Skip to content

Instantly share code, notes, and snippets.

@samqi
Last active March 17, 2020 10:30
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save samqi/e0fcada6383fa166d899d18cbb72082b to your computer and use it in GitHub Desktop.
virtualbox cli command
# List virtual machines
VBoxManage list vms
"MyVM" {wwwwww-4301-4a7d-8af8-fe02fed00451}
# Start VM in headless mode
VBoxManage startvm MyVM --type headless
# Power off VM
VBoxManage controlvm MyVM poweroff
#show details
VBoxManage showvminfo MyVM
###############################
#create virtualbox with a script
# http://www.digitesters.com/manage-a-virtualbox-headless-system-create-a-vm-with-a-script/
###############################
# Get IP Address from Virtualbox VMs
# https://forums.virtualbox.org/viewtopic.php?f=1&t=36592
#show ip from interface 1
VBoxManage guestproperty get "MyVM" "/VirtualBox/GuestInfo/Net/0/V4/IP"
#show ip from interface 2
VBoxManage guestproperty get "MyVM" "/VirtualBox/GuestInfo/Net/1/V4/IP"
#or
VBoxManage guestproperty enumerate MyVMb|grep IP
##################################
# for newer encrypted Virtualbox, you can use this after stasrting server headless
VBoxManage controlvm "vmname" addencpassword "vmname" "/home/user/vm-name-password"
## export ova https://www.techrepublic.com/article/how-to-import-and-export-virtualbox-appliances-from-the-command-line/
vboxmanage export vmname -o vmname.ova
@samqi
Copy link
Author

samqi commented Jul 25, 2019

# Convert Virtualbox from vmdk to Windows Server format (since .ova cannot be imported for Win 2K12
# from https://superuser.com/questions/1133256/convert-ova-to-vhd-for-usage-in-hyper-v
# virtualbox official docs ref: note, latest version uses clonemedium but clonehd still supported https://www.virtualbox.org/manual/ch08.html#vboxmanage-clonehd
cd \Program Files\Oracle\Virtualbox
VBoxManage clonehd --format vhd "source.vmdk" "d:\images\destination.vhd"

@samqi
Copy link
Author

samqi commented Jul 26, 2019

@samqi
Copy link
Author

samqi commented Aug 9, 2019

From https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html:

VBoxManage list ostypes
VBoxManage storagectl $VM --name "IDE Controller" --add ide
VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0  --device 0 --type dvddrive --medium "C:\VM\ISO\ubuntu-18.04.2-live-server-amd64.iso"
VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 e1000g0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment