489 lines
9.0 KiB
HTML
489 lines
9.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Formatting</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux System Administrators Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Using Disks and Other Storage Media"
|
|
HREF="disk-usage.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Tapes"
|
|
HREF="tapes.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Partitions"
|
|
HREF="partitions.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux System Administrators Guide: </TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="tapes.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 5. Using Disks and Other Storage Media</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="partitions.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="FORMATTING"
|
|
></A
|
|
>5.8. Formatting</H1
|
|
><P
|
|
><I
|
|
CLASS="GLOSSTERM"
|
|
>Formatting</I
|
|
>
|
|
is the process of writing marks
|
|
on the magnetic media that are used to mark tracks and sectors.
|
|
Before a disk is formatted, its magnetic surface is a complete mess
|
|
of magnetic signals. When it is formatted, some order is brought
|
|
into the chaos by essentially drawing lines where the tracks go, and
|
|
where they are divided into sectors. The actual details are not
|
|
quite exactly like this, but that is irrelevant. What is important
|
|
is that a disk cannot be used unless it has been formatted.</P
|
|
><P
|
|
>The terminology is a bit confusing here: in MS-DOS and MS
|
|
Windows, the word formatting is used to cover also the process of
|
|
creating a filesystem (which will be discussed below). There, the
|
|
two processes are often combined, especially for floppies. When the
|
|
distinction needs to be made, the real formatting is called
|
|
<I
|
|
CLASS="GLOSSTERM"
|
|
>low-level formatting</I
|
|
>, while making the
|
|
filesystem is called <I
|
|
CLASS="GLOSSTERM"
|
|
>high-level formatting</I
|
|
>
|
|
.
|
|
In UNIX circles, the two are called formatting and making a
|
|
filesystem, so that's what is used in this book as well.</P
|
|
><P
|
|
>For IDE and some SCSI disks the formatting is actually
|
|
done at the factory and doesn't need to be repeated; hence most
|
|
people rarely need to worry about it. In fact, formatting a hard
|
|
disk can cause it to work less well, for example because a disk
|
|
might need to be formatted in some very special way to
|
|
allow automatic bad sector replacement to work.</P
|
|
><P
|
|
>Disks that need to be or can be formatted often require a
|
|
special program anyway, because the interface to the formatting
|
|
logic inside the drive is different from drive to drive. The
|
|
formatting program is often either on the controller BIOS, or is
|
|
supplied as an MS-DOS program; neither of these can easily
|
|
be used from within Linux.</P
|
|
><P
|
|
>During formatting one might encounter bad spots on the
|
|
disk, called <I
|
|
CLASS="GLOSSTERM"
|
|
>bad blocks</I
|
|
>
|
|
or <I
|
|
CLASS="GLOSSTERM"
|
|
>bad sectors</I
|
|
>.
|
|
These are sometimes handled by the drive
|
|
itself, but even then, if more of them develop, something needs to
|
|
be done to avoid using those parts of the disk. The logic to do
|
|
this is built into the filesystem; how to add the information into
|
|
the filesystem is described below. Alternatively, one might create
|
|
a small partition that covers just the bad part of the disk; this
|
|
approach might be a good idea if the bad spot is very large, since
|
|
filesystems can sometimes have trouble with very large bad areas.</P
|
|
><P
|
|
>Floppies are formatted with <B
|
|
CLASS="COMMAND"
|
|
>fdformat</B
|
|
>
|
|
. The
|
|
floppy device file to use is given as the parameter. For example,
|
|
the following command would format a high density, 3.5 inch floppy
|
|
in the first floppy drive:
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
> <TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
> <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>fdformat /dev/fd0H1440</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Double-sided, 80 tracks, 18 sec/track. Total capacity
|
|
1440 kB.</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Formatting ... done</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Verifying ... done</TT
|
|
>
|
|
<TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
Note that if you want to use an autodetecting device (e.g.,
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/dev/fd0</TT
|
|
>),
|
|
you <EM
|
|
>must</EM
|
|
> set
|
|
the parameters of the device with <B
|
|
CLASS="COMMAND"
|
|
>setfdprm</B
|
|
>
|
|
first.
|
|
To achieve the same effect as above, one would have to do the
|
|
following:
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
> <TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
> <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>setfdprm /dev/fd0 1440/1440</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
> <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>fdformat /dev/fd0</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Double-sided, 80 tracks, 18 sec/track. Total capacity
|
|
1440 KB.</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Formatting ... done</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Verifying ... done</TT
|
|
>
|
|
<TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
It is usually more convenient to choose the correct device file that
|
|
matches the type of the floppy. Note that it is unwise to format
|
|
floppies to contain more information than what they are
|
|
designed for.</P
|
|
><P
|
|
><B
|
|
CLASS="COMMAND"
|
|
>fdformat</B
|
|
>also validate the floppy,
|
|
i.e., check it for bad blocks. It will try a bad block several
|
|
times (you can usually hear this, the drive noise changes
|
|
dramatically). If the floppy is only marginally bad (due to dirt on
|
|
the read/write head, some errors are false signals),
|
|
<B
|
|
CLASS="COMMAND"
|
|
>fdformat</B
|
|
> won't complain, but a real error will
|
|
abort the validation process. The kernel will print log messages for
|
|
each I/O error it finds; these will go to the console or, if
|
|
<B
|
|
CLASS="COMMAND"
|
|
>syslog</B
|
|
> is being used, to the file
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/var/log/messages</TT
|
|
>.
|
|
<B
|
|
CLASS="COMMAND"
|
|
>fdformat</B
|
|
>
|
|
itself won't tell where the error is (one usually doesn't care,
|
|
floppies are cheap enough that a bad one is automatically thrown
|
|
away).
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
> <TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
> <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>fdformat /dev/fd0H1440</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Double-sided, 80 tracks, 18 sec/track. Total capacity
|
|
1440 KB.</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Formatting ... done</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>Verifying ... read: Unknown error</TT
|
|
>
|
|
<TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
The <B
|
|
CLASS="COMMAND"
|
|
>badblocks</B
|
|
> command can be used to search any
|
|
disk or partition for bad blocks (including a floppy). It does not
|
|
format the disk, so it can be used to check even existing
|
|
filesystems. The example below checks a 3.5 inch floppy with two
|
|
bad blocks.
|
|
|
|
<TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
> <TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
> <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>badblocks /dev/fd0H1440 1440</B
|
|
></TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>718</TT
|
|
>
|
|
<TT
|
|
CLASS="COMPUTEROUTPUT"
|
|
>719</TT
|
|
>
|
|
<TT
|
|
CLASS="PROMPT"
|
|
>$</TT
|
|
>
|
|
</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
|
|
<B
|
|
CLASS="COMMAND"
|
|
>badblocks</B
|
|
> outputs the block numbers of the bad
|
|
blocks it finds. Most filesystems can avoid such bad blocks. They
|
|
maintain a list of known bad blocks, which is initialized when the
|
|
filesystem is made, and can be modified later. The initial search
|
|
for bad blocks can be done by the <B
|
|
CLASS="COMMAND"
|
|
>mkfs</B
|
|
>
|
|
command
|
|
(which initializes the filesystem), but later checks should be done
|
|
with <B
|
|
CLASS="COMMAND"
|
|
>badblocks</B
|
|
> and the new blocks should be added
|
|
with <B
|
|
CLASS="COMMAND"
|
|
>fsck</B
|
|
>. We'll describe
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mkfs</B
|
|
>
|
|
and <B
|
|
CLASS="COMMAND"
|
|
>fsck</B
|
|
> later.</P
|
|
><P
|
|
>Many modern disks automatically notice bad blocks, and attempt
|
|
to fix them by using a special, reserved good block instead. This is
|
|
invisible to the operating system. This feature should be
|
|
documented in the disk's manual, if you're curious if it is
|
|
happening. Even such disks can fail, if the number of bad blocks
|
|
grows too large, although chances are that by then the disk
|
|
will be so rotten as to be unusable.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="tapes.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="partitions.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Tapes</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="disk-usage.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Partitions</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |