Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a Win7 x64 & Ubuntu 11.10 x64 dual boot set-up on a single HDD.

I wanted to run the native Ubuntu as a guest OS inside Virtual-box running on Win7 host.

I used the following command to list the partitions:

C:\ >vboxmanage internalcommands listpartitions -rawdisk \\.\physicaldrive0
Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x07  0   /32 /33  153 /27 /2           1200         2048
2       0x07  153 /27 /3   1023/254/63        363337      2459648
5       0x82  1023/254/63  1023/254/63          9537    746575872
6       0x83  1023/254/63  1023/254/63         46430    766107783
7       0x83  1023/254/63  1023/254/63         46431    861200384
4       0x07  1023/254/63  1023/254/63         10000    956291072

Then I created the vmdk file as follows (specifying the ubuntu partitions 5,6 & 7):

C:> vboxmanage internalcommands createrawvmdk -filename "C:\ubuntu_01.vmdk" -rawdisk \.\physicaldrive0 -partitions 5,6,7

The vmdk file was created successfully, but when I created a VM and specified this virtual drive, the VM wont start, theres just a blank black screen with a white cursor at the top left corner. It doesnot even show up the Grub boot menu.

Then I created another vmdk file without specifying the partitions.

C:> vboxmanage internalcommands createrawvmdk -filename "C:\ubuntu_02.vmdk" -rawdisk \.\physicaldrive0

This time the VM starts and ubuntu boots successfully from inside the VM (the grub 2 boot menu is presented and on selecting Ubuntu, it boots successfully).

How can I use only the specific native ubuntu partitions instead of the entire disk for the guest ubuntu OS in virtualbox? Please help.

Host: Win 7 x64
Guest: Ubuntu 11.10 x64
Vbox version: 4.1.6 r74713 with latest guest additions installed.

share|improve this question
add comment

4 Answers

As soon as you boot Ubuntu from a "virtualized" real harddisk with the method you mentioned it will not find it's bootmanager Grub as in your dual boot setting Grub most likely resides in the MBR of the first (boot) partition on you physical hard drive. From there Grub decides on your choice to boot Windows or Ubuntu.

If you want to boot Ubuntu from a virtual machine then you need a bootmanager (Grub) the same way you need it on a real system.

To achieve this you either need to install Grub in your Ubuntu partition or you need to create a small boot partition for Grub that could easily be added to your Virtual Machine. Read here, and in the GNU Grub manual for further details.

Warning: Both methods could break your dual boot setup or could make your Windows or Ubuntu system unbootable if you made something wrong.

The safe way:

A much safer way to have access for your host and guest data would be installing Ubuntu on it's own 10-15 GB VDI and just mounting your host /home in the guest OS for data acess. By doing so you will also be able to load host or guest kernel modules without breaking the host Ubuntu installation.

share|improve this answer
Thank you Takkat. Could you please elaborate on the steps or best practices for setting up a dedicated grub partition in a dual boot environment? –  Zaki Nov 14 '11 at 9:09
@Zaki: I was afraid that you are going to ask for this. No, I can't - mainly because I am unable to test this without a huge risk to break my own setup (that includes graphic drivers and other kernel modules) here. Nevertheless I strongly recommend you go for the safe way (see edit of my answer). –  Takkat Nov 14 '11 at 10:55
Please correct me if Im wrong, but I always assumed that MBR is not specific to a particular partition but applies to the disk as a whole. So my understanding is, when I start the VM (attaching the vmdk file created with ubuntu -partitions specified), it cannot read the mbr present on the 'real' disk and thus cannot start the boot process. Is this correct ? –  Zaki Nov 15 '11 at 12:49
I can confirm that kernel module incompatibility is definitely not a problem as I have successfully run the native ubuntu from inside the VM in windows host (specified the whole disk instead of ubuntu paritition when creating the vmdk). However after tons of googling aroung, I believe grub2 chainloading would be an option. –  Zaki Nov 15 '11 at 13:17
@Zaki: Don't load Guest Additions if you proceed ;) –  Takkat Nov 15 '11 at 13:27
show 1 more comment

I found a perfectly working workaround. sda7 is the partition where I installed linux, 5,6,7 are the native partition I want to virtualize, and "ceztko" is my home :P

  • from the native linux, reinstall the grub to the native linux partition: sudo-grub install --force /dev/sda7
  • copy the partition boot sector to your home: # dd if=/dev/sda7 of=/home/ceztko/virtualbox-native.mbr bs=512 count=1
  • copy virtualbox-native.mbr to your windows installation
  • Reboot to Windows and from Administrator prompt:

    VBoxManage internalcommands createrawvmdk -filename C:\users\ceztko\ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 5,6,7 -mbr c:\users\ceztko\Dropbox\resources\virtualbox-native.mbr

  • Run VirtualBox and assign the new virtual drive to the virtual machine.
  • Enjoy!

This may be a bug in Virtualbox. But better I guess is a bug in grub, confused by the non-accessible Windows partitions when installed as mbr in the boot disk.

share|improve this answer
command should be: sudo grub-install --force /dev/sda7 –  Chris Good Feb 2 at 6:45
Thanks for the great solution! I had to do a couple of extra things to get it working. I had to run Virtualbox as Windows administrator in order to use the rawdisk. As my dual boot Ubuntu 12.04 LTS was 64 bit, I had to turn on Intel virtualization Technology in the host BIOS. Ref askubuntu.com/questions/308937/…. Then I could select Ubuntu(64 bit), in the guest setup, then the guest would boot. Without Virtualization on in the BIOS, guest would just show a black screen after selecting Ubuntu from the grub menu. –  Chris Good Feb 2 at 8:39
add comment

I had a similar issue and solved it a little bit different, i.e., without booting into the native Linux.

If you specified the -partitions parameter for the .vmdk rawdisk, an image of the MBR and some subsequent sectors will be also created, which you can overwrite directly within the virtual Linux without affecting the original physical sectors. Check the vmdk file for reference. In my case the flat image covered the first 32kb.

In order to boot into the virtual Linux for the first time, you could use e.g., the SuperGrubDisk ISO image. After a successful boot, fix the MBR from the local installation under the virtual environment as usual.

Note that if you want to install grub on your virtual MBR it may be the case that the MBR is not large enough to fit the whole grub image. You notice this only if you attempt to boot the system. In this case you can enlarge the flat image representing the first sectors of your harddisk. You need to adapt the .vmdk file accordingly.

share|improve this answer
add comment

The complete solution:

The normal place of an OS loader, Grub is one, is "on the PBR", inside the partition. And that's the safest place against its destruction, instead of exposing it on the MBR.

And that makes Linux boot the conventional way, by loading the PBR and executing it. GAG is a nice program to multi-boot and/or to boot logical partitions. It's best to get it on a CD like SystemRescueCd together with a host of tools. Burn the CD or use the ISO file and boot it, then select GAG then configure it, done.

If you don't suspend/resume 6 months long as Linux allows, Tux'll greet you everyday. Thanks for the tip that GAG will rewrite that virtual MBR.

And if you can contact GAG's author, tell him:

  1. My eternal thanks
  2. That he should start configuration with a fully populated Main Screen and let delete, reorder and modify the icons. That makes an already usable configuration right away instead of having to do a lot of manipulations to get started.
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.