VirtualBox Windows Host, Shared Folders and Linux Guest

VirtualBox comes with a feature to give you access to the hosts’s filesystem through a CIFS server.  This is available after you’ve installed the Guest Additions drivers in the Guest.  More details are available here (specific to Ubuntu but can apply to all versions of Linux):

There are more details at that page on how to set up the share.

Frustratingly, the CIFS (Shared Folder) server name you access a hosts file system on a Linux Guest is different to one that you use under Windows so as a quick overview

Windows Guest

net use x: vboxsvrshare

Linux Guest

mount -t vboxsf share mountpoint

Note the change from vboxsvr under Windows to vboxsf under Linux.


Ubuntu Karmic Koala 64, VirtualBox + Windows 7 64

I have an Intel Core i7, 8Gb DDR3 laptop which essentialy means I’ve 8 cores at my disposal. To take advantage of this and the ample memory available, like many servers these days, virtualisation is the way to go.

I do have a preference for running Linux on the desktop, which stems from familiarity and flexibility rather than a hate of Microsoft, but there are tools and reasons why Windows is the only way forward. As a middle ground, running Windows as a VM guest strikes a good balance.

VirtualBox is Oracle’s desktop virtualisation offering and is more akin to VMware Server 1.x but with modern hardware virtualisation support. Why. VBox over VMware Server 2.x? It’s far simpler to set up and run, and far simpler to install under Ubuntu. Ubuntu’s repos are populated with VirtualBox OSE, which stands for Open Source Edition.

To install do the following:

apt-get install virtualbox-ose

At the time of writing the OSE version in Karmic Stable is 3.0.8, whereas the latest version is 3.1.4.  I mention this because I ran into the following problems with running Windows 7 64-Bit and VirtualBox-OSE 3.0.8 64-Bit:

  • Intermittent slowness in the guest
  • Locking up of the Guest + VirtualBox

To alleviate these problems I did the following

  • Installed the RealTime (RT) kernel in Ubuntu Karmic
    apt-get install install linux-image-rt linux-headers-rt
  • Reduced the number of vCPUs from 4, to 2, to 1

This did seem to fix the issue of locking up, and gave me a Windows 7 desktop, but I had 8 cores to play with – going to 1vCPU just caused me problems running applications within the guest that needed a little more processing power that I had available.

I’ve now resorted to installing the version found at This is 3.1.4 r57640 at the time of this posting.

As I already had Windows 7 up and running under OSE 3.0.8 I did the following

apt-get remove virtual-box-ose

