"The Linux Gazette...making Linux just a little more fun!"


(?) The Answer Guy (!)


By James T. Dennis, [email protected]
LinuxCare, http://www.linuxcare.com/


(?) One Bad Sector

It Doesn't Ruin the Whole Disk

From John Gilbert on Tue, 04 May 1999

(?) I cant believe that its not possible to re-use or dispose of a bad sector on a hard drive!!!

Please tell me its possible to do something!

I only have one bad sector - but its really pissing me off! Isn't there something I can do?

Awaiting your response,
JB.

(!) Hmm. You can "dispose" of a bad sector by adding it to the bad blocks list. The easiest way to do this is to allow the mke2fs and e2fsck tools "check" the portions of the disk that underlie a given filesystem by using the -c options to each of them.
Thus, when you first create an ext2 filesystem you should always add the -c option so that it will (transparently) call the 'badblocks' command and account for those that are detected. (The installation front ends to most Linux and GNU suite distributions, such as Red Hat, Caldera, etc. have a checkbox on their menu/dialogs to enable this).
When you suspect that additional sectors have gone bad you should run 'e2fsck -c' to add any newly bad sectors to the bad blocks list that is maintained as part of the the filesystem's metadata.
There are similar features for other filesystem types --- although in some cases you'll have to build the badblocks table to a file and run the filesytem formatting utility separately (I won't go into details about feeding a badblocks list to each of the alternative Linux filesystem types as I don't know them off hand and they'd only be of interest to a tiny percentage of LG reader --- much less than 1% by my guess).
If the sector that goes bad is sector number one on track zero --- then you have a paperweight. That one sector is a single point of failure (SPOF) in the whole PC drive management architecture. This is a limitation of the architecture that lies below the OS level as it is imposed by the BIOS. Certainly someone could write a BIOS to overcome the problem. It's also possible that your hard drive has quite a bit of built in redundancy to prevent the problem from ever being visible to the BIOS.
Modern hard drives are sophisticated pieces of electronics.
They have embedded microprocessors running programs that map their own arrangements of data blocks into an abstraction that's compatible with the BIOS representation of a hard disk. A BIOS "thinks" of a hard disk as a flat three dimensional array of head and tracks (cylinders) and sectors. In reality modern drives are almost always more complex and far less regular.
Most modern drives store more sectors on their outer tracks than they do on the inner ones. This is referred to as ZBR (zone-bit recording).
Most drives have "extra" sectors on each track --- and they'll automatically map the "extras" in for any sector that they detect as bad or "weak."
All hard drives have always implemented some error detection into their electronics. All recent drives (the last decade or so) have also implemented at least rudimentary ECC, error correction coding. When a drive's electronics detect errors they automatically try several re-reads to "get it right." Many drives are programmed to move the successfully read data into one of the "extras" on that track when this occurs. Likewise if they detect "correctable" errors through their ECC mechanisms. Some drives might even migrate data to extra sectors on adjacent tracks or heads.
So, you generally won't see bad sectors on a modern drive until there are enough of them that all of the available extras on a given track, cylinder, or within a given zone, are all in use.
Most drives have a "hidden" extra cylinder on which they store some of the persistent data for these low level mapping and remapping operations. This is the "diagnostics cylinder." I think that they also have at least one sector per track or cylinder devoted to maintaining the bad block remappings for that track. (Some drives might implement this as an additional surface --- so that one drive head is devoted to all diagnostics).
Most modern hard drives also have quite a bit of RAM on them. A half meg is minimal, and two to four meg is common on larger, high performance SCSI drives. I don't keep up on these things so they may have drives with 8 or 16 Mb onboard.
I've often wondered if it wouldn't make more sense for drive manufacturers to support a small (socketed?) bit of NVRAM to store the MBR and the location of their diagnostics data map. Of course it's possible that some of them ARE doing this --- since I wouldn't know.
Of course I'm just speculating here. I've never designed hard drives and my discussions with hardware engineers from Seagate, Quantum and other aquaintances in the field have been far less detailed than my preceding speculations.
The key point here is that these drives are not just simple arrays of heads, sectors and tracks. I think I read a message from Linus recently (on the kernel-list, in reference to discussions about implementing "elevator-seeking" and similar tricks in the low level disk drivers) that basically said: 'anyone who treats a modern hard drive as anything other than a linear list of storage blocks is a fool.'
As for "re-using" a bad sector: you shouldn't have to worry about that. If you drive hasn't already done it automatically and transparently then your best strategy is to mark it as bad and let the OS work AROUND that spot. Occasional surface defects and wear and tear are to be expected in any mechanical equipment --- and hard drives are fundamentally mechanical.


Copyright © 1999, James T. Dennis
Published in The Linux Gazette Issue 42 June 1999
HTML transformation by Heather Stern of Starshine Techinical Services, http://www.starshine.org/


[ Answer Guy Index ] 1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24


[ Table Of Contents ] [ Front Page ] [ Previous Section ] [ Next Section ]