From: Michael Haardt (u31b3hs@cip-s02.informatik.rwth-aachen.de)
Date: 07/16/92


From: u31b3hs@cip-s02.informatik.rwth-aachen.de (Michael Haardt)
Subject: FAQ addition: (was Re: Badblocks revisited (**sigh**))
Date: 16 Jul 1992 08:21:05 GMT

duperval@ERE.UMontreal.CA (Duperval Laurent) writes:
> [I have badblocks, how can I mark them?]

Ok, it seems time to write that article once again, since it comes up
so often, in both comp.os.minix and comp.os.linux. If everybody has
working improvements of my method, *please* say so.

I think you have a MFM 506 like drive, because both SCSI and IDE drives
map bad blocks away on their own.

Linux does not mark bad blocks, so you have to do that. It's not really
difficult, it is just that you need MINIX to do the job. Don't yell at
me ...

First, make a backup. I'll say that only once.

Then boot MINIX and don't mount your HD. Use readall(1) to find out all
bad blocks on your HD and note them. In theory, you can use
badblocks(1) now, assuming that you have a working version. I never
had, due to the wonderful diff strategy :(

Then make a new filesystem. If that gives problems, you will have to
move your partition start a little higher, you can't mark bad blocks
at the start of the fs.

One inode can contain 7 direct blocks, so you need enough inodes to
hold all blocks. Mount your HD under /mnt and do "touch /mnt/.BAD000",
"touch /mnt/.BAD001" etc. until you have enough files, each using one
inode. Next unmount your HD and use de(1) to edit the inodes. You will
have to change filesize to 7*1024=7168 and write the numbers of the
bad blocks into the block fields.

Next, which is a little more complicated, you have to change the zone
bitmaps. Used zones (==blocks, because 1 block == 1024 bytes == 1 zone)
are marked with an set bit. The MINIX 1.3 book explains in which order
the bits are, if I remember right lower bits are lower numbers. de(1)
will help you to find the right words.

Last you should do is running "fsck -a" on your partition, and you are
done.

I hope you formatted your harddrive using the media defect table, otherwise
you will have to reiterate the above procedure a few times ;) The
manufacturer can make better checks, so there are blocks listed which are
only weak but may work after formatting, but after a certain time they
will be bad. I know that from experience, the "certain time" was a few
months. Don't think the automatic bad block search of formatters will
find them. It is an *additional* check and I wish people would mark it
as that.

Do I need to say that a) you now can restore your system and b) you
regularly should make backups? I don't think so :)

Michael