old-www/LDP/LG/issue37/tag/39.html

233 lines
9.0 KiB
HTML

<!--startcut ======================================================= -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META NAME="generator" CONTENT="lgazmail v1.1H.i">
<TITLE>The Answer Guy 37: Removing Bad Sectors</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
LINK="#3366FF" VLINK="#A000A0">
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<H4>"The Linux Gazette...<I>making Linux just a little more fun!</I>"</H4>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<center>
<H1><A NAME="answer">
<img src="../../gx/dennis/qbubble.gif" alt="(?)"
border="0" align="middle">
<font color="#B03060">The Answer Guy</font>
<img src="../../gx/dennis/bbubble.gif" alt="(!)"
border="0" align="middle">
</A></H1>
<BR>
<H4>By James T. Dennis,
<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a><BR>
Starshine Technical Services,
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H4>
</center>
<p><hr><p>
<!-- endcut ======================================================= -->
<!-- begin 39 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
height="50" width="60" alt="(?) " border="0"
>Removing Bad Sectors</H3>
<p><strong>From Fadel on Fri, 22 Jan 1999
</strong></p>
<!-- ::
Removing Bad Sectors
~~~~~~~~~~~~~~~~~~~
:: -->
<P><STRONG>
Dear Sir..
<br>How are you?
I'm Writing to ask you How can I remove bad sectors HDD?
Please reply me as soon as you can.
<br>yours
<br>Fadel
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
HEIGHT="28" WIDTH="50" BORDER="0"
>
I'm not sure what you mean by "removing bad sectors."
</BLOCKQUOTE>
<BLOCKQUOTE>
A "bad sector" is a portion on a hard drive we doesn't
appear to reliably record data. That is to say that
attempts to record test patterns to this location on
the disk and read them back result in errors.
</BLOCKQUOTE>
<BLOCKQUOTE>
Some bad sectors are manufacturers defects on the
surface of the disk (generally minor imperfections
in the metal-oxide or other coating which is deposited
on the disk platter during its manufacture). Before
it is shipped a normal hard drive is thoroughly tested
on the manufacturer's test harnesses to "map out" the
initial set of bad sectors and to ensure that the number
of them fell below a suitable threshold.
</BLOCKQUOTE>
<BLOCKQUOTE>
Back in the old days (about 5 years ago and more) it
was common to see the bad sectors listed on a sticker
on the drives housing. That was common with MFM and
RLL (ST-506 interface) drives. However it is largely
unnecessary with modern SCSI and IDE drives.
</BLOCKQUOTE>
<BLOCKQUOTE>
Modern hard drives have "extra" sectors on every track.
These are automatically "mapped in" to replace bad
sectors. This happens initially at the factory and
(at least with some of them) automatically in normal
use. The drive electronics on these sorts of drives are
actually embedded microcomputers running a program to
store (typically on a "hidden" diagnostics cylinder) the
state of the rest of the drive.
</BLOCKQUOTE>
<BLOCKQUOTE>
Consequently most modern drives leave the factor with
no "apparent" bad sectors (and a few extras per track).
So they'd rarely need a bad sectors list. (Also if they
had one it would be very difficult to use it in
mainstream modern operating systems like Window '98
--- which has no option or way for you to supply a
list of bad sectors to their disk formatting utilities).
</BLOCKQUOTE>
<BLOCKQUOTE>
In the case of Linux is is possible to supply such a list.
However it is generally much easier to just run '<tt>badblocks</tt>'
which will scan specified portions of the disk's surface
testing every sector and returning a list of bad blocks.
</BLOCKQUOTE>
<BLOCKQUOTE>
Normally you wouldn't run '<tt>badblocks</tt>' yourself. As I've
mentioned in past issues of my column, you normally
supply <tt>-c</tt> options to the <tt>mke2fs</tt> and <tt>e2fsck</tt>
commands (named <tt>mkfs.ext2</tt> and <tt>fsck.ext2</tt> on some systems).
These options force these commands to transparently call
'<tt>badblocks</tt>', passing in the parameters specifying the
partitions (disk regions) and reading back the results
(the bad blocks). The resulting list of bad blocks is then
stored according to the needs of the filesystem in question
(ext2 in this case).
</BLOCKQUOTE>
<BLOCKQUOTE>
The ext2 filesystem uses a special sort of "hidden file" to
which it allocates all of the bad blocks on the filesystem.
The insures that those data blocks (sectors) will never
be accessed or used for any other files.
</BLOCKQUOTE>
<BLOCKQUOTE>
Under MS-DOS we used to manually name files suspected of
containing a bad block (those which would cause the whole
system to "hang" when we'd attempt to access them) with a
name like <tt>BADBLOCK.001</tt>. Later Peter Norton, Paul Mace and
others wrote utilities to help use test for and properly
mark bad blocks.
</BLOCKQUOTE>
<BLOCKQUOTE>
Now, if you mean that you want to return badblocks to
use I suppose the easiest method would be to make a
new filesystem over the one that has the bad blocks.
You could run mke2fs without the -c option and let
it trip over any bad blocks on it's own. If there are
blocks that were properly detected as 'bad' before
--- it's typically a VERY BAD idea to try to use them
to store data later. You can't selectively use the
'bad blocks' for "unimportant" data and you can't guarantee
that the controller won't hang up the whole system
(or drastically hurt its performance) during attempts
to access these. (Sometimes blocks are "marginal" ---
data can be stored there and read back with some
retries and error correction. All hard drives use
ECC --- error correction coding and automatically
correct most bit errors in normal operation. However,
a block is declared 'bad' when it passes certain
thresholds, always requiring ECC and often requiring
multiple retries. I don't know the exact details of
those thresholds --- but they certainly differ among
various drive manufacturers).
</BLOCKQUOTE>
<!-- sig -->
<!-- end 39 -->
<!--startcut ======================================================= -->
<P> <hr> <P>
<H5 align="center"><a href="http://www.linuxgazette.com/copying.html"
>Copyright &copy;</a> 1999, James T. Dennis
<BR>Published in <I>The Linux Gazette</I> Issue 37 February 1999</H5>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P align="center">
<table width="98%"><tr valign="center" align="center">
<td rowspan="3" colspan="4"><A HREF="../lg_answer37.html"><IMG
SRC="../../gx/dennis/answernew.gif"
ALT="[ Answer Guy Index ]"></A></td>
<TD width="8%"><A HREF="./1.html">1</A></TD>
<TD width="8%"><A HREF="./2.html">2</A></TD>
<TD width="8%"><A HREF="./3.html">3</A></TD>
<TD width="8%"><A HREF="./4.html">4</A></TD>
<TD width="8%"><A HREF="./5.html">5</A></TD>
<TD width="8%"><A HREF="./6.html">6</A></TD>
<TD width="8%"><A HREF="./7.html">7</A></TD>
<TD width="8%"><A HREF="./8.html">8</A></TD>
<TD width="8%"><A HREF="./9.html">9</A></TD>
<TD width="8%"><A HREF="./10.html">10</A></TD>
</tr><tr valign="center" align="center">
<TD><A HREF="./11.html">11</A></TD>
<TD><A HREF="./12.html">12</A></TD>
<TD><A HREF="./14.html">14</A></TD>
<TD><A HREF="./15.html">15</A></TD>
<TD><A HREF="./16.html">16</A></TD>
<TD><A HREF="./17.html">17</A></TD>
<TD><A HREF="./18.html">18</A></TD>
<TD><A HREF="./19.html">19</A></TD>
<TD><A HREF="./21.html">21</A></TD>
<TD><A HREF="./22.html">22</A></TD>
</tr><tr valign="center" align="center">
<TD><A HREF="./23.html">23</A></TD>
<TD><A HREF="./28.html">28</A></TD>
<TD><A HREF="./29.html">29</A></TD>
<TD><A HREF="./30.html">30</A></TD>
<TD><A HREF="./31.html">31</A></TD>
<TD><A HREF="./32.html">32</A></TD>
<TD><A HREF="./33.html">33</A></TD>
<TD><A HREF="./34.html">34</A></TD>
<TD><A HREF="./37.html">37</A></TD>
<TD><A HREF="./38.html">38</A></TD>
</tr><tr valign="center" align="center">
<TD><A HREF="./39.html">39</A></TD>
<TD><A HREF="./41.html">41</A></TD>
<TD><A HREF="./42.html">42</A></TD>
<TD><A HREF="./43.html">43</A></TD>
<TD><A HREF="./44.html">44</A></TD>
<TD><A HREF="./45.html">45</A></TD>
<TD><A HREF="./46.html">46</A></TD>
<TD><A HREF="./47.html">47</A></TD>
<TD><A HREF="./48.html">48</A></TD>
<TD><A HREF="./49.html">49</A></TD>
</tr></table>
</P>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P> <hr> <P>
<!-- begin lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<A HREF="../index.html"
><IMG SRC="../../gx/indexnew.gif" ALT="[ Table Of Contents ]"></A>
<A HREF="../../index.html"
><IMG SRC="../../gx/homenew.gif" ALT="[ Front Page ]"></A>
<A HREF="../lg_bytes37.html"
><IMG SRC="../../gx/back2.gif" ALT="[ Previous Section ]"></A>
<A HREF="../york.html"
><IMG SRC="../../gx/fwd.gif" ALT="[ Next Section ]"></A>
<!-- end lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
</BODY></HTML>
<!--endcut ========================================================= -->