File: formatting.html

package info (click to toggle)
sysadmin-guide 0.9-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 944 kB
  • ctags: 1
  • sloc: makefile: 5
file content (489 lines) | stat: -rw-r--r-- 9,231 bytes parent folder | download
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<!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
>