herber@bgsuvax.UUCP (Steve Herber) (02/10/88)
I spent some time playing with the partition sizes defined in the uda.c UNIBUS disk driver because we were installing some System Industries SI83C disk drives (522Mb), DEC RA82 compatible (see a follow up article in comp.periphs about this installation). I wanted to stretch out the useful disk space as much as possible. I noticed that when I used /etc/newfs, it usually listed a large number of wasted sectors in the last cylinder. I finally figured out that the number of wasted sectors was equal to the difference between the number of sectors given for that partition in /etc/disktab and the total number of sectors available on the number of cylinders used for that partition. Newfs always rounded up and wouldn't allow a cylinder to be split between partitions. 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? Does there have to be a fixed number of 'padding' sectors at the end so that the Unix filesystems will be OK? ...inquiring minds want to know... Thanks in advance. -- Steve Herber CSNET herber@bgsu.edu Sr. Systems Programmer UUCP ...!osu-cis!bgsuvax!herber Bowling Green State Univ.
chris@trantor.umd.edu (Chris Torek) (02/15/88)
[This makes a nice story, so I am quoting it all:] In article <1560@bgsuvax.UUCP> herber@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@mimsy.umd.edu Path: not easily reachable