在CentOS上使用VirtualBox命令行工具VBoxManage可完成虚拟机管理操作,以下是常用命令及示例:
VBoxManage list vms VBoxManage createvm --name "VM名称" --ostype RedHat_64 --register VBoxManage unregistervm "VM名称" --delete # 启动(支持headless模式,无图形界面) VBoxManage startvm "VM名称" --type headless|gui # 关闭 VBoxManage controlvm "VM名称" poweroff VBoxManage modifyvm "VM名称" --memory 2048 --cpus 2 # 创建硬盘 VBoxManage createhd --filename "/path/to/disk.vdi" --size 20000 # 挂载到虚拟机 VBoxManage storageattach "VM名称" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/path/to/disk.vdi" # 设置NAT网络 VBoxManage modifyvm "VM名称" --nic1 nat # 桥接网络(需指定物理网卡) VBoxManage modifyvm "VM名称" --nic1 bridged --bridgeadapter1 "eth0" VBoxManage storageattach "VM名称" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "/path/to/centos.iso" VBoxManage list runningvms # 查看运行中的虚拟机 VBoxManage showvminfo "VM名称" # 查看详细信息 以上信息综合自。