Page 1 of 1

Linux guest, raw disks: Partition wierdness [SOLVED]

Posted: 20. Jul 2010, 17:31
by damiannz
hey folks,

I'm trying to boot my existing Ubuntu installation on /dev/disk0s3 (80GB on a 230GB drive) as a raw disk device with VirtualBox 3.2.6. But, neither GRUB nor Linux/Ubuntu can see any of my partitions.

I created the vmdk like this:

Code: Select all

VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -partitions 3 -filename disk0s3_01.vmdk -register -mbr grub.mbr 
(grub.mbr was pulled from an existing Ubuntu installation), but on startup I get:

Code: Select all

GRUB loading. 
error: no such partition
in addition, GRUB cannot see any partitions:

Code: Select all

grub rescue> ls
(hd0)
grub rescue>
and this is confirmed when I go ahead and try to re-install Ubuntu on the raw device: gparted just offers up my entire 230GB disk as 'unallocated', which is not what I expected.

If, on the other hand, I create the vmdk file like this:

Code: Select all

VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0s3 -filename disk0s3_02.vmdk -register
then I get what I expect (an 80GB hdd with Ubuntu already on it but with a confused GRUB (

Code: Select all

GRUB Geom Error
FATAL: INT18: BOOT FAILURE
).

i have no idea how to fix grub to allow Linux to boot in either case, and if i boot up a live CD and try to reinstall grub on the virtual disk's MBR i get a segfault in grub-setup.

Any help appreciated.

Re: Linux guest, raw disks: Partition wierdness

Posted: 21. Jul 2010, 10:41
by ChipMcK

Re: Linux guest, raw disks: Partition wierdness

Posted: 23. Jul 2010, 15:07
by damiannz
Hi ChipMcK,

Thanks for the link - unfortunately I can't get grub-install (nor, indeed, Linux) to see my partitions or recognize my disk.

Further investigation shows some weirdness. It appears that the MBR partition is fine:

Code: Select all

ubuntu@ubuntu:~$ sudo fdisk -l /dev/sda

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          26      204819+  ee  GPT
Partition 1 does not end on cylinder boundary.
/dev/sda2              26       14614   117181404   af  HFS / HFS+
/dev/sda3           14615       26003    91482142+  83  Linux
/dev/sda4   *       26004       29827    30716280    c  W95 FAT32 (LBA)
ubuntu@ubuntu:~$ 
but this is for some reason not being passed through to the /dev filesystem:

Code: Select all

ubuntu@ubuntu:~$ ls /dev/sd*
/dev/sda
ubuntu@ubuntu:~$ 
and if I try to look using parted:

Code: Select all

ubuntu@ubuntu:~$ ls /dev/sd*
/dev/sda
ubuntu@ubuntu:~$ 
My guess is that the GPT partition map isn't passed through in the .vmdk somehow, but I don't know what that means nor what to do about it.

Again, any help appreciated.

Re: Linux guest, raw disks: Partition wierdness

Posted: 26. Jul 2010, 12:27
by damiannz
Well, it turns out you need to manually copy the GPT data to a separate file and edit the VMDK to point the first 40 LBA sectors of your drive at this file.

Following these instructions here: http://blog.jardinmagique.info/2009/08/ ... -boot.html, and with a GRUB boot floppy image in the CDROM slot, I'm booting up as far as initramfs where it times out waiting for /dev/sda3 to mount. Which is progress, but I'm still stuck, but at least now I know vaguely why :-)

Re: Linux guest, raw disks: Partition wierdness [SOLVED]

Posted: 29. Jul 2010, 17:45
by damiannz
The final problem was to do with SATA vs IDE booting. For some reason I had the hard drive adapter set to IDE; using SATA it worked fine.