VirtualBox : Use Raw Disk to load Windows under Linux

Here I explain how to use a Physical disk partition for a guest OS under VirtualBox. This is also called Raw Disk partition use for VirtualBox. My use case was to run WindowsXP as guest OS from a physical installation under Linux and still be able to boot up the system in same Windows installation when needed. My system is running Ubuntu 11.04 on core2 duo, 3GB memory, two hard disks (one with Ubuntu and other with WindowsXP installation), with VirtualBox 4.0.4. Process is simple but took quite a while to get all information/steps collected and tested. In nutshell, first we need to know the partition that we will use, then the user who is going to use it needs to have access to it. After that an mbr has to be created and finally a vmdk file is created to use the Raw Disk. Keep reading for the full process.

  1. Lets assume our raw disk is /dev/sdb.
    unixite@sandbox:~/ > sudo fdisk -l /dev/sdb
    Disk /dev/sdb: 160.0 GB, 160000000000 bytes
    255 heads, 63 sectors/track, 19452 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xd0f5c1be
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1   *           1       19452   156248158+   7  HPFS/NTFS
  2. First add the user that is going to run VirtualBox to the disk group (or the group to which this disk belongs, use lsto find the right group for your system. Without this step, you will not be able to create a vmdk file. It will complain of accessibility error with the raw disk. After that logout and log back in or start a fresh new shell that shows that the user now belongs to disk group. (Update : 2011-11-11 Thanks kszys for suggesting the correction to usermod command)
    unixite@sandbox:~/ > ls -l /dev/sdb
    brw-rw---- 1 root disk 8, 16 2011-05-11 10:32 /dev/sdb
    unixite@sandbox:~/ > sudo usermod -a -G disk unixite
  3. Create an mbr (master boot record) to use with Windows. This is a must step otherwise you could get “grub> Unknown format” (or similar) error. mbr package has utilities to create an mbr file (install it using sudo apt-get install mbr). Be careful. Here we want to only create an mbr file and not modify any disk settings.
    unixite@sandbox:~/ > install-mbr --force WinXP.mbr
    unixite@sandbox:~/ > ls -l WinXP.mbr
    -rw-r--r-- 1 unixite unixite 512 2011-04-29 11:29 WinXP.mbr
  4. Create a Virtual Disk out of the real raw partition. This will not create a huge disk or a copy. It will only create the settings to make use of the raw partition. So here we tell VBoxManage that /dev/sdb is the real raw disk, from which we want to use partition 1 for this purpose and mbr to be used is in the given file.
    unixite@sandbox:~/ > VBoxManage internalcommands createrawvmdk -filename /home/unixite/.VirtualBox/WinXP.vmdk -rawdisk /dev/sdb -partitions 1 -relative -mbr WinXP.mbr
    RAW host disk access VMDK file /home/unixite/.VirtualBox/WinXP.vmdk created successfully.
  5. Once the disk is created, you create a virtual machine or add this disk as primary disk to already existing virtual machine which is a very much established process.
  6. Boot up the system and it could crash or give blue screen on death first time. If it does, then boot in safe mode first, followed by the normal mode and it will work out ok.

Note: For me the SATA emulation for the RAW disk (under VirtualBox) did not work. I had to use the IDE emulation for the real SATA disk to get this working. There is some patch available to break windows binding to a given SATA driver and go more generic, but I did not try that yet.


  1. You might want to change:

    sudo usermod --groups disk unixite

    to something like that:

    sudo usermod -a -G disk unixite

    It cost me an hour to add myself to all the other groups that I lost with the command you suggested…

    1. You are right. I should have been more careful in that. The original command moves the user to the said group removing it from all other groups. So the command that you suggested is indeed the right one. Sorry for the extra trouble that it cost you.

      1. I followed your instructions, but when I try to create a new Virtual Machine and use the new vmdk I get this error:

        Failed to open the hard disk /home/techplex/.VirtualBox/Win7.vmdk.

        The medium ‘/home/techplex/.VirtualBox/Win7.vmdk’ can’t be used as the requested device type.

        Result Code: NS_ERROR_FAILURE (0x80004005)
        Component: Medium
        Interface: IMedium {53f9cc0c-e0fd-40a5-a404-a7a5272082cd}
        Callee: IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}

        The problem was that I created the vmdk as root, so I had to change owner.

        Hopefully that helps spmeone.

  2. On my Debian Wheezy (testing) the install-mbr command will not run without root. So my xx.mbr ends up with root permissions. I am assuming that that will create problems so I am changing the permissions to the Virtualbox user.

    Side note question: I am not using an existing install but want to make a new install in the raw access partition. The partition I want to use is an extended partition. Will the installer be able to partition said partition as if it were a whole drive with separate partitions for / /home and swap?

  3. A few comments:

    1. I wasn’t able to create it in /home/USERNAME/.VirtualBox/WinXP.vmdk

    (error message: VERR_FILE_NOT_FOUND at /home/vbox/vbox-4.3.16/src/VBox/Storage/VMDK.cpp(3427) in function int vmdkCreateRawImage(PVMDKIMAGE, PVBOXHDDRAW, uint64_t)

    Instead, I created it in /home/USERNAME/WinXP.vmdk

    2. After creating the file I tried to load it in VBOX, I got:


    Instead I had to open virtualbox with sudo. This solved it.

    3. I had Windows installation on my DiskOnKey and I wanted to be able to install it on the virtual machine. In order to do so I had to go to Settings -> Storage -> Add a new controller. I added a SCSI hard disk of 20 GB. Otherwise you have nowhere to install windows…

    Did you have similar experience?

Comments are closed.