在CentOS下使用VirtualBox命令行管理虚拟机,主要使用VBoxManage命令,以下是一些常见操作:
- 创建虚拟机:
VBoxManage createvm --name "虚拟机名称" --ostype RedHat_64 --register。 - 删除虚拟机:
VBoxManage unregistervm "虚拟机名称" --delete。 - 启动虚拟机:
VBoxManage startvm "虚拟机名称" --type headless(headless表示后台运行)。 - 关闭虚拟机:
VBoxManage controlvm "虚拟机名称" poweroff(强制关闭);VBoxManage controlvm "虚拟机名称" acpipowerbutton(发送ACPI关机信号,正常关机)。 - 查看虚拟机信息:
VBoxManage showvminfo "虚拟机名称"。 - 配置虚拟机内存和CPU:
VBoxManage modifyvm "虚拟机名称" --memory 内存大小(MB) --cpus CPU数量。 - 添加虚拟硬盘:先创建硬盘
VBoxManage createhd --filename "硬盘路径/硬盘名.vdi" --size 硬盘大小(MB),再挂载到虚拟机VBoxManage storageattach "虚拟机名称" --storagectl "控制器名称" --port 端口号 --device 设备号 --type hdd --medium "硬盘路径/硬盘名.vdi"。