aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/articles/formatting-media/article.sgml
blob: 289e384c83d6aa156348bb5f56d008f90857bff9 (plain) (blame)
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
<!DOCTYPE BOOK PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
<!-- $Id: article.sgml,v 1.4 1997-11-28 21:48:46 jfieber Exp $ -->
<book>

<bookinfo>
<bookbiblio>
<title>Formatting Media For Use With FreeBSD 2.2-RELEASE</title>
<subtitle>A Tutorial</subtitle>

<authorgroup>
<author>
<firstname>Doug</firstname>
<surname>White</surname>
<affiliation>
<address><email>dwhite@resnet.uoregon.edu</email></address>
</affiliation>
</author>
</authorgroup>

<pubdate>March 1997</pubdate>
<abstract><para>This document describes how to slice, partition, and
format hard disk drives and similar media for use with FreeBSD.  The
examples given have been tested under FreeBSD 2.2-GAMMA and may work
for other releases. </para>
</abstract>
</bookbiblio>
</bookinfo>

<chapter>
<title>Introduction & Definitions</title>

<sect1>
<title>Overview</title>
<para>Successfully adding disks to an existing system is the mark of an
experienced system administrator.  Slicing, partitioning, and adding
disks requires a careful dance of proper command and name syntax.  One
slipped finger and an entire disk could disappear in seconds.  This
document is written in an attempt to simplify this process and avoid
accidents.  Thankfully, enhancements to existing tools (notably
sysinstall) have greatly improved this process in recent releases of
FreeBSD.  </para>

<para>There are two possible modes of disk formatting:
<itemizedlist> 

<listitem><para><firstterm>compatibility mode</firstterm>: Arranging a
disk so that it has a slice table for use with other operating
systems.</para> </listitem>

<listitem><para><firstterm>dangerously dedicated mode</firstterm>:
Formatting a disk with no slice table.  This makes the process of
adding disks easier, however non-FreeBSD operating systems may not
accept the disk. </para> </listitem> 
</itemizedlist> 
</para>

<para>For most cases, dedicated mode is the easiest to set up and use
in existing systems, as a new disk is usually dedicated entirely to
FreeBSD.  However, compatibility mode insures optimum interoperability
with future installations at a cost of increased complexity.</para>

<para>In addition to selecting the mode, two methods of slicing the
disk are available.  One is using the system installation tool
<command>/stand/sysinstall</command>.  2.1.7-RELEASE and later
versions of <command>sysinstall</command> contain code to ease setup
of disks during normal system operation, mainly allowing access to the
Label and Partition editors and a Write feature which will update just
the selected disk and slice without affecting other disks.  The other
method is running the tools manually from a root command line.  For
dangerously dedicated mode, only three or four commands are involved
while <command>sysinstall</command> requires some manipulation.</para>
</sect1>
<sect1>
<title>Definitions</title>

<para>UNIX disk management over the centuries has invented many new
definitions for old words.  The following glossary covers the
definitions used in this document and (hopefully) for FreeBSD in
general.  </para>

<!-- I'm tempted to use GLOSSARY here but will resort to a list for
now. -->

<itemizedlist>
<listitem><para>compatibility mode:  Arranging a disk so that it has a slice
table for use with other operating systems.  Oppose dangerously
dedicated mode.</para></listitem>

<listitem><para>dangerously dedicated mode:  Formatting a disk with no slice
table.  This makes the process of adding disks easier, however
non-FreeBSD operating systems may not accept the disk.  Oppose
compatibility mode.</para></listitem>

<listitem><para>disk:   A circular disc,  covered with magnetic or similarly
manipulable material, spun by a motor under a head.  Data is stored on
the disk by changing the pattern of magnetism on the disc, which can
be later read.  Hard disks, CD-ROMs, Magneto-optical,and Zip/Jaz
removables are examples of disks.</para></listitem>

<listitem><para>slice: A division of a disk.  Up to four slices are permitted on one
disk in the PC standard.  Slices are composed of contiguous sectors.
Slices are recorded in a <quote>slice table</quote> used by the system BIOS to
locate bootable partitions.  The slice table is usually called the
Partition Table in DOS parlance.  Maintained by the fdisk utility.</para></listitem>

<listitem><para>partition: A division of a slice.  Usually used in reference
to divisions of the FreeBSD slice of a disk.  Each filesystem and swap
area on a disk resides in a partition.  Maintained using the disklabel
utility.</para></listitem>
	
<listitem><para>sector:  Smallest subdivision of a disk.  One sector usually
represents 512 bytes of data.</para></listitem>

</itemizedlist>
</sect1>

<sect1>
<title>Warnings & Pitfalls</title>

<para>Building disks is not something to take lightly.  It is quite possible
to destroy the contents of other disks in your system if the proper 
precautions are not taken.</para>

<para><emphasis>Check your work carefully.</>  It is very simple to destroy
the incorrect disk when working with these commands.  When
in doubt consult the kernel boot output for the proper device.</para>

<para>Needless to say, we are not responsible for any damage to any data 
or hardware that you may experience.  You work at your own risk!</para>

</sect1>

<sect1>
<title>Zip, Jaz, and Other Removables</title>

<para>Removable disks can be formatted in the same way as normal hard
disks.  It is essential to have the disk drive connected to the system
and a disk placed in the drive during startup, so the kernel can
determine the drive's geometry.  Check the <command>dmesg</command>
output and make sure your device and the disk's size is listed.  If
the kernel reports 
<informalexample>
<screen>
Can't get the size
</screen>
</informalexample>
then the disk was not in the drive.  In this case, you will need to restart the
machine before attempting to format disks.
</para>
</sect1>

</chapter>
<chapter>
<title>Formatting Disks in Dedicated Mode</title>

<sect1>
<title>Introduction</title>

<para>This section details how to make disks that are totally dedicated to
FreeBSD.  Remember, dedicated mode disks cannot be booted by the PC
architecture.</para>

</sect1>
<sect1>
<title>Making Dedicated Mode Disks using Sysinstall</title>

<para><command>/stand/sysinstall</command>, the system installation
utility, has been expanded in recent versions to make the process of
dividing disks properly a less tiring affair.  The fdisk and disklabel
editors built into sysinstall are GUI tools that remove much of the
confusion from slicing disks.  For FreeBSD versions 2.1.7 and later,
this is perhaps the simplest way to slice disks.</para>

<orderedlist>
<listitem><para>Start sysinstall as root by typing 
<informalexample>
<screen><userinput>/stand/sysinstall</userinput></screen>
</informalexample> 
from the command prompt.</para></listitem>

<listitem><para>Select <command>Index</command>.</para></listitem>
<listitem><para>Select <command>Partition</command>.</para></listitem>
<listitem><para>Select the disk to edit with arrow keys and
<keycap>SPACE</keycap>.</para>
</listitem>
<listitem><para>If you are using this entire disk for FreeBSD, select
<command>A</command>.</para></listitem> 
<listitem><para>When asked: 
<informalexample>
<screen>
Do you want to do this with a true partition entry so as to remain
cooperative with any future possible operating systems on the
drive(s)?
</screen>
</informalexample>answer <command>No</command>.</para></listitem>
<listitem><para>When asked if you still want to do this, answer
<command>Yes</command>.</para></listitem> 
<listitem><para>Select <command>Write</command>.</para></listitem>
<listitem><para>When warned about Writing on installed systems, answer
<command>Yes</command>.</para></listitem> 
<listitem><para><command>Quit</command>the FDISK Editor and
<keycap>ESCAPE</keycap> back to the Index menu.</para></listitem>
<listitem><para>Select <command>Label</command> from the Index
menu.</para></listitem>  
<listitem><para>Label as desired.  For a single partition, enter
<command>C</command> to Create a partition, accept the
default size, partition type Filesystem, and a mountpoint (which isn't
used).</para></listitem> 
<listitem><para>Enter <command>W</command> when done and confirm to
continue.  The filesystem will be newfs'd for you, unless you select 
otherwise (for news partitions you'll want to do this!).  You'll get
the error: 
<informalexample>
<screen>Error mounting /mnt/dev/wd2s1e on /mnt/blah : No such file or directory </screen>
</informalexample>
Ignore.
</para></listitem>
<listitem><para>Exit out by repeatedly pressing <keycap>ESCAPE</keycap>.</para></listitem>
</orderedlist>

</sect1>
<sect1>
<title>Making Dedicated Mode Disks Using the Command Line</title>


<para>Execute the following commands, replacing wd2 with the disk
name.  Lines beginning with # are comments. </para>
<informalexample>
<screen>
<userinput>  
        dd if=/dev/zero of=/dev/rwd2 count=2
        disklabel /dev/rwd2 | disklabel -B -R -r wd2 /dev/stdin
        # We only want one partition, so using slice 'c' should be fine:
        newfs /dev/rwd2c
</userinput>
</screen>
</informalexample>

<para>	If you need to edit the disklabel to create multiple
partitions (such as swap), use the following: </para>
        
<informalexample>
<screen>
<userinput>
        dd if=/dev/zero of=/dev/rwd2 count=2
        disklabel /dev/r$d > /tmp/label
        # Edit disklabel to add partitions:
        vi /tmp/label
        disklabel -B -R -r wd2 /tmp/label
        # newfs partitions appropriately
</userinput>
</screen>
</informalexample>

<para>Your disk is now ready for use.</para>

</sect1>
</chapter>

<chapter>
<title>Making Compatibility Mode Disks</title>

<sect1>
<title>Introduction</title>
<para>The command line is the easiest way to make dedicated disks, and
the worst way to make compatibility disks.  The command-line fdisk
utility requires higher math skills and an in-depth understanding of
the slice table, which is more than most people want to deal with.
Use sysinstall for compatibility disks, as described below.</para>

</sect1>
<sect1>

<title>Making Compatibility Mode Disks Using Sysinstall</title>

<orderedlist>
<listitem><para>Start sysinstall as root by typing 
<informalexample>
<screen><userinput>/stand/sysinstall</></screen>
</informalexample> 
from the command prompt.</para></listitem>

<listitem><para>Select <command>Index</command>.</para> </listitem>
<listitem><para>Select <command>Partition</command>.</para></listitem>
<listitem><para>Select the disk to edit with arrow keys and
<keycap>SPACE</keycap>.
</para></listitem>
<listitem><para>If you are using this entire disk for FreeBSD, select
<command>A</command>.</para></listitem> 

<listitem><para>When asked: 
<informalexample>
<screen>
Do you want to do this with a true partition entry so as to remain
cooperative with any future possible operating systems on the
drive(s)?
</screen>
</informalexample> answer <command>yes</command>.</para></listitem>
<listitem><para>Select <command>Write</command>.</para></listitem>
<listitem><para>When asked to install the boot manager, select None with
<keycap>SPACE</keycap> then hit <keycap>ENTER</keycap> for OK.</para></listitem>
<listitem><para><command>Quit</command> the FDISK Editor.</para></listitem>
<listitem><para>You'll be asked about the boot manager, select
<command>None</command> 
again. </para></listitem> 
<listitem><para>Select <command>Label</command> from the Index
menu.</para></listitem>  
<listitem><para>Label as desired.  For a single partition, accept the
default size, type filesystem, and a mountpoint (which isn't
used).</para></listitem> 
<listitem><para>The filesystem will be newfs'd for you, unless you select otherwise (for news partitions you'll want to do this!).  You'll get the error:
<informalexample>
<screen>
Error mounting /mnt/dev/wd2s1e on /mnt/blah : No such file or directory </screen> 
</informalexample>
Ignore.
</para></listitem>
<listitem><para>Exit out by repeatedly pressing <keycap>ESCAPE</keycap>.</para></listitem>
</orderedlist>

<para>Your new disk is now ready for use.</para>

</sect1>
</chapter>

<chapter>
<title>Other Disk Operations</title>
<sect1>
<title>Adding Swap Space</title>

<para>As a system grows, it's need for swap space can also grow.
Although adding swap space to existing disks is very difficult, a new
disk can be partitioned with additional swap space.  </para>

