1、添加源

wget -P /etc/yum.repos.d http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo

2、安装

yum install VirtualBox
yum install dkms kernel-devel kernel-headers
/sbin/vboxconfig #重新编译 VirtualBox 内核

3、将用户加入 vboxusers 组

sudo groupadd -G vboxusers -a root

4、开机自启动:

vi /etc/rc.d/rc.local
VBoxManage startvm 虚拟机名字 -type vrdp &

chmod +x /etc/rc.d/rc.local

5、其他命令

VBoxManage list vms #列出虚拟机
VBoxManage list runningvms #列出运行中的虚拟机
VBoxManage controlvm 虚拟机名字 acpipowerbutton # 关闭虚拟机,等价于点击系统关闭按钮,正常关机
VBoxManage controlvm 虚拟机名字 poweroff # 关闭虚拟机,等价于直接关闭电源,非正常关机