Subject: Re: Hard errors in hd.
To: Jesus M. Gonzalez <jgb@gsyc.inf.uc3m.es>
From: Phil Knaack <flipk@idea.exnet.iastate.edu>
List: port-i386
Date: 08/28/1996 13:32:08
Jesus M. Gonzalez <jgb@gsyc.inf.uc3m.es> writes: 

>	We have a disk (wd) wich is giving some hard errors in a sector,
>something like:

>Hard error in BSN ...

>	What do I have to do to tell NetBSD not to use it? Should
>I renewfs the partition? Or what?

	I battled with this a couple of weeks ago on an older drive with
several defects.

	The solution is (supposed to be) to use the program "badsect" to
mark them as bad. Badsect will create a device node whose device numbers
are the FSBN of the bad sector(s) in a subdir on the disk, and then 
"fsck" will convert those device nodes into files which hold those bad 
blocks.

	The only problem is that badsect requires the filesystem to be
mounted to create the device nodes, and must also open the raw device to 
determine if the block numbers specified hold such things as boot info or
superblock data (in which case the block _cannot_ be marked as bad).

	This is a problem because I believe some recent change (can't
remember if its before or after 1.1) in the kernel disallows simultaneous
access to a mounted filesystem and the raw device that its mounted from.
Thus badsect is useless, without either

		a) modifications to badsect to have it check the locations
			of these sectors while the fs is not mounted and
			THEN create the nodes while mounted, or

		b) a (temporary) kernel patch that allows such
			modifications.

	My solution was to modify badsect to do only the checks on the
raw filesystem, then wrote my own 10-line program which called mknod(2) 
to create the nodes. (I only needed it once so I didn't put much effort
into modifying anything else.)

	Once this is done, an "fsck" and answering "yes" to the 
"Hold bad blocks? [n]" question is all it takes.

	If this kernel change was post-1.1 then you should have no problems
with badsect.

Good luck.

Cheers,
Phil
--
Phillip F Knaack
Database Programmer, Information Development for Extension Audiences (IDEA)
Iowa State University Extension