Linux guest, raw disks: Partition wierdness [SOLVED]

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
damiannz
Posts: 5
Joined: 20. Jul 2010, 15:59
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu, XP

Linux guest, raw disks: Partition wierdness [SOLVED]

Post 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.
Last edited by damiannz on 29. Jul 2010, 17:43, edited 1 time in total.
ChipMcK
Volunteer
Posts: 1095
Joined: 20. May 2009, 02:17
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, OSX
Location: U S of A

Re: Linux guest, raw disks: Partition wierdness

Post by ChipMcK »

damiannz
Posts: 5
Joined: 20. Jul 2010, 15:59
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu, XP

Re: Linux guest, raw disks: Partition wierdness

Post 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.
damiannz
Posts: 5
Joined: 20. Jul 2010, 15:59
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu, XP

Re: Linux guest, raw disks: Partition wierdness

Post 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 :-)
damiannz
Posts: 5
Joined: 20. Jul 2010, 15:59
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu, XP

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

Post 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.
Post Reply