[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #29464] util/i386/pc/grub-setup: fails to write Buggy BIOS boot-sec
[bug #29464] util/i386/pc/grub-setup: fails to write Buggy BIOS boot-sector drive-number detection in boot.img
Wed, 07 Apr 2010 21:38:11 +0000
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:220.127.116.11) Gecko/20100404 Ubuntu/10.04 (lucid) Firefox/3.6.3
Summary: util/i386/pc/grub-setup: fails to write Buggy BIOS
boot-sector drive-number detection in boot.img
Project: GNU GRUB
Submitted by: intuitivenipple
Submitted on: Wed 07 Apr 2010 09:38:10 PM GMT
Priority: 5 - Normal
Item Group: Software Error
Assigned to: None
Discussion Lock: Any
Reproducibility: Every Time
Planned Release: None
I've been investigating why, on Acer Travelmate C100 tablet PCs, grub2 fails
to boot, reporting:
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
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:
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;
dev->disk = disk;
/* 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:
Reply to this item at:
Message sent via/by Savannah
- [bug #29464] util/i386/pc/grub-setup: fails to write Buggy BIOS boot-sector drive-number detection in boot.img,