*BSD News Article 16509


Return to BSD News archive

Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!metro!ipso!runxtsa!bde
From: bde@runx.oz.au (Bruce Evans)
Subject: Re: bad block handling... documentation? what documentation?
Message-ID: <1993May26.025119.2864@runx.oz.au>
Organization: RUNX Un*x Timeshare.  Sydney, Australia.
References: <C7J4Dt.A1A@sugar.NeoSoft.COM>
Date: Wed, 26 May 93 02:51:19 GMT
Lines: 59

In article <C7J4Dt.A1A@sugar.NeoSoft.COM> peter@taronga.com writes:
>Well, I've been trying to get bad144 turned on on my ESDI drives for months
>and I still get the same errors on boot up: a hard read error on the bad
>sector map itself. Now, the 'c' and 'd' partitions cover the map, and I can
>read and write it just fine... at least when I read I read the same thing
>I wrote. This happens on wd0 and wd1, and it happens even when I adjust
>the diskmap to 1221 cylinders instead of 1222 (and adjust 'c' and 'd' to
>match).

The bad sector table goes at the end of the 'c' partition, so if you can
read and write 'c' and 'd' then you can read and write the bad sector
table.  If not, then perhaps the bootstrap disagrees with the kernel
about where the disklabel is (I once got confused by mixing 0.0 and 0.1
bootstraps, kernels and disklabel binaries).  bad144 actually accesses
the bad sector table through the 'd' partition because it wants to work
with absolute sector numbers.  This is somewhat dangerous because the
driver cannot check the 'd' partition boundaries very carefully
(actually wd.c doesn't check at all, so bad144 and disklabel will "work"
even if the 'd' partition is empty).

You have to intialize the table before you can read it.  It is normal to
get errors about a badly formatted bad sectoe table on a freshly labeled
disk.  The bad sector table needs to be formatted immediately after
disklabeling by running bad144 with suitable options to set the serial
number and nothing else (these options are unclearly documented).  After
that, read partition 'c' using dd to find all bad sectors.  You need
patchkit-0.2.3/patch10003 to force the wd driver to print suitable error
messages about where the bad sctors are.  (Actually, not completely
suitable.  The driver forgets to terminate the messages with newlines.
The bug in the driver that inhibits this printing is that the
DKFL_QUIET flag is turned off only if partition 'd' is opened first.)

This is my disk label for a 1222-cylinder ESDI drive.  The "unused"
cylinders in it are actually used seriously damaged cylinders (too many
for bad144 to handle) and by Minix, DOS and Linux partitions.

# /dev/rwd0d:
type: ESDI
disk: mydisk1
label: 
flags: badsect
bytes/sector: 512
sectors/track: 35
tracks/cylinder: 7
sectors/cylinder: 245
cylinders: 1222
rpm: 3600
interleave: 1
...

8 partitions:
#        size   offset    fstype   [fsize bsize   cpg]
  a:    14700      245    4.2BSD      512  4096    16 	# (Cyl.    1 - 60)
  b:    25725    29400    4.2BSD     1024  8192    16 	# (Cyl.  120 - 224)
  c:   299145      245    unused        0     0       	# (Cyl.    1 - 1221)
  d:   299390        0    unused        0     0       	# (Cyl.    0 - 1221)
  h:   100695   198450    4.2BSD      512  4096    16 	# (Cyl.  810 - 1220)
-- 
Bruce Evans  bde@runx.oz.au