Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dual-boot laptop with Windows 7 and Ubuntu 12.04. I am trying to boot the ubuntu partition from windows using Virtualbox. I have successfully created the .vmdk, and created the virtual machine. However, I can't get it to boot (in Virtualbox). All I get is a black screen with the cursor in the top left.

I wonder if I'm specifying the partitions correctly. My Ubuntu install has 3 partitions: \, \boot, \home. No swap partition. These are all in Disk 0, partitions 3,4,5 respectively.

The command I used to create the .vmdk is:

 VBoxManage internalcommands createrawvmdk -filename C:\Users\abalter\.virtualbox\ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 3,4,5

Then I create a virtual machine based on that .vmdk.

Why won't it boot?

share|improve this question

migrated from stackoverflow.com May 30 '12 at 1:56

This question came from our site for professional and enthusiast programmers.

It's a known bug: https://www.virtualbox.org/ticket/9926 This http://www.neowin.net/forum/topic/784138-howto-boot-existing-ubuntu-partition-using-virtualbox-inside-windows/ suggests creating a custom iso that bootstraps grub2 as a workaround.

share|improve this answer
1  
I'm not sure what you mean by custom ISO. Could you explain? I've gotten it to work with a USB drive with no custom ISO. – abalter Jul 7 '12 at 4:21
    
The purpose of the custom install ISO is to include programs that put the grub2 partition inside the linux partition. Instead, putting Linux on its own disk (for your case a USB stick), also works since the problem is with windows and linux on the same disk. – cagney Mar 11 '13 at 17:42

I just did this yesterday, finally got it working using this tutorial: http://askubuntu.com/questions/78902/cannot-run-native-ubuntu-in-virtualbox-with-a-vmdk-created-using-the-createrawvm

I used ceztko's post (copied below). Note also that after I had it all working, I booted into Ubuntu in the VM and re-ran update-grub, which got rid of the extra entry in grub for Windows 7 (this is for safety's sake; if you accidentally try to boot the Win 7 partition from within a VM running on that same Windows 7 install, bad bad bad things will happen). After doing this, I essentially have 2 separate installs of grub: one on the system MBR that includes entries for Win 7 and Ubuntu, and one on the MBR of the VirtualBox .vmdk file (even though this file points to the raw Ubuntu partition, it's possible for it to have a different MBR).

ceztko's post:

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.

Edit: I should mention that Hemlock was pretty close - the problem is indeed that the .vmdk file pointing to the raw partition doesn't include a valid bootloader/boot sector. The first step in cetzko's post has you install grub to the MBR of the partition, and then make a copy of that MBR to add in to the .vmdk file. Normally grub is installed to the MBR of the entire hard drive.

share|improve this answer

The problem is the boot sector. You probably aren't including it in the available partitions of your raw disk.

I accomplished something similar this way:

  1. Create a virtual drive as you normally would.
  2. Create the raw disk you have described
  3. Install to the virtual drive
  4. Mount / on the virtual drive and /home on your raw disk
  5. Make sure that the virtual drive is set as the boot disk. This is where I had problems.
  6. Enjoy
share|improve this answer
    
Thanks Hemlock, but that's not quite the solution I'm looking for. That would allow me to share the /home directory, but not all installed apps etc. More importantly, I want to be in the same environment regardless of whether I booting into the linux partition or accessing it through VB from Windows. – abalter Jun 19 '12 at 21:56
    
You'll never be in the same environment; the virtualization doesn't have the same hardware. – Hemlock Jun 20 '12 at 12:00
    
This cannot be true. The method I used is from the Virtualbox documentation. Others seem to have gotten it to work. Also, I've successfully done what I want with a USB drive: i.e. installed ubuntu, and can boot natively from the USB drive or through virtualbox in Windows 7. – abalter Jul 7 '12 at 4:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .