Dobrica Pavlinušić's random unstructured stuff
GNU fdisk broken: Revision 3

I have been backing up whole disk image from Eee PC, and mounting it using loop file system to access partition in it. However, I have problems with GNU fdisk which reports 4Gb image as:


Disk /backup/eee/hda: 3 GB, 3997486080 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7807590 sectors
Units = sectors of 1 * 512 = 512 bytes


 Device Boot Start End Blocks Id System
 /backup/eee/hda1 63 4803435 2409718 83 Linux
 /backup/eee/hda2 4819563 7759395 1469947 83 Linux
 /backup/eee/hda3 7775523 7775460 0 c FAT32 LBA
 /backup/eee/hda4 7791588 7791525 0 ef EFI FAT

For a start, disk size is wrong:


$ ls -al hda
-rwxrwxrwx 1 dpavlin root 4001292288 2008-01-20 00:59 hda


And then, even more wrong, offsets of partition seem to be wrong. When same image is examined using fdisk from util-linux, sectors are reported like this:


Disk hda: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x332b332a


Device Boot Start End Blocks Id System
 hda1 63 4819499 2409718+ 83 Linux
 hda2 4819500 7775459 1477980 83 Linux
 hda3 7775460 7791524 8032+ c W95 FAT32 (LBA)
 hda4 7791525 7807589 8032+ ef EFI (FAT-12/16/32)

And this is correct (let's ignore size for now). I can verify this by mounting second file system as:


sudo mount hda 1 -o loop,offset=`expr 4819500 \* 512`


This seems to be off-by-one error. There is bug reported against Debian package which seems related, but than again, in my case I'm examining same disk image.