May 5

Ok, you will think that this is another tutorial about how to install Ubunto as Guest OS using VirtualBox in Windows 7. However, what I propose is to run a real installation of Ubuntu in your computer at the same time of Windows 7 using VirtualBox. In such a way you can run your Ubuntu either virtualized in Windows or boot it as the real operating system.
The steps are the following:

  1. Install Windows 7
  2. Install Ubuntu. Normally this is straightforward, you have to repartition your hard disk, etc. VERY IMPORTANT: Do not mount in ubuntu the partition where you have installed Windows 7, nor any partition that would be visible in Windows.
  3. Boot in Windows 7 and install VirtualBox (next steps are based on
  4. Click Start > Run Type diskmgmt.msc and click OK (In Vista/Win7 use the Start > Search Box) (1) Locate your BOOT Disk #
  5. Open a command prompt cmd.exe (run as admin in Vista/Win7).
  6. Type cd %programfiles%\oracle\virtualbox
  7. Type the following (replace # with your BOOT Disk number from step 4)
    VBoxManage internalcommands createrawvmdk -filename “%USERPROFILE%”\.VirtualBox\usb.vmdk -rawdisk \\.\PhysicalDrive#
  8. Start VirtualBox (run as admin in Vista/Win7) and create a New Virtual Machine
  9. When prompted for a Virtual Hard Disk, click use existing hard disk and select usb.vmdk
  10. Once you have finished creating your New Virtual Machine, click Start.
  11. If all goes well, VirtualBox should now be running the Linux version installed on your PC emulated from within Windows.
  12. You can Install VirtualBox guest additions, however, depending on your graphic card, it is possible that in this case you have to use two versions of /etc/X11/xorg.conf files, one for running your ubuntu emulated in virtualbox, and other to use when the PC is started in ubuntu (not emulated).
  13. I have rewritten a script (based on the one available in, but to solve other problem) to switch from one xorg.conf to another depending on if you are running directly or from VirtualBox. Suppose you have the two xorg.conf files in /etc/X11: xorg.conf-real and xorg.conf-vbox. Then you have to create a small script in /etc/init.d (called xorg_conf) with the following content:

    VIDEO=`/usr/bin/lspci |grep -c VGA.*VirtualBox`
    if [ “$VIDEO” = 1 ]; then
    cp -f /etc/X11/xorg.conf-vbox /etc/X11/xorg.conf
    cp -f /etc/X11/xorg.conf-real /etc/X11/xorg.conf
  14. Soft linking the script into rc2.d as S12xorg_conf will copy the correct xorg.conf file into place before X starts.
  15. If you like to test the new unity desktop interface in VirtualBox, install unity-2d: This is a work around until full support for unity 3d in virtualbox for windows be available: I tried to enabled 3d acceleration but is not working in linux guest over windows hosts yet.
  16. Now the opposite, to run your current Windows Installation under Ubuntu.  To do this, you will need your Windows 7 Installation CD.
  17. Execute the following command:
    sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/sda -filename win7.vmdk
  18. To allow your virtual machine boot in Windows 7 instead of your Ubuntu Installation, you have to create a virtual hard disk and install a small linux distribution first, that you will configure to boot your windows installation. I decided to install slitaz which is a very small and easy to use linux distribution, but don’t worry, If you want to save your time, you can download the virtual disk from here: vmslitaz.vdi.gz (the root password is root, the default user is upx and its password is upx). Decompress it using gzip or your favorite compression/decompression utility.
  19. As root, create a new Windows 7 virtual machine, and when prompted for a Virtual Hard Disk, click use existing hard disk and select vmslitaz.vdi.
  20. Once your machine has been created, add win7.vmdk as a second Virtual Hard Disk.
  21. Run the recently created virtual machine.  If Windows complains showing a screen about an error due to hardware changes, boot from the installation CD and repair Windows.
  22. More detailed information about Windows installation can be found at


Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.