在CentOS中使用VBoxManage命令管理VirtualBox虚拟机,首先要确保已安装VirtualBox。以下是一些常用操作:
VBoxManage list vms,可查看所有已注册虚拟机的名称和UUID。VBoxManage createvm --name "虚拟机名称" --ostype "操作系统类型" --register,如VBoxManage createvm --name "CentOSVM" --ostype "CentOS_64" --register。VBoxManage modifyvm "虚拟机名称" --参数,例如VBoxManage modifyvm "CentOSVM" --memory 2048 --cpus 2,可设置内存为2048MB、CPU核数为2。VBoxManage createhd --filename "硬盘文件路径" --size 硬盘大小,再添加到虚拟机VBoxManage storagectl "虚拟机名称" --name "控制器名称" --add sata --controller IntelAhci,然后VBoxManage storageattach "虚拟机名称" --storagectl "控制器名称" --port 0 --device 0 --type hdd --medium "硬盘文件路径"。VBoxManage startvm "虚拟机名称" --type headless,以无头模式启动,也可不加--type参数以默认方式启动。VBoxManage controlvm "虚拟机名称" poweroff,强制关闭虚拟机。