(Which removes certain libqt4 dependencies – but I’ll show the complete steps to install Virtual Box 3.1.4 from below:

apt-get install libqt4-network libqt4-opengl libqtcore4 libqtgui4
dpkg -i /tmp/virtualbox-3.1_3.1.4-57640_Ubuntu_karmic_amd64.deb

This will ask you to compile new updated kernel modules, so answer yes to the question of doing so.
It also says you must add your user to the vboxusers group so do this:

sudo usermod -G vboxusers -a username

Log back out and back in again to activate your user in the vboxusers group.

Fire up Windows 7 and things appear more stable.  Currently running 2vCPU with 4Gb Ram.  If you had Windows 7 previously running under an older version of VirtualBox then don’t forget to update Guest Additions to that of the running VirtualBox version.

Run Windows XP from raw partition under Linux

I have managed to successfully boot my Windows XP raw partition from within Linux (Ubuntu, Karmic Koala Alpha 4) using Sun’s Virtual Box so I thought I’d share my successes and gotchas with you.

Warnings and expectations!
I accept no responsibility for the loss or damage to your data or computer by following these instructions!

First up – these instructions worked for me and were collated from lots of googling and sanitising other instructions found on the internet. I’m hoping these are a little more straightforward to follow than some I’ve seen.
Secondly, although I got this going, it wasn’t necessarily the ideal set up I was hoping for. The computer I was using for this was an Compaq NC6400 with 4Gb Ram and a very slow hard drive. There are no hardware virtualisation features on my model so although it was cool to get it working, the speed of disk access was nearly enough to see me go mad.

Disk Layout
My hard drive disk layout was your pretty average Windows XP partition followed by some Linux partitions:

Disk /dev/sda: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7e987e98

Device Boot Start End Blocks Id System
/dev/sda1 * 1 5338 42877453+ 7 HPFS/NTFS
/dev/sda2 5339 5363 200812+ 83 Linux
/dev/sda3 5364 5736 2996122+ 82 Linux swap / Solaris
/dev/sda4 5737 7297 12538732+ 83 Linux

Pre-Requisite – Windows XP Preparation
There are a couple of things that need to be done under Windows XP prior to starting this. This includes running the MergeIDE utility which preps a system to be moved to another piece of hardware (in our case, a virtual machine) as Windows XP isn’t so friendly when it comes across different hardware. Also you need to create hardware profiles – you will be booting your original Windows XP that has been running under your specific hardware, and not Virtual Box’s virtual hardware.

  1. Download, extract and run the MergeIDE utility from this site
  2. Create a hardware profile under Windows XPRight Click on My Computer and go to Properties, then click on the Hardware tab. From there you can create new hardware profiles which you can select on boot.

Virtual Box and Windows XP raw partition
Sun’s VBox can be downloaded from Sun’s Virtual Box Website or by using your Linux distribution’s software installer. As I was running Ubuntu the instructions will be specific to that.

  1. Ensure your user is a member of the ‘disk’ group as your normal unprivileged user needs access to the partitions that Linux can seesudo usermod -a -G disk username

    You will need to log out and log back in again for the whole X desktop (e.g. Gnome) session to see the changes.

  2. sudo aptitude install virtualbox-ose mbrmbr package provides a means of creating a new boot record that will be used to boot your partition

    the virtualbox-ose package is the Open Source Edition as packaged up by Ubuntu

  3. mkdir -p ~/.VirtualBox&&cd ~/.VirtualBox
  4. install mbr –force MBR.mbrthis creates a new master boot record for you to use to boot your partition
  5. Refer to the disk partitioning layout and recall in the example above that /dev/sda, partition 1 (/dev/sda1) has my Windows XP install. Also note that /dev/sda has my original MBR so we will need to directly reference partition 1 to get access to Windows XP directly.Check your disk layout by doing the following

    fdisk -l /dev/sda

    Note normally you’d expect to prepend that with sudo (or be root) to view this, but this is a good check that your permissions are working as expected. If not – check you have set up your user permissions correctly and have logged out and back in again.
    Still not working after that? Do an ls -l /dev/sda and check the group that has write permissions on the partition. Add your username to that.

  6. IMPORTANT – UNMOUNT THE WINDOWS PARTITION FROM LINUXYou don’t want to have multiple OSes accessing the same device simultaneously. You have been warned!
  7. Create the disk file that VBox will use to access the partition:VBoxManage internalcommands createrawvmdk -filename ./WindowsXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./MBR.mbr -relative -register

    This says create a file called WindowsXP.vmdk in the current dir, the disk is /dev/sda and the partition number is 1. We’re using the MBR file created in step number 4. The register option adds this into the Virtual Media Manager in VBox.user@localhost:~/.VirtualBox$ VBoxManage internalcommands createrawvmdk -filename ./WindowsXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./MBR.mbr -relative -register
    VirtualBox Command Line Management Interface Version 3.0.4_OSE
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    RAW host disk access VMDK file ./WindowsXP.vmdk created successfully.

  8. If you get permission denied, double check those user permissions. If you are getting access denied at this stage, there isn’t a chance that VBox will! So review from step 1 again…
  9. Fire up VirtualBox OSE and create a new Windows XP Virtual Machine, choosing the new hard disk you created in step 7
  10. Important: Now go back into the new Virtual Machine’s settings to enable IO-Apic

  11. Now boot it up!

I encountered a rather frustrating issue that prevented me booting up my Windows XP partition:

A disk read error occurred
Press Ctrl+Alt+Del to restart

To circumvent this, after lots of searching and reading I realised that the people that have successfully booted had something in common in their vmdk file. Edit the vmdk file you created in Step 7 and change

ddb.geometry.biosHeads=”255″ to ddb.geometry.biosHeads=”240

Save and watch proudly as Windows XP boots from a raw partition under Linux

Booting your native Windows XP – Keyboard and Mouse not working after installing Guest Additions: Uninstall Guest Additions.
Unfortunately I’ve not come across a nice solution to this. After booting into Windows XP from within Linux, after getting frustrated if the speed isn’t what you expect, there may be a reason to boot back into Windows XP natively. The problem you may come across though is that after installing Virtual Box Guest Additions, it replaced your mouse and keyboard drivers. This is great for running Windows XP under Linux, but not so great when that hardware disappears!
So – uninstalling Virtual Box is all I’ve come across so far. This seems correct as of version 3.0.4. Reports of it working with older (2.2.2) have been unconfirmed by me.

After some googling the following helped me set up my raw Windows XP from within Linux