在Ubuntu 10.04 LTS Server上通过SSH安装Virtualbox 4.0
直接在Server上安装virtualbox-ose(Open Source Edition)版本后, 启动老是提示出错:
MyServer:~#/etc/init.d/virtualbox-ose start * Starting VirtualBox host networking... [ OK ] * Starting VirtualBox kernel module vboxdrv * No suitable module for running kernel found.
后来发现官方网站上闭源版本的介绍, 真是很详尽: http://www.virtualbox.org/wiki/Linux_Downloads
MyServer:~#vi /etc/apt/sources.list
添加一句:
deb http://download.virtualbox.org/virtualbox/debian lucid contrib
MyServer:~#wget http://download.virtualbox.org/virtualbox/debian/Oracle_vbox.asc MyServer:~# apt-key add oracle_vbox.asc MyServer:~#wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - MyServer:~# apt-get update MyServer:~# apt-get install virtualbox-4.0
第一次运行出错:
MyServer:~# /etc/init.d/vboxdrv setup * Stopping VirtualBox kernel modules [ OK ] * Uninstalling old VirtualBox DKMS kernel modules [ OK ] * Trying to register the VirtualBox kernel modules using DKMS Error! Your kernel headers for kernel 2.6.32-28-server cannot be found at /lib/modules/2.6.32-28-server/build or /lib/modules/2.6.32-28-server/source. * Failed, trying without DKMS * Recompiling VirtualBox kernel modules * Look at /var/log/vbox-install.log to find out what went wrong
查找错误日志 /var/log/vbox-install.log 发现提示要安装linux-headers-2.6.32-28-server
apt-get install linux-headers-2.6.32-28-server
或者
apt-get install linux-headers-`uname -r` apt-get install linux-headers-generic
再次启动就正常了
MyServer:~# /etc/init.d/vboxdrv start * Starting VirtualBox kernel modules [ OK ]
运行Setup看看:
MyServer:~# /etc/init.d/vboxdrv setup * Stopping VirtualBox kernel modules [ OK ] * Uninstalling old VirtualBox DKMS kernel modules [ OK ] * Trying to register the VirtualBox kernel modules using DKMS [ OK ] * Starting VirtualBox kernel modules
如果Linux内核升级后,出现 Failed, trying without DKMS
/etc/init.d/vboxdrv setup * Stopping VirtualBox kernel modules [ OK ] * Uninstalling old VirtualBox DKMS kernel modules [ OK ] * Removing old VirtualBox netadp kernel module [ OK ] * Removing old VirtualBox netflt kernel module [ OK ] * Removing old VirtualBox kernel module [ OK ] * Trying to register the VirtualBox kernel modules using DKMS * Failed, trying without DKMS * Recompiling VirtualBox kernel modules [ OK ] * Starting VirtualBox kernel modules [ OK ]
那就安装dkms
apt-get install dkms
好了, 现在可以用普通用户的身份来使用虚拟机了
Ubuntu1010是网上下载的IDE硬盘系统
Ubuntu1004是自己装的Sata硬盘系统
在上传虚拟机镜像之前,最好在本地打开虚拟机,清除一下网卡MAC addresses的Cache后再关机:
sudo rm /etc/udev/rules.d/70-persistent-net.rules
创建Windows的虚拟机
user@MyServer:~$VBoxManage createvm --name Ubuntu1010 --register Virtual machine 'Ubuntu1010' is created and registered. UUID: b066726c-8559-48f1-b998-fd7ad742e7ce Settings file: '/home/user/VirtualBox VMs/Ubuntu1010/Ubuntu1010.vbox' user@MyServer:~$VBoxManage createvm --name Ubuntu1004 --register Virtual machine 'Ubuntu1004' is created and registered. UUID: 9e2a7030-953e-4935-aad7-07de8269ab1c Settings file: '/home/www/VirtualBox VMs/Ubuntu1004/Ubuntu1004.vbox'
顺便贴一下如何删除虚拟机,包括虚拟机文件, 下手前要三思:
user@MyServer:~$VBoxManage unregistervm Ubuntu1004 --delete
创建虚拟机所需的存储控制器
user@MyServer:~$VBoxManage storagectl Ubuntu1010 --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on user@MyServer:~$VBoxManage storagectl Ubuntu1004 --name "SATA Controller" --add sata --controller IntelAHCI --hostiocache on