Virtual Box commands

From Newroco Tech Docs
Jump to navigationJump to search

Virtual Box commands

List commands

vboxmanage list vms
vboxmanage list ostypes
vboxmanage list runningvms
vboxmanage list hostdvds
vboxmanage list hostinfo
vboxmanage list hddbackends
vboxmanage list systemproperties
vboxmanage list dhcpservers
vboxmanage list hdds
vboxmanage list dvds

Create new VM

VBoxManage createvm -name name_new_vm -register

Creade a new image .vdi of 4000 MB

VBoxManage createvdi -filename new_image.vdi -size 4000

Start VM in headless mode

VBoxManage startvm vm_name --type headless

Power off VM

VBoxManage controlvm vm_name poweroff

Create raw partition

qemu-img create -f raw -o size=1.2T image_name.raw

Convert from .raw to .vdi

VBoxManage convertfromraw image_name.raw image_name.vdi

Attach a disk to virtualbox

  • To check the right configuration use
 VBoxManage showvminfo vm_name 
  • use depending on the situation SATA, SATAController, SATA Controller
  • change the port if you have multiple disk on the VM
VBoxManage storageattach Moodle --storagectl "SATA" --port 3 --device 0 --type hdd --medium vm_image.vdi 

Remove disk from VM

sudo VBoxManage storageattach Moodle --storagectl "SATA" --port 3 --device 0 --type hdd --medium emptydrive

Undefine a disk

vboxmanage closemedium disk disk_name

To undefine also to delete a dis use

vboxmanage closemedium disk disk_name --delete