通过命令行启动 VirtualBox,可以省去直接启动虚拟机显示图形界面的那部分资源。
这种形式非常适用于在服务器上虚拟 n 台机器同时提供服务。
使用 Host Interface 网络连接方式,
可以让虚拟机的虚拟网卡获取和主机一样的网络地址等信息,从而可以直接对外提供服务。
1.查看主机上的可用虚拟机:
C:\Users\Administrator>d:
D:\>cd D:\Program Files\Oracle\VirtualBox
D:\Program Files\Oracle\VirtualBox>
D:\Program Files\Oracle\VirtualBox>VBoxManage list vms
"RedHat63" {fe79a2b1-cc8a-4b78-bcf7-9f964506a8a5}
"MysqlMac" {0efaee42-5037-4763-b711-0769ad3d9630}
"gc1" {d2ebd95c-be22-4d2e-89f4-a01b25f484eb}
"solaris186" {3ea74180-2798-4fa5-a360-106a66937566}
"RedHat63_2" {24ae9504-7c9f-487a-b2a4-a0ba554fafad}
注:VBoxManage list vms -l 显示详细信息。
2.启动指定的可用虚拟机:
VBoxManage startvm <uuid>|<name> [--type gui|sdl|headless]
2.1.打开默认窗口的虚拟机:
$VBoxManage startvm RedHat63 --type gui
Waiting for the VM to power on...
VM has been successfully started.
2.2.打开简单窗口的虚拟机:
<img width="690" height="534" alt="说明: VirtualBox
$VBoxManage startvm RedHat63 --type sdl
Waiting for the VM to power on...
VM has been successfully started.
2.3.打开无窗口的虚拟机(无外设):
$VBoxManage startvm RedHat63 --type headless
Waiting for the VM to power on...
VM has been successfully started.
注:这种方式打开的虚拟机可以通过,如:远程桌面或 ssh 来登陆操作。
3.查看已经运行的虚拟机:
$VBoxManage list runningvms
"RedHat63" {937d825f-4a3f-46c3-a22b-9e20d15964ec}
4.控制已经运行的虚拟机:(暂停|恢复|重启|关机|休眠)
VBoxManage controlvm <uuid>|<name> pause|resume|reset|poweroff|savestate
注:更多参数详见 VBoxManage --help 输出的帮助。
5.修改虚拟机配置:(--memory 取值单位MB)
$VBoxManage modifyvm RedHat63 --memory 256 --acpi on --boot1 disk -nic1 bridged
6.创建一个虚拟磁盘:(--size 取值单位MB --sizebyte 取值单位字节
$VBoxManage createhd --filename RedHat63.vdi --size 30000
更多命令用法详见 VBoxManage --help 输出的帮助。
后台自动开启vBox脚本
start D:\"Program Files"\Oracle\VirtualBox\VBoxManage.exe startvm RedHat63 --type gui
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29302187/viewspace-2061670/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29302187/viewspace-2061670/