`

centos6.2安装virtualbox4.1.10+virtualbox后台运行+开机自启动

阅读更多
笔者的环境是centos6.2x86+virtualBox4.1.10

1.安装前请对centos进行升级。

yum update

2.下载virtualbox4.1.10。地址

https://www.virtualbox.org/wiki/Linux_Downloads

要选择红帽对应的版本。

3.下载完成后进行安装,不要用rpm的方式进行安装,请用yum的方式安装,它可以解决一部分的软件包依赖关系。

安装完成后启动virtualbox会得到以下的错误。



大概意思是虚拟机的内核驱动没有加载或是因为/dev/vboxdr有权限问题,请切换到root用户用/etc/init.d/vboxdtrv setup命令重新安装内核模块,并且建议应该先安装DKMS。我们不妨切到root用户先执行/etc/init.d/vboxdtrvsetup命令看看有什么结果。

显示用DKMS注册虚拟机内核失败。看样子要装DKMS这个东西了。下载地址,

http://rpm.pbone.net/index.php3?stat=3&limit=2&srodzaj=1&dl=40&search=dkms&field[]=1&field[]=2

下载红帽版本

5.下载后用rpm安装,安装完成后再次运行/etc/init.d/vboxdtrv setup


6.显示没有kernel-headers那么我们接下来安装kernel-headers

yum install kernel-headerskernel-devel gcc

7.安装完成后再次运行/etc/init.d/vboxdtrv setup

显示没有make命令那么安装make

8.yum install make(如果早就已经安装好了开发工具那么就会省去这一步,如果有了kernel-headers也会省去第六6步)

9.安装好后再次运行/etc/init.d/vboxdtrv setup

这次成功了。

然后就可打开virtualbox建立虚拟系统了。但是还有个问题,作为服务器,我们希望注销用户后虚拟系统一直在后台跑着,如何实现呢?

很简单用命令就行了

将所有虚拟系统都关掉,然后用

VBoxManage startvm 虚拟机名字 --type headles命令启动虚拟机,这样就会在后台运行了



VBoxManage startvm          <uuid>|<name>...

                            [--typegui|sdl|headless]



如何关闭?

VBoxManage controlvm 虚拟机名称 poweroff这是关机命令

VBoxManage controlvm        <uuid>|<name>

                           pause|resume|reset|poweroff|savestate|                           

如何开机启动?

编辑/etc/rc.d/rc.local

在里面加入

VBoxManage startvm 虚拟机名字 --type headles命令就可以开机启动了。

#!/bin/sh

#

# This script will beexecuted *after* all the other init scripts.

# You can put your owninitialization stuff in here if you don't

# want to do the full Sys Vstyle init stuff.



touch /var/lock/subsys/local

VBoxManage startvm win03-233 --type headless

VBoxManage startvm centos6.2-234 --type headless
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics