CentOS命令行安装Virtualbox

添加virtualbox源

cd /etc/yum.repos.d
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

添加rpmforge源

cd
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-1.el6.rf.x86_64.rpm

安装依赖

yum --enablerepo rpmforge install dkms
yum groupinstall "Development Tools"
yum install kernel-devel

安装VirtualBox

yum install VirtualBox-4.1

系统有点BUG,修正一下
Error! Your kernel headers for kernel 2.6.32-71.el6.x86_64 cannot be found at
/lib/modules/2.6.32-71.el6.x86_64/build or /lib/modules/2.6.32-71.el6.x86_64/source.
[FAILED]
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules [FAILED]
(Look at /var/log/vbox-install.log to find out what went wrong)

cd /lib/modules/modules/2.6.32-71.el6.x86_64/
ln -s /usr/src/kernels/2.6.32-220.23.1.el6.x86_64/ build
/etc/init.d/vboxdrv setup

安虚拟机Windows Server 2003
因为CentOS没有桌面,需要先在自己的电脑上安装一个Windows Server 2003,运行起来并且配置好后,关闭虚拟机,将对应的vdi文件复制到服务器,服务器新建立的虚拟机将直接使用该文件作为硬盘

VBoxManage createvm --name server2003 --ostype Windows2003 --register --basefolder /mydata/vms/
VBoxManage modifyvm server2003 --memory 512  --accelerate3d off --nic1 bridged --bridgeadapter1 eth0
VBoxManage storagectl server2003 --name IDE --add ide --controller PIIX4 --bootable on
VBoxManage storageattach server2003 --storagectl IDE --type hdd --port 0 --device 0  --medium /mydata/vms/server2003/server2003.vdi

启动虚拟机

VBoxManage startvm server2003 -type headless

强制关闭虚拟机

VBoxManage controlvm server2003 poweroff

参考:
https://www.virtualbox.org/manual/ch08.html#vboxmanage-createvdi

http://www.cnblogs.com/sunson/articles/2268215.html

发表评论

电子邮件地址不会被公开。

*