2018年6月21日 星期四

透過 VBoxManage 來控制 VirtualBox

 以下資料取自 http://rainstingtw.blogspot.com/2012/09/use-VBoxManage-to-control-VirtualBox.html

透過 VBoxManage 來控制 VirtualBox 

9月 27, 2012
在 VirtualBox 內,除了透過圖形化介面來控制我們的虛擬機器外,
也可透過下 command 的方式來控制我們的虛擬機。

這裡來紀錄一下,如何透過 VBoxManage 這個內建的 command 來控
制 VirtualBox:,以下就介紹幾個常用的:

1. How to show the VirtualBox VM info
VBoxManage showvminfo

2. How to show the VM Harddrive info
VBoxManage showhdinfo

3. How to list running VM
VBoxManage list runningvms

4. How to list available VM
VBoxManage list vms

5. How to list available VM Harddrives
VBoxManage list hdds

6. How to list available ISO’s
VBoxManage list dvds

然後這裡列出如何透過 command 來直接控制 VM:

7. How to Start VM

這裡要注意,透過在前面增加前綴字「nohup」,可以確保離開 console 後,
我們的 VM 還能在背景執行:

nohup VBoxHeadless --startvm "vmname"
P.S. 這邊建議改用"&" VBoxHeadless --startvm "vmname" &, 這樣程序就會直接進入背景執行效果相同

8. How to pause VM
VBoxManage controlvm "vmname" pause

9. How to resume VM
VBoxManage controlvm "vmname" resume

10. How to reset VM
VBoxManage controlvm "vmname" reset

11. How to poweroff VM (hard poweroff eg. pull the plug)
VBoxManage controlvm "vmname" poweroff

12. How to send poweroff single to VM (tells VM OS to shutdown)
VBoxManage controlvm "vmname" acpipowerbutton

13. How to attach a DVD / CD to a running vm
VBoxManage controlvm "vmname" dvdattach "filename"

14. How to de-attach a DVD / CD from a running vm
VBoxManage controlvm "vmname" dvdattach none

15. How to find out the VM IP
VBoxManage guestproperty get "vmid" "/VirtualBox/GuestInfo/Net/0/V4/IP"

沒有留言: