Virtualbox: Raw linux partition not booting

4

4

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?

abalter

Posted 2012-05-28T04:36:18.567

Reputation: 544

Answers

2

cagney

Posted 2012-05-28T04:36:18.567

Reputation: 21

1I'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 – 2012-07-07T04:21:51.420

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 – 2013-03-11T17:42:49.787

1

I just did this yesterday, finally got it working using this tutorial: https://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.

Isaac Dontje Lindell

Posted 2012-05-28T04:36:18.567

Reputation: 399

0

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

Hemlock

Posted 2012-05-28T04:36:18.567

Reputation: 101

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 – 2012-06-19T21:56:13.160

You'll never be in the same environment; the virtualization doesn't have the same hardware. – Hemlock – 2012-06-20T12:00:19.300

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 – 2012-07-07T04:22:37.113