Useful Virtualbox Command

Log into your host server using ssh.

Get a list of all VMs.

$ VBoxManage list vms

Start a guest VM named mywiki with RDP enabled and listening on port 3390.

If you plan to run multiple guest VMs in headless mode with RDP enabled, you will need to choose a unique port for each to listen on. If you don’t specify a port, the default port is 3389.

$ nohup VBoxHeadless -s mywiki -v on -p 3390 &

Now if you want to check that your guest VM is among your running VMs

$ VBoxManage list runningvms

If you should need to connect to the console on that running VM named mywiki. Lets assume it’s IP address is 192.168.139.10. We are going to use rdesktop, which is a good RDP client found in most linux distros.

$ rdesktop -g 1024x768 -a 16 -5 192.168.139.10:3390 &

To view the properties of your VM use the showvminfo option. This is handy if you want to connect your RDP client to a running VM and you don’t remember which port your VM is listening on.

$ VBoxManage showvminfo mywiki Ok, now lets assume you have a rogue guest-

VM that want to shut-down and it is not responding to your request for a normal orderly shut-down.

You can power it off using-

$ VBoxManage contolvm mywiki poweroff

For details see virtualbox site-

https://www.virtualbox.org/manual/ch08.html

https://www.virtualbox.org/manual/ch08.html

$ vboxmanage import <file>.ova

https://www.virtualbox.org/manual/ch08.html

$ vboxmanage export <machine-name> -o <file>.ova

https://www.virtualbox.org/manual/ch08.html

$ vboxmanage clonevm <source-machine-name> --name <target-machine-name> --register

Check running process and kill in case VM got stuck

 ps -AF | grep V

Exporting and importing appliances

In the case you do your backups using some sort of shell script, VBoxManage export (followed by the virtual machine name, can help you get the job done. The following command will export the CentOS7 appliance to ~/VMexports/CentOS7.ova:

VBoxManage export CentOS7 --output ~/VMexports/CentOS7.ova

To import it (not surprisingly), we will use VBoxManage import:

VBoxManage import ~/VMexports/CentOS7.ova

Resize Virtual Disk Size

VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi

VBoxManage modifyhd "cloned.vdi" --resize 51200

VBoxManage clonehd "cloned.vdi" "resized.vmdk" --format vmdk

Changing UUID in virtual disk

VBoxManage internalcommands sethduuid "/home/user/VirtualBox VMs/drupal/drupal.vhd"

 

Leave a Reply