Posted by: Rick Vanover
Rick Vanover, Sun xVM, VirtualBox, Virtualization, Virtualization platforms, Virtualization strategies
Sun xVM VirtualBox offers a powerful command-line interface (CLI) component, VBoxManage, which can perform most functions within VirtualBox. Having a robust CLI is key to automation and scripting, even in a workstation virtualization product. In my continued coverage of VirtualBox, this blog will highlight some of the parameters of VBoxManage with some examples and areas where this command can be of use.
Probably one of the more versatile commands for VBoxManage is
modifyvm. This parameter can set memory, operating system type, pae settings, monitor quantity, hardware inventory as well as snapshot configuration. Here is a sample command that sets a memory amount, makes the CD-ROM disk the first boot device and disables USB support:
vboxmanage modifyvm XP-TestSystem -memory 512 -boot1 dvd -usb off
The modifyvm parameter also has extended options such as BIOS display time, network interface driver type, host network interface assigned to the VM and enabling or disabling of the clipboard. Overall, modifyvm has over 50 parameters for an individual VM.
From an automation standpoint, the controlvm parameter would be used to start a VM at host system boot. Controlvm can also be used to attach USB or DVD devices. The entry below will disconnect the media of the two virtual Ethernet adapters and reset the power state:
vboxmanage controlvm XP-TestSystem reset setlinkstate1 off
vboxmanage controlvm XP-TestSystem setlinkstate2 off
Note that in the case of an inventory of multiple devices of the same type, a separate entry would be required as in the case of disabling the network interface.
The snapshot parameter can be used to manage all elements of a snapshot. In the case of a frequently used test system, it may be a good idea to automate the change back to the base snapshot. The following command would revert a VM to the existing snapshot:
vboxmanage snapshot XP-TestSystem discardcurrent -state
This command cannot be executed while the VM is running, yet a leading with a power down
controlvm parameter can get the system to a state where running the snapshot parameter will do the trick.
This is a very quick sample of what is capable with the VBoxManage command. I don’t know of anything that can be done in the interface that cannot be done with this command. VBoxManage commands also interact the same way across different platforms of xVM VirtualBox. This flexibility offers a compelling solution for an automated deployable solution at the zero-cost of xVM VirtualBox. The online user manual has the entire chapter 8 dedicated to the VBoxManage command, which can be downloaded from the VirtualBox website.