[dm-devel] Re: grub 0.96 bug

Molle Bestefich molle.bestefich at gmail.com
Mon Mar 21 14:55:02 UTC 2005


> grub> device (hd0) /dev/mapper/hpt37x_ehgjaggaf
> grub> device (hd0,5) /dev/mapper/hpt37x_ehgjaggaf6
> grub> root (hd0,5)/boot
> Attempt to open drive 0x80 (/dev/mapper/hpt37x_ehgjaggaf6)
> Error 5: Partition table invalid or corrupt
> grub> root (hd0,5)/boot
> Attempt to open drive 0x80 (/dev/mapper/hpt37x_ehgjaggaf6)
> Error 5: Partition table invalid or corrupt

Think it tries to read a partition table out of a logical partition, humn...
No idea where to look for this bug; hints appreciated.

> grub> root (hd0,5)/boot
> Attempt to open drive 0x80 (/dev/mapper/hpt37x_ehgjaggaf)
> Error 18: Selected cylinder exceeds maximum supported by BIOS

Examining further, GRUB thinks the disk has only 4999680 sectors.
It corresponds to about 2.441 MB, while the disk is really about 160.000 MB.

Looking through the source code, the above sector value is some insane
default in GRUB.
The code tries to use 3 different ways of getting the sector count:

1.) ioctl(fd, HDIO_GETGEO) call in lib/device.c
Fails with error -1.
Documentation/hdio.txt from kernel sources has this to say with
regards to that function:
"Not particularly useful with modern disk drives, whose geometry is a
polite fiction anyway. "

2.) fstat (fd, &st)
Fails with error 0.
No idea what this should do :-).

3.) ioctl(fd, BLKGETSIZE) call in lib/device.c
This works for device-mapped devices!
Seems to be a widely used function, there's even a 64-bit version.
Unfortunately, GRUB only attempts this approach after having
*successfully* retrieved cylinder, head and sector values through
HDIO_GETGEO.


I've gone ahead and solved my problems myself; the attached patch
fixes GRUB 0.96 to work correctly (at least for me) with device-mapped
devices.

This is my first hack ever with anything Linux-ie.
So go ahead and flame at will :-).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grub-0.96-devicemapper.patch
Type: application/octet-stream
Size: 1895 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20050321/d06d3f1b/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: oh joy it works.txt
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20050321/d06d3f1b/attachment.txt>


More information about the dm-devel mailing list