Wed 07 Apr 2010 09:38:10 PM UTC, original submission:
I've been investigating why, on Acer Travelmate C100 tablet PCs, grub2 fails to boot, reporting:
"Geom Error"
It turns out the MBR boot sector does not have the two NOP instructions written into offset 0x66 which allows drive 0x80 to be forced as the boot device when the BIOS reports a different device - in this case 0x5F.
I traced the code in util/i386/pc/grub-setup.c and discovered that the test for the drive number fails and therefore the jmp instruction isn't over-written.
The reason is dest_dev->disk->id is never set prior to the test.
So far as I can determine this is the code-path:
utils/i386/pc/grub-setup.c::setup()
dest_dev = grub_device_open (dest);
kern/device.c::grub_device_open(const char *dest name)
disk = grub_disk_open(name);
kern/disk.c::grub_disk_open(const char *name)
disk = (grub_disk_t) grub_zalloc(sizeof(*disk));
disk->name = grub_strdup (name);
...
disk->dev = dev;
...
return disk;
dev->disk = disk;
return dev;
...
/* If DEST_DRIVE is a hard disk, enable the workaround, which is
for buggy BIOSes which don't pass boot drive correctly. Instead,
they pass 0x00 or 0x01 even when booted from 0x80. */
if (dest_dev->disk->id & 0x80)
/* Replace the jmp (2 bytes) with double nop's. */
*boot_drive_check = 0x9090;
To test this I added a small patch to report the value of disk->id and built the binary. When run on the target system it reveals:
./grub-setup: info: the size of hd0 is 78140160
./grub-setup: info: setting the root device to 'hd0,1'.
./grub-setup: info: disk->id = 0.
and the resulting boot sector contained the jmp instruction.
I've got a manual workaround until a fix can be created.
1. Boot from a LiveCD image from CD or network (via PXE).
2. Open a terminal (there are two ways)
a. press Ctrl+Alt+F1 twice to get to virtual console #1
b. Applications > Accessories > Terminal
3. Create a file containing the nops:
echo -e -n "\0220\0220" >/tmp/nop.bin
4. Write the nops into the boot sector (replace /dev/sda if necessary with the boot device name on your system):
sudo dd if=/tmp/nop.bin of=/dev/sda bs=2 count=1 seek=102
5. Restart and test.
This issue was originally reported in Ubuntu Forums and has a bug report against it at:
https://bugs.launchpad.net/ubuntu/+bug/555500
|