Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Feb 1997 22:24:21 +0100 (MET)
From:      =?iso-8859-1?Q?=22Dag?= -Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav=22?=  <dag-erli@ifi.uio.no>
To:        freebsd-doc@freebsd.org
Subject:   Bug report: FreeBSD makes invalid partition table entries
Message-ID:  <199702112124.18867.gymir.ifi.uio.no@ifi.uio.no>

next in thread | raw e-mail | index | archive | help
My FreeBSD isntallation isn't on the net, so I couldn't use send-pr. I did,
however, use the template so I hope you can use this:

>Submitter-Id:   current-users
>Originator:     Dag-Erling Smoergrav
>Organization:   University of Oslo
>Confidential:   no
>Synopsis:       FreeBSD partition entries are invalid
>Severity:       non-critical
>Priority:       low
>Category:       i386
>Release:        FreeBSD 2.1-STABLE i386
>Class:          sw-bug
>Environment:
 
I have not checked for this bug on other computers than mine, but I suppose
it applies to all i386-based computers.
 
>Description:

There is apparently an off-by-one error in the code that creates the FreeBSD
partition during installation. The length field in the partition table is
correct; however the ending-cylinder/sector field is low by one cylinder.
 
This is a little hairy because actually FDISK doesn't give a damn, the BIOS
doesn't give a damn, DOS doesn't give a damn and none of my own software (I
write disk utilities for a hobby :) ) gives a damn. PowerQuest PartitionMagic,
however, *does* give a damn, and will report a "partition table error #101" for
the relevant disk.
 
I verified that the error was indeed FreeBSD's thus:

I read the MBR into a file, and vgrepped its contents. The disk where I keep
FreeBSD is an ST3144A (the first widespread 1-inch IDE drive to hit the market,
back in '91-'92) with 1001 cylinders, 15 heads and 17 sectors per track. The
FreeBSD partition was listed with a starting position of 1/0/1 and an ending
position of 999/14/17 (the first cylinder contains my homemade multi-booter)
 
Now the last cylinder is numbered 1000, so either the FreeBSD partition was one
cylinder short, or the entry was wrong. Since PQMagic had reported an error, I
checked the length field, which was 255,000 (1000*15*17). Now according to the
start and stop fields this should be 254,745 (999*15*17). I set it to that
value, wrote the MBR back and booted FreeBSD, which complained that the
partition was smaller than the slices it held. I rebooted DOS, changed the
length back to 255,000 and the ending position to 1000/14/17, wrote back and
rebooted FreeBSD, which chirped happily. I also checked the disk with PQMagic
which no longer reported any errors.
 
This seems to indicate that the length field was right and the ending position
wrong, and that FreeBSD only cares about the start position and the length
(which explains why the off-by-one error doesn't register).
 
>How-To-Repeat:
 
Install FreeBSD :)
 
>Fix:
 
See "Description" for an explanation of how I worked around the bug.
 
For a more permanent fix, I suppose FreeBSD's disk partitioning utility needs a
brush-up. I looked through pfdisk.c (dunno if it's the right program, though)
but the readability is like something I'd write while drunk and blind and with
both hands tied behind my back, so I gave up trying to track down the error
(let alone fixing it).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702112124.18867.gymir.ifi.uio.no>