ubuntu

VirtualBox在Ubuntu上如何使用命令行操作

小樊
47
2025-08-25 10:49:24
栏目: 智能运维

以下是VirtualBox在Ubuntu上的命令行操作方法:

  1. 安装VirtualBox

    sudo apt update  
    sudo apt install virtualbox  
    
  2. 创建虚拟机

    VBoxManage createvm --name "UbuntuVM" --ostype "Ubuntu_64" --register  
    
  3. 配置虚拟机

    • 设置内存:
      VBoxManage modifyvm "UbuntuVM" --memory 2048  
      
    • 创建虚拟硬盘并添加:
      VBoxManage createhd --filename "UbuntuVM.vdi" --size 20000  
      VBoxManage storagectl "UbuntuVM" --name "SATA Controller" --add sata --controller IntelAhci  
      VBoxManage storageattach "UbuntuVM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "UbuntuVM.vdi"  
      
  4. 启动/关闭虚拟机

    • 启动:
      VBoxManage startvm "UbuntuVM"  
      
    • 关闭:
      VBoxManage controlvm "UbuntuVM" poweroff  
      
  5. 其他常用操作

    • 列出所有虚拟机:
      VBoxManage list vms  
      
    • 删除虚拟机(谨慎操作,会删除所有硬盘数据):
      VBoxManage unregistervm "UbuntuVM" --delete  
      

说明:需先安装VirtualBox扩展包以支持命令行工具VBoxManage,部分操作(如网络配置)需结合图形界面或额外参数。

0
看了该问题的人还看了