Using VirtualBox: Notes and Hints

by Jack Email

After using VirtualBox (version 3.0.12) for 3 months now, I've made some notes on things that fall into the 'good to know' category to make virtual computing easier.

1) Don't burn a CD for each operating system, the raw ISO file on your hard drive is just fine.
2) Installing guest additions makes the virtual machine's interface more responsive.
3) Setting up permanent shared folders makes working with files from one machine to another simple.
4) Backing up machines is as easy as copying the .VDI file.
5) Cloning a virtual machine to another physical machine is an easy way to copy your computing environment from a desktop to a laptop.

Follow up:


1) Don't burn a CD for each operating system, the raw ISO file on your hard drive is just fine.

VirtualBox's Virtual Media Manager allows you to not only manage your virtual drive images, but CD/DVD images as well. You just need to add the image file to the Media Manager and it will be available to VirtualBox. When you create a new virtual machine, set up the machine normally. Once it appears in VirtualBox's main window, click "settings" and "CD/DVD-ROM". Then select "Mount CD/DVD Drive" and select the appropriate ISO image file. After the new operating system has installed, remember to unmount the installation ISO so your new machine can boot from its virtual hard drive.



2) Installing guest additions makes the virtual machine's interface more responsive.

Without Guest Additions, VirtualBox's guest machines feel a little like molasses. This is because of the need to capture and isolate the mouse input. Installing guest additions obviates the need to capture the mouse at all and your inputs have a more fluid and normal feel. Installing guest additions is simple:

From your virtual machine, unlock the mouse by holding down the 'host' key (by default the right Ctrl key) and move the mouse pointer outside of the virtual machine's window. Click on the "Devices" menu on the VM's upper border and select "Install Guest Additions". This mounts the guest additions ISO for use within the virtual machine. Now you proceed with the installation from the virtual machine, with the exact steps depending on your operating system.

For Ubuntu flavored Linux guests, open a terminal window and type:

cd /media/cdrom0

For 64 bit linux guest enter:
sudo sh ./VBoxLinuxAdditions-amd64.run

For 32 bit linux guest enter:
sudo sh ./VBoxLinuxAdditions-x86.run

If you use the wrong version, it just errors out, so you can't make a critical mistake here if you aren't sure whether you are using a 32bit or 64bit operating system.

And that's it! Restart the virtual machine and now you have full control over the machine's window size and shape. Your mouse no longer requires capture and you can enter and exit seamless mode by toggling host-L (usually right Ctrl-L).


3) Setting up permanent shared folders makes working with files from one machine to another simple.

The bottom window bar of each virtual machine contains a number of icons which allow control over how the virtual operating system sees resources of the host and the physical machine. To create a shared folder, right click the folder icon. This opens the shared folder management window. Now click the "folder+" icon at the upper right side, and choose a host folder to use as a shared folder (I'll use "SharedFiles" for my example). You would generally also want to select "make permanent". Click through the "OK"s. You now have a folder on the host that will be made available to the guest system. On the guest, create a new folder, for example /home/jack/MyShare. Obviously, unless your name is Jack too, jack would be replaced by the username you logged in with.

To mount this folder in a Ubuntu flavored Linux guest open a terminal:
HostDirName = the name of the shared folder on the host drive.
GuestDirName = the name of the folder on the guest.
UserName = the user account you are logged in as.

For my example above this would be "sudo mount -t vboxsf SharedFiles /home/jack/MyShare", or generically as:

sudo mount -t vboxsf HostDirName /home/UserName/GuestDirName

To make sure your share mounts on startup, you just need to add a line in /etc/fstab as follows:
sudo gedit /etc/fstab

Add the following line at the bottom, save and exit.

HostDirName /home/UserName/GuestDirName vboxsf defaults 0 0

That's it! Your new share will be available every time you start your guest machine.

4) Backing up machines is as easy as copying the .VDI file.

VirtualBox has a snapshot utility that allows you to save various states of your guest machine. You can think of this as a full restore point which you can revert back to in the event of some mishap. It is also possible to make a simple copy of your virtual machine by copying the .VDI file in the VBox/HardDisks directory. If you don't have any snapshots, you can copy the .VDI file directly. If you have existing snapshots, they need to be merged (using the discard snapshot command) first. It is worth noting that every .VDI file has a unique UUID identifier associated with it, so while you can use this file to restore an existing .VDI, it can't be used to clone a machine on the same host. This brings us to...


5) Cloning a VM to another physical machine is an easy way to copy your computing environment from a desktop to a laptop.

A copied .VDI can be used to clone a machine onto a different host! Simply create a new virtual machine and during the setup dialogs, choose "Use existing hard disk" and select the copied .VDI from the media manager screen.



To make a same-host clone, you need to use VirtualBox's command line utility VBoxManage as follows:

In this example, VirtualBox is running on a Windows 7 host. Open a command prompt on the host and navigate to the directory where VirtualBox is installed. In my case this is c:/Program Files (x86)/VirtualBox. Determine which .VDI file you wish to clone.
cd /Program Files (x86)/VirtualBox
VBoxmanage clonevdi "SourceName.vdi" "DestinationName.vdi"

You can now mount this new .VDI file in the VirtualBox media manager and create a new virtual machine from it. It will be an exact clone of the source machine in the state it was in when it was copied. You will need to set up any shared folders on VirtualBox (since it is a 'new' virtual machine), but the mount itself is preserved on the copied guest.

1 comment

Comment from: Tim [Visitor]
Thanks for the tips / just loaded Virtualbox and wanted to install W7 guest and keep a clean copy to clone as and when rather than reinstall each time - thanks again.
02/17/11 @ 07:12

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
What color is green?
antispam test