<para>To add swap space when adding a disk to a system:
<orderedlist>
<listitem><para>When partitioning the disk, edit the disklabel and
allocate the amount of swap space to add in partition `b' and the
remainder in another partition, such as `a' or `e'.  The size is given
in 512 byte blocks.  </para></listitem>
<listitem><para>When newfsing the drive, do NOT newfs the `c'
partition.  Instead, newfs the partition where the non-swap space
lies.</para></listitem> 
<listitem><para>Add an entry to <filename>/etc/fstab</filename> as follows:
<informalexample>
<programlisting>
/dev/wd0b                       none            swap    sw 0 0
</programlisting>
</informalexample>
Change /dev/wd0b to the device of the newly added
space.</para></listitem>
<listitem><para>To make the new space immediately available, use the
<command>swapon</command> command.
<informalexample>
<screen>
<userinput>
$ swapon /dev/sd0b
</userinput>
swapon:  added /dev/sd0b as swap space
</screen>
</informalexample>
</para></listitem>
</orderedlist>
</para>
</sect1>

<sect1>
<title>Copying the Contents of Disks</title>
<!-- Should have specific tag -->
<para>Submitted By:  Renaud Waldura (<email>renaud@softway.com</email>) </para>

<para>To move file from your original base disk to the fresh new one,
do:
<informalexample>
<screen>
<userinput>
mount /dev/wd2 /mnt
pax -r -w -p e /usr/home /mnt
umount /mnt
rm -rf /usr/home/*
mount /dev/wd2 /usr/home
</userinput>
</screen>
</informalexample>
</para>
</sect1>

<sect1>
<title>Creating Striped Disks using CCD</title>
<para>Commands Submitted By: Stan Brown (<email>stanb@awod.com</email>) </para>

<para>
The Concatenated Disk Driver, or CCD, allows you to treat several identical disks as a single disk.
Striping can result in increased disk performance by distributing reads and
writes across the disks.  See the ccd(4) and ccdconfig(4) man pages or the
<ulink URL="http://stampede.cs.berkeley.edu/ccd/">CCD Homepage</ulink> for further details.</para>

<para>To create a new CCD, execute the following commands.  This describes
how to add three disks together; simply add or remove devices as
necessary.  Remember that the disks to be striped must be <emphasis>identical.</></para>

<para>Before executing these commands, make sure you add the line
<userinput>
pseudo-device ccd 4
</userinput>

to your kernel.</para>

<informalexample>
<screen>
<userinput>
cd /dev ; sh MAKDEV ccd0

disklabel -r -w sd0 auto
disklabel -r -w sd1 auto
disklabel -r -w sd2 auto

disklabel -e sd0c # change type to 4.2BSD
disklabel -e sd1c # change type to 4.2BSD
disklabel -e sd2c # change type to 4.2BSD

ccdconfig ccd0 32 0 /dev/sd0c /dev/sd2c /dev/sd2c

newfs /dev/rccd0c
</userinput>
</screen>
</informalexample>

<para>Now you can mount and use your CCD by referencing device /dev/ccd0c.
</para>

</sect1>
</chapter>

<chapter>
<title>Credits</title>



<para>The author would like to thank the following individuals for
their contributions to this project:
<itemizedlist>
<listitem><para>Darryl Okahata
(<email>darrylo@hpnmhjw.sr.hp.com</email>) for his
simple dedicated mode setup documentation which I have used repeatedly
on freebsd-questions.</para></listitem>
<listitem><para>Jordan Hubbard
(<email>jkh@freebsd.org</email>) for making
sysinstall useful for this type of task.</para></listitem>
<listitem><para>John Fieber
(<email>jfieber@indiana.edu</email>) for making
information and examples of the DocBook DTD on which this document is
based.</para></listitem>
<listitem><para>Greg Lehey (<email>grog@freebsd.org</email>) for checking my 
work and pointing out inaccuracies, as well as miscellaneous support.
</para></listitem>
</itemizedlist>
</para>

</chapter>



</book>