A few MORE questions about 4.3BSD partitions.

Chris Torek chris at trantor.umd.edu
Mon Feb 15 12:40:49 AEST 1988


[This makes a nice story, so I am quoting it all:]

In article <1560 at bgsuvax.UUCP> herber at bgsuvax.UUCP (Steve Herber) writes:
>Well, I got out my calculator and quickly figured out CYLINDERS NEEDED *
>SECTORS/TRACK * TRACKS/CYLINDER so that all of my partitions ended EXACTLY
>on cylinder boundaries.  Boy, was I proud of myself (pat myself on back
>here:-) for getting the most efficient usage out of my disks...
>
>...until I started to get 'CAN NOT READ BLOCK: BLK 1016197' errors from
>FSCK on a few of the partitions where the block number was always 3 from 
>the end of the partition.  From that point on, my disk was corrupted
>beyond FSCK's ability to repair it.  I eventually figured out that 
>I could build the partition using sector sizes 3 smaller the maximum
>number available on the cylinder boundaries and I have not had any
>corruption since.
>
>OK, now the $64,000 question.  Why can't I make the partition sizes
>exactly equal to the maximum of sectors available on a group of
>cylinders?

Be not embarrassed.  I made the very same mistake.

The number of sectors in the root file system must be a multiple
of four.  If it is not, fsck will be unable to read the very last
block.  On other file systems, it is less important since fsck
normally uses the raw device; but fsck must use the block device
to check /, and the kernel does block device I/O in units of
BLKDEV_IOSIZE bytes.  Examining <sys/param.h>, you will see that
BLKDEV_IOSIZE is 2048, which is 2048/512, or 4, sectors.

The moral is that you should not only make your file systems
multiples of cylinders (to get full use), but also multiples
of 4 sectors (to avoid confusing fsck).  Alternatively, apply
the following section of code to disk strategy routines.  This
is from the current vaxmba/hp.c, and replaces the old

	if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz)
		goto bad;

I am not sure if it uses any post-4.3BSD-release features.

	if (bp->b_blkno < 0) {
		bp->b_error = EINVAL;
		goto bad;
	}
	if (bp->b_blkno + sz > maxsz) {
		if (bp->b_blkno == maxsz) {
			bp->b_resid = bp->b_bcount;
			goto done;
		}
		sz = maxsz - bp->b_blkno;
		if (sz <= 0) {
			bp->b_error = EINVAL;
			goto bad;
		}
		bp->b_bcount = sz << DEV_BSHIFT;
	}
-- 
In-Real-Life: Chris Torek, Univ of MD Computer Science, +1 301 454 7163
(hiding out on trantor.umd.edu until mimsy is reassembled in its new home)
Domain: chris at mimsy.umd.edu		Path: not easily reachable



More information about the Comp.unix.wizards mailing list