Assorted Tips – Oracle VM VirtualBox

With this post I start a new series with short tips about tools and frameworks. My main motivation is to add a “safety net” to my OneNote notebook full of notes and, who knows, maybe they are useful to others as well.

Oracle VM VirtualBox

Through the command-line you can issue a number of commands that can be useful for advanced users. (For the rest of the post let’s assume you are in a command prompt where VirtualBox is installed.)

Headless VMs

You can use command-line to start a VM in headless mode (you will need to enable remote desktop to access it, be warned!):

VBoxHeadless -startvm <vm-name>

You can also save the state of a running VM using the following command:

VBoxManage controlvm <vm-name> savestate

(Use double quotes to surround the VM name if it has spaces.)

Clones

If you have a local disk and want to add a copy of it (very copy-paste approach), in older VirtualBox versions you can reassign a disk Id:

VBoxManage internalcommands sethduuid <file>

(That one is for older versions really – today you can create clones directly from UI.)

To create a clone from the command-line (why not? you can use this in a setup script):

VBoxManage clonehd <file-in> <file-out> -format VDI|VMDK|VHD|RAW

(Output format is optional, but useful if you plan for a later export to another tool.)