命令行启动 VirtualBox 虚拟机

查看所有虚拟机

VBoxManage.exe  list vms

查看正在运行的虚拟机

VBoxManage.exe  list runningvms

无界面启动

VBoxManage.exe  startvm "centos" --type headless

正常关闭虚拟机

VBoxManage.exe  controlvm "centos"  acpipowerbutton

强制关机

VBoxManage.exe  controlvm "centos"  poweroff

通过网络设置连接方式为网桥网卡,这样网络IP和真实IP在同一个网段 进入命令行 执行 dhclient enp0s3 -v 即可访问网络

批量启动

start_all.bat
VBoxManage.exe startvm centost1 --type headless
VBoxManage.exe startvm centost2 --type headless
VBoxManage.exe startvm centost3 --type headless
VBoxManage.exe startvm centost4 --type headless
VBoxManage.exe startvm centost5 --type headless
VBoxManage.exe startvm centost6 --type headless
VBoxManage.exe startvm centost7 --type headless

批量关闭

VBoxManage.exe controlvm centost1  poweroff
VBoxManage.exe controlvm centost2  poweroff
VBoxManage.exe controlvm centost3  poweroff
VBoxManage.exe controlvm centost4  poweroff
VBoxManage.exe controlvm centost5  poweroff
VBoxManage.exe controlvm centost6  poweroff
VBoxManage.exe controlvm centost7  poweroff

批量复制

这样不需要重新安装系统,只要用其中一个安装好的系统即可

mkdir centos1
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t1.vdi
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t2.vdi
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t3.vdi
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t4.vdi
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t5.vdi
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t6.vdi
VBoxManage.exe clonehd centos/centos.vdi  centos1/centos_t7.vdi