Super Nerdy Cool

My (technical) adventures through the professional world…
December 2, 2010

Virtualization with VirtualBox (running Windows inside Linux)

I recently re-installed Windows on an old laptop to use Adobe Acrobats and the likes. Some Windows programs just aren’t accessible on Linux via Wine (although MS Office works). I’ve decided to set up Windows as a virtual machine on my Linux laptop; let’s see if virtualization will take the separate Windows machine out of the picture. I went with VirtualBox since it is open source, free, and was mentioned on Linux Journal. My initial reaction is VERY favorable. It seems everything works flawlessly (internet, cd drive, accessing files from the host machine; usb supported only through PUEL proprietary version.). I’ll jot down what I would like to be able to do with VirtualBox but have not been able to yet later in the post.

For the remainder of this post, host machine refers to my Linux laptop, and guest machine refers to the virtual machine with Windows XP.

Installation

## open-source version
sudo apt-get install virtualbox-ose ## install on debian/ubuntu
## PUEL version -- needed for usb support
echo "deb http://download.virtualbox.org/virtualbox/debian maverick non-free" >> /etc/apt/sources.list
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-3.2 ## usb support

Start VirtualBox and create a new machine. I kept most of the default configs, such as dynamic hard drive space. Then pop in my Windows XP cd and install.

This post shows how to do certain things with VirtualBox on Ubuntu.

Access files from Host machine

Start the machine, click on the “Devices” menu -> “Install Guest Additions”. Download the iso and install it on the Guest machine (should be automatically mounted; if not, click on on it under “Devices”).

On the host:

mkdir ~/VirtualBoxShare
## shutdown virtual machine
VBoxManage sharedfolder add "WinXP" -name "vqnportege-share" -hostpath /home/vinh/ ## "WinXP" is the name of my virtual machine, I'm making my home directory accessible on the guest machine, calling this path "vqnportege-share"
## start virtual machine
## on guest, Run -> cmd -> net use x: \vboxsvrvqnportege-share
## x drive should be accessible on the guest machine now...now I can access files from my Linux home directory.

After installing Guest Additions, copy/paste for text between host and guest should work.

USB Support on PUEL version

Got the following here (for Ubuntu 10.10 Maverick):

sudo usermod -G vboxusers -a vinh

Restart host machine. Enable USB controller in for the windows machine (click settings in VirtualBox). After plugging usb device onto the host, click on the usb icon on the bottom of the virtual machine and select the device that you want to use in the guest machine. See this post for more details.

It’s that easy to set up a Windows virtual machine that is highly integrated with the host Linux machine.

Backup and Restore

According to this thread, you need to backup 3 files (“WinXP” is the name of the machine):

  1. ~/.VirtualBox/HardDisks/WinXP.dvi,
  2. ~/.VirtualBox/VirtualBox.xml, and
  3. ~/.VirtualBox/Machines/WinXP/WinXP.xml.

You can also “Take Snapshot” of the machine at a point in time. The file will be in ~/.VirtualBox/Machines/WinXP/Snapshots/{0001....}.vdi (this file analogous to the WinXP.dvi file).

To restore the virtual machine on a different system, place the files in the same path.

If you want to backup the machine and have it used in the same host machine (so two virtual machines that are identical), you will need to clone it to get a new id according to this post:

VBoxManage clonehd ~/.VirtualBox/HardDisks/WinXP.vdi ~/WinXP_Backup.vdi

Wish List

With VirtualBox, the user interface is a machine within a machine. I think with either VMWare and/or Parallels on Mac OS X (I saw on another person’s), each app window can be like a regular app’s window, ie, freely moving on the host’s desktop (not in a box). Also, you can access files between the two very seamlessly. The best part is file integration. If a file is set to open default by an app on the guest machine, then doubling clicking the file on the host will launch the virtual machine, open the app, and the file is opened. It is as if the the Windows apps were installed on the host machine. I don’t know if this is possible with VirtualBox or not yet. I’ll look more into this.

2 Comments to “Virtualization with VirtualBox (running Windows inside Linux)”

Leave a Comment