summaryrefslogtreecommitdiff
path: root/sag-0.6.1-www/Invisible/sag-0.6/node34.html
blob: 881fcbc25188e419be7fb94a33c65a89a43fccd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<HTML>
<HEAD>
<TITLE>Formatting</TITLE>
<META NAME="description" CONTENT="Formatting">
<META NAME="keywords" CONTENT="sag">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<LINK REL=STYLESHEET HREF="sag.css">
</HEAD>
<BODY LANG="EN" >
 <A NAME="tex2html740" HREF="node35.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html738" HREF="node28.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html732" HREF="node33.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html742" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html743" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html741" HREF="node35.html">Partitions</A>
<B>Up:</B> <A NAME="tex2html739" HREF="node28.html">Using Disks and Other </A>
<B> Previous:</B> <A NAME="tex2html733" HREF="node33.html">Tapes</A>
<BR> <P>
<H1><A NAME="SECTION00560000000000000000">Formatting</A></H1>
<P>
	<b>Formatting</b> 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>
	The terminology is a bit confusing here: in MS-DOS, 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 <b>low-level formatting</b>, while making the filesystem
	is called <b>high-level formatting</b>.  In UNIX circles,
	the two are called formatting and making a filesystem, so
	that's what is used in this book as well.
<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>
	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>
	During formatting one might encounter bad spots on the disk,
	called <b>bad blocks</b> or <b>bad sectors</b>.  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>
	Floppies are formatted with <tt>fdformat</tt><A NAME="1489">&#160;</A>.  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:
		<BLOCKQUOTE> <TT>
<code>$</code> <I>fdformat /dev/fd0H1440</I> <BR> 
<code>Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.</code> <BR> 
<code>Formatting ... done</code> <BR> 
<code>Verifying ... done</code> <BR> 
<code>$ </code>
		</TT></BLOCKQUOTE>
	Note that if you want to use an autodetecting device (e.g.,
	<tt>/dev/fd0</tt><A NAME="1491">&#160;</A>), you <EM>must</EM> set the parameters of the device
	with <tt>setfdprm</tt><A NAME="1493">&#160;</A> first.  To achieve the same effect as
	above, one would have to do the following:
		<BLOCKQUOTE> <TT>
<code>$</code> <I>setfdprm /dev/fd0 1440/1440</I> <BR> 
<code>$</code> <I>fdformat /dev/fd0</I> <BR> 
<code>Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.</code> <BR> 
<code>Formatting ... done</code> <BR> 
<code>Verifying ... done</code> <BR> 
<code>$ </code>
		</TT></BLOCKQUOTE>
	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>
	<tt>fdformat</tt><A NAME="1495">&#160;</A> will 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), <tt>fdformat</tt><A NAME="1497">&#160;</A> 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 <tt>syslog</tt><A NAME="1499">&#160;</A>
	is being used, to the file <tt>/usr/adm/messages</tt><A NAME="1501">&#160;</A>.  <tt>fdformat</tt><A NAME="1503">&#160;</A>
	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).
		<BLOCKQUOTE> <TT>
<code>$</code> <I>fdformat /dev/fd0H1440</I> <BR> 
<code>Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.</code> <BR> 
<code>Formatting ... done</code> <BR> 
<code>Verifying ... read: Unknown error</code> <BR> 
<code>$ </code>
		</TT></BLOCKQUOTE>
<P>
	The <tt>badblocks</tt><A NAME="1505">&#160;</A> 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.
		<BLOCKQUOTE> <TT>
<code>$</code> <I>badblocks /dev/fd0H1440 1440</I> <BR> 
<code>718</code> <BR> 
<code>719</code> <BR> 
<code>$ </code>
		</TT></BLOCKQUOTE>
	<tt>badblocks</tt><A NAME="1507">&#160;</A> 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 <tt>mkfs</tt><A NAME="1509">&#160;</A> command (which initializes
	the filesystem), but later checks should be done with
	<tt>badblocks</tt><A NAME="1511">&#160;</A> and the new blocks should be added with
	<tt>fsck</tt><A NAME="1513">&#160;</A>.  We'll describe <tt>mkfs</tt><A NAME="1515">&#160;</A> and <tt>fsck</tt><A NAME="1517">&#160;</A> later.
<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>
<HR><A NAME="tex2html740" HREF="node35.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html738" HREF="node28.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html732" HREF="node33.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html742" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html743" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html741" HREF="node35.html">Partitions</A>
<B>Up:</B> <A NAME="tex2html739" HREF="node28.html">Using Disks and Other </A>
<B> Previous:</B> <A NAME="tex2html733" HREF="node33.html">Tapes</A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sat Nov 15 02:32:11 EET 1997</I>
</ADDRESS>
</BODY>
</HTML>