VBoxManage


虛擬機名稱 centos6.9-1 centos6.9-2 centos6.9-3
使用命令開機 虛擬機
VBoxManage startvm 'centos6.9-1' 正常啟動
VBoxManage startvm centos6.9-2 -type vrdp 無界面啟動
VBoxManage startvm centos6.9-2 --type headless 無界面啟動 推薦使用
VBoxManage startvm 'centos6.9-3'
 
 
查看正在運行的虛擬機
VBoxManage list runningvms
 
關閉虛擬機
VBoxManage controlvm 'centos6.9-2' poweroff 斷電關閉虛擬機
VBoxManage controlvm centos6.9-2 savestate 休眠虛擬機
VBoxManage discardstate centos6.9-2 放棄休眠,直接關閉
VBoxManage controlvm centos6.9-2 acpipowerbutton 正常關閉 centos6.9 推薦使用
 
查看快照列表
VBoxManage snapshot centos6.9-2 list
 
創建快照
VBoxManage snapshot centos6.9-2 take snap20180603 snap20180603為快照名稱
刪除快照
VBoxManage snapshot centos6.9-2 delete snap20180603
快照回復
uuid 使用 查看快照列表獲取
VBoxManage snapshot centos6.9-2 restore 0307c6d5-1258-4cd4-984a-4341f17c1bf9 [uuid]
 
設置開機自啟動
 
virtualbox(vboxmanage)自動啟動虛擬機
系統centos 7,virtualbox 5,宿主機重啟后,其上的虛擬機不能自動啟動,怎樣才能使虛擬機能隨主機啟動而自動啟動呢?步驟如下:
步驟一:
# vi /etc/default/virtualbox
# virtualbox defaults file
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostartvm.cfg
步驟二:
#vi /etc/vbox/autostartvm.cfg
# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny
# Create an entry for each user allowed to run autostart
root = {
allow = true
startup_delay = 10
}
步驟三:
#VBoxManage setproperty autostartdbpath /etc/vbox
步驟四:centos6.9-2為需要開機自啟動的虛擬機
#VBoxManage modifyvm centos6.9-2 --autostart-enabled on
步驟五:
#service vboxautostart-service restart --測試發現stop/start不能啟動vm,而restart則可以
--詳細操作參考參考文獻【1】。
 
參考文獻:
【1】 How To Set Your VirtualBox 4.2 VM to Automatically Startup , http://lifeofageekadmin.com/how-to-set-your-virtualbox-vm-to-automatically-startup/
【2】 9.24. Starting virtual machines during system boot, http://www.virtualbox.org/manual/ch09.html#autostart
【3】 8.8.9. Auto starting VMs during host system boot, http://www.virtualbox.org/manual/ch08.html
 
如果以上不起作用的情況下
編輯shell腳本
#!/bin/bash
VBoxManage startvm centos6.9-1 --type headless
VBoxManage startvm centos6.9-2 --type headless
VBoxManage startvm centos6.9-3 --type headless
 
添加執行權限
chmod +x /etc/vbox/vm_centos.sh
加入到開機自啟動腳本中
 
安裝增強工具,實現文件共享
點擊安裝增強
 
yum -y upgrade kernel kernel-devel
yum install kernel sources kernel-devel
 
sshfs
 
掛載虛擬光驅
mount /dev/cdrom /mnt/
 
cd /mnt/ 查看列表
執行文件
./VBoxLinuxAdditions.run
 
cat /proc/version
查看版本信息,添加版本
/sbin/rcvboxadd quicksetup
/sbin/rcvboxadd quicksetup 3.10.0-957.1.3.el7.x86_64
 
/sbin/rcvboxadd quicksetup 3.10.0-957.10.1.el7.x86_64
 
執行掛載命令
 
# 掛載命令 共享目錄 要掛載到的目錄
mount -t vboxsf www /data/www/
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM