May 20, 2011

Ubuntu Host, Windows 7 Guest, Raw disk, Virtual Box

Command in Ubuntu to create the win7 virtual machine using the raw disk Windows 7 partition that comes with the Dell computer.

This is tested on Virtual Box 4.0.4
Make sure you run everything as root
Make sure you use "IDE controller" type ICH6, otherwise the win7 will blue screen (BSOD)

This is based on the following blogs:

First install Virtualbox. I found it easier to install it using the "all platform" exectuable. Make sure you also download and install the Oracle Extension Package, which is installed using this command:
 VBoxManage extpack install Extention_file_name

Then do the following commands: make sure you are root, and you are at "/root".

VBoxManage createvm --name win7 --ostype Windows7_64 --register
VBoxManage modifyvm "win7" --memory 1024 --acpi on --boot1 disk --nic1 nat

VBoxManage storagectl "win7" --name "IDE Controller"   --add ide --controller ICH6

VBoxManage internalcommands createrawvmdk -filename /root/win7.vmdk -rawdisk /dev/sda -partitions 1,2,3 -mbr /root/vm.mbr -relative

VBoxManage storageattach win7 --storagectl "IDE Controller"  --port 0 --device 0 --type hdd --medium /root/win7.vmdk

------ Other useful commands------------

vboxmanage unregistervm win7 --delete

VBoxManage storageattach win7 --storagectl "IDE Controller"  --port 0 --device 1 --type dvddrive --medium "/root/Windows 7 64-bit Repair Disc.iso"

VBoxManage storageattach win7 --storagectl "IDE Controller"  --port 0 --device 1 --type dvddrive --medium /opt/VirtualBox/additions/VBoxGuestAdditions.iso

vboxmanage controlvm win7 reset

----If you still cannot boot your Windows 7, try to use the Windows 7 Rescue image to fix it. Use the above "vboxmanage" command to attach the repair disk ISO file and hit F12 when vbox boots to boot from CD, let it fixes it and then boot to regular Win7


  1. Thanks! Even though it doesn't say it specifically, the problem I was having was that I was trying to use a SATA controller in VirtualBox, and I needed to load the rawdisk image using the IDE controller. After doing that I got everything working. Thanks for getting me past the last step! :)

  2. Glad that this post was helpful to you. It took me some time to figure this out from a post on a MAC forum.

  3. hi

    i dont understand this

    VBoxManage internalcommands createrawvmdk -filename /root/win7.vmdk -rawdisk /dev/sda -partitions 1,2,3 -mbr /root/vm.mbr -relative

    i formatted my hd and now win7 is on sda2


    /dev/sda1 1 25536 205117888+ 7 HPFS/NTFS
    /dev/sda2 25537 37032 92341620 7 HPFS/NTFS
    /dev/sda3 37033 48916 95458230 af HFS / HFS+
    /dev/sda4 48917 60801 95466232 5 Esteso
    /dev/sda5 48917 50221 10482381 83 Linux
    /dev/sda6 * 50222 50237 128488+ 83 Linux
    /dev/sda7 50238 50759 4192933+ 82 Linux swap / Solaris
    /dev/sda8 50760 55188 35575911 83 Linux
    /dev/sda9 55189 55710 4192933+ 82 Linux swap / Solaris
    /dev/sda10 55711 57015 10482381 83 Linux
    /dev/sda11 57016 58973 15727603+ 83 Linux
    /dev/sda12 58974 60278 10482381 83 Linux
    /dev/sda13 60279 60801 4200966 83 Linux

    what should i do?

    obviously GREATEST POST EVER!

  4. You should probably do

    VBoxManage internalcommands createrawvmdk -filename /root/win7.vmdk -rawdisk /dev/sda -partitions 2 -mbr /root/vm.mbr -relative

    Without the 1,3 in the partitions section of the command( you can also have -partitions 1,2 if you want).