After adding several debugging fprintf statements the reason for this problem seems to become clear. grub-setup calls grub_disk_open() which in turn calls an open() function via an array of pointers. Here's the source-code peppered with my debug print statements from kern/desk.c::grub_disk_open():
That function simply iterates through an array called 'map' that contains the contents of /boot/grub/device.map. The first entry in 'map' (map[0]) represents the first line in the device.map file.
From that it is now possible to see why the id is set to 0 and therefore why the buggy BIOS work-around never gets applied to the boot sector.
After adding several debugging fprintf statements the reason for this problem seems to become clear. grub-setup calls grub_disk_open() which in turn calls an open() function via an array of pointers. Here's the source-code peppered with my debug print statements from kern/desk. c::grub_ disk_open( ):
grub_ dprintf( "disk", "grub_disk_dev_list %s\n", raw); dprintf( "disk", "dev->open (%p)\n", (void *) dev->open);
grub_dprintf( "disk", "%s\n", "GRUB_ERR_NONE"); UNKNOWN_ DEVICE) {
grub_dprintf( "disk", "%s\n", "GRUB_ERR_ UNKNOWN_ DEVICE" );
for (dev = grub_disk_dev_list; dev; dev = dev->next)
{
grub_
if ((dev->open) (raw, disk) == GRUB_ERR_NONE) {
break;
}
else if (grub_errno == GRUB_ERR_
grub_errno = GRUB_ERR_NONE;
}
else
goto fail;
}
Running grub-setup with extra debug info output to stdout:
sudo ./grub-setup -vvv '(hd0)' >grub-setup.log 2>grub- setup.stderr. log
shows:
grub-setup: opening destination 'hd0' SourceCode/ grub/grub2- 1.98/kern/ disk.c: 245: Opening `hd0'... SourceCode/ grub/grub2- 1.98/kern/ disk.c: 268: grub_disk_dev_list hd0 SourceCode/ grub/grub2- 1.98/kern/ disk.c: 271: dev->open (0x80754f7) SourceCode/ grub/grub2- 1.98/kern/ disk.c: 278: GRUB_ERR_ UNKNOWN_ DEVICE SourceCode/ grub/grub2- 1.98/kern/ disk.c: 271: dev->open (0x80740b0) SourceCode/ grub/grub2- 1.98/kern/ disk.c: 278: GRUB_ERR_ UNKNOWN_ DEVICE SourceCode/ grub/grub2- 1.98/kern/ disk.c: 271: dev->open (0x804b6d6) biosdisk_ open(hd0) drive(hd0) drive(hd0) returned 0 SourceCode/ grub/grub2- 1.98/kern/ disk.c: 273: GRUB_ERR_NONE
/home/all/
/home/all/
/home/all/
/home/all/
/home/all/
/home/all/
/home/all/
grub_util_
find_grub_
i=0 hd0
find_grub_
setting disk->id=0
/home/all/
grub-setup: testing: disk->id = 0
So find_grub_drive() is the function returning 0.
That function simply iterates through an array called 'map' that contains the contents of /boot/grub/ device. map. The first entry in 'map' (map[0]) represents the first line in the device.map file.
From that it is now possible to see why the id is set to 0 and therefore why the buggy BIOS work-around never gets applied to the boot sector.