Date: Fri, 16 Aug 2002 11:50:06 -0700 (PDT) From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/20633: fdisk doesn't handle LBA correctly Message-ID: <200208161850.g7GIo6ZQ047726@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/20633; it has been noted by GNATS. From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru> To: Bruce Evans <bde@zeta.org.au>, freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: bin/20633: fdisk doesn't handle LBA correctly Date: Fri, 16 Aug 2002 22:42:35 +0400 On Sat, Aug 17, 2002 at 03:56:57AM +1000, Bruce Evans wrote: > On Fri, 16 Aug 2002, Artem 'Zazoobr' Ignatjev wrote: > > Hi, if I understand what jhb said in audit trail, following patch > > should solve the issue. Stephen, if it still bothers you, could you try > > it? > > > > --- sbin/i386/fdisk/fdisk.c Fri Aug 16 16:24:27 2002 > > +++ sbin/i386/fdisk/fdisk.c Fri Aug 16 16:33:28 2002 > > @@ -468,13 +468,21 @@ [skip] > > - printf("\tbeg: cyl %d/ head %d/ sector %d;\n\tend: cyl %d/ head %d/ sector %d\n" [skip] > > + /* > > + * if C/H/S of start or end are all set to 0xff, then C/H/S don't have > > + * enough bits to hold the address, and one should use LBA instead. > > + */ > > + if ((partp->dp_scyl != 0xff || partp->dp_ssect != 0xff || > > + partp->dp_shd != 0xff) && (partp->dp_ecyl != 0xff || > > + partp->dp_esect != 0xff || partp->dp_ehd != 0xff)) > > + printf("\tbeg: cyl %d/ head %d/ sector %d;\n" [skip] > > Fdisk should print these values, at least optionally, since they are needed > for debugging. The magic values might be non-magic on old systems. Debugging WHAT? And, I can hardly imagine such a situation inside hard drives & slice tables. > Also, the usual magic number of cylinders seems to be 1022, not 1023. I disagree. Now i'm hacking fdisk to work with extended slices, it can now dump partition table of the whole disk, since this inability dove me mad when I was installing FreeBSD into extended (there was another issue to make it boot :-) ), when i'll finish it, I'll send the proposed sources/patches to -hackers, also I hope I make boot2 more friendly to extended slices (I've got already hack for boot1 to allow booting from bootmanagers ala ntloader). Take a look at the dump (I've cut all entries regarding extendeds below the top-level slicetable, since them all take space, but are of no interest now) Script started on Fri Aug 16 22:23:06 2002 ******* Working on device /dev/ad4 ******* parameters extracted from in-core disklabel are: cylinders=7476 heads=255 sectors/track=63 (16065 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=7476 heads=255 sectors/track=63 (16065 blks/cyl) Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: sysid 6 (Primary 'big' DOS (> 32MB)), start 63, size 2088387 (1019 Meg), flag 0 beg: cyl 0/ head 1/ sector 1; end: cyl 129/ head 254/ sector 63 The data for partition 2 is: sysid 7 (OS/2 HPFS, NTFS, QNX-2 (16 bit)), start 2088450, size 8385930 (4094 Meg), flag 80 (active) beg: cyl 130/ head 0/ sector 1; end: cyl 651/ head 254/ sector 63 The data for partition 3 is: sysid 131 (Linux filesystem), start 10474380, size 4192965 (2047 Meg), flag 0 beg: cyl 652/ head 0/ sector 1; end: cyl 912/ head 254/ sector 63 The data for partition 4 is: sysid 15 (Extended DOS, LBA), start 14667345, size 105435855 (51482 Meg), flag 0 beg: cyl 913/ head 0/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 5 is: sysid 130 (Linux swap or Solaris x86), start 14667408, size 256977 (125 Meg), flag 0 beg: cyl 913/ head 1/ sector 1; end: cyl 928/ head 254/ sector 63 The data for partition 7 is: sysid 131 (Linux filesystem), start 14924448, size 16771797 (8189 Meg), flag 0 beg: cyl 929/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 9 is: sysid 7 (OS/2 HPFS, NTFS, QNX-2 (16 bit)), start 31696308, size 40965687 (20002 Meg), flag 0 beg: cyl 1023/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 11 is: sysid 12 (FAT-32, LBA), start 72662058, size 7389837 (3608 Meg), flag 0 beg: cyl 1023/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 13 is: sysid 165 (FreeBSD/NetBSD/386BSD), start 80051958, size 8401932 (4102 Meg), flag 0 beg: cyl 1023/ head 254/ sector 63; end: cyl 1023/ head 254/ sector 63 The data for partition 15 is: sysid 7 (OS/2 HPFS, NTFS, QNX-2 (16 bit)), start 88453953, size 25398702 (12401 Meg), flag 0 beg: cyl 1023/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 Script done on Fri Aug 16 22:23:06 2002 A-ha! Better see once, than hear many times: magic value for start is 1023/1/1, and for end is 1023/254/63, but note my FreeBSD slice - it was created using linux fdisk, but even these strange values works ok. > Writing the correct magic numbers is more interesting. fdisk(8) doesn't > support it directly. You may have to change the C/H/S values to the magic > ones manually. Is there any papers on the subject? All my knowledge was obtained experimentally, watching how my dad revives dead hds.... It looks like the magic is cyl=1023, regardless of h/s values... Sinceherely yours, Artem 'Zazoobr' Ignatjev. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208161850.g7GIo6ZQ047726>