Working with the VBoxManage and VBoxHeadless

Hello everybody, today I’m going to show you some basics in managing virtual machines in VirtualBox, from command line.

First, lets assume you have installed virtual machine and you want to run particular one, but you don’t know what was its real name. To list all virtual machines you use:

VBoxManage list vms

Then when you see the name of machine, you can run it by typing:

VBoxHeadless -startvm “nameofmachine”

This way, you’ll be able to run machine without running VirtualBox GUI.

Now that I experimented with VBoxManage controlvm, you can use it to reset, poweroff , savestate of machine and all those cool stuff you can do in GUI. For example, to restart machine, use:

VBoxManage controlvm “nameofmachine” reset

One more thing, that is very cool is that you can change type of networking while machine is still running. You can do that with:

VBoxManage controlvm “nameofmachine” nic<1-N> null|nat|bridged|intnet|hostonly [<devicename>]

For device name, I have vboxnet0, and that is the device which your host recognizes. After changing the way your virtual machine access the network, you can reset it just in case, and everything should work well.

For exporting you can use command:

VBoxManage export “nameofmachine” -o nameofovffile.ovf –legacy09

You can add some informations about virtual machine but they are not needed for importing it and running safely. Legacy09 is for including possibilities that someone who will import can read OVF 0.9 standard and not newest 1.0.

Importing is also piece of cake:

VBoxManage import nameofovffile.ovf

You can include –dry-run or -n flag to go through the process of imorting in detail and choose what to import and the way of importing.

After importing, you may find some difficulties in network access on virtual machine. The problem should be easy solved by removing /etc/udev/rules.d/70-persistent-net.rules

I’d also point you to this post, cuz this is very good post about doing some virutal machine work in command line. YEY! 😀

Advertisements