aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/disks/chapter.sgml
blob: 89d197ee3a383cb7c8007e55bb3fe2f4ed169c0d (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
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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->

<chapter id="disks">
  <title>Storage</title>

  <sect1 id="disks-synopsis">
    <title>Synopsis</title>


    <para>This chapter covers the use of disks in FreeBSD.  This
      includes memory-backed disks, network-attached disks, and
      standard SCSI/IDE storage devices.</para>

    <para>After reading this chapter, you will know:</para>
    <itemizedlist>
      <listitem><para>The terminology FreeBSD uses to describe the
      organization of data on a physical disk (partitions and slices).</para>
      </listitem>
      <listitem><para>How to mount and unmount filesystems.</para>
      </listitem>
      <listitem><para>How to add additional hard disks to your system.</para>
      </listitem>
      <listitem><para>How to setup virtual filesystems, such as memory
      disks.</para></listitem>
      <listitem>
	<para>How to use quotas to limit disk space usage.</para>
      </listitem>
      <listitem>
	<para>How to create and burn CDs and DVDs on FreeBSD.</para>
      </listitem>
      <listitem>
        <para>The various storage media options for backups.</para>
      </listitem>
      <listitem>
        <para>How to use backup programs available under FreeBSD.</para>
      </listitem>
      <listitem>
        <para>How to backup to floppy disks.</para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 id="disks-naming">
    <title>Device Names</title>

    <para>The following is a list of physical storage devices
      supported in FreeBSD, and the device names associated with
      them.</para>

    <table id="disk-naming-physical-table">
      <title>Physical Disk Naming Conventions</title>

      <tgroup cols="2">
	<thead>
	  <row>
	    <entry>Drive type</entry>
	    <entry>Drive device name</entry>
	  </row>
	</thead>
	<tbody>
	  <row>
	    <entry>IDE hard drives</entry>
	    <entry><literal>ad</literal>
	  </row>
	  <row>
	    <entry>IDE CDROM drives</entry>
	    <entry><literal>acd</literal>
	  </row>
	  <row>
	    <entry>SCSI hard drives and USB Mass storage devices</entry>
	    <entry><literal>da</literal>
	  </row>
	  <row>
	    <entry>SCSI CDROM drives</entry>
	    <entry><literal>cd</literal></entry>
	  </row>
	  <row>
	    <entry>Assorted non-standard CDROM drives</entry>
	    <entry><literal>mcd</literal> for Mitsumi CD-ROM,
	      <literal>scd</literal> for Sony CD-ROM,
	      <literal>matcd</literal> for Matsushita/Panasonic CD-ROM
	    </entry>
	  </row>
	  <row>
	    <entry>Floppy drives</entry>
	    <entry><literal>fd</literal></entry>
	  </row>
	  <row>
	    <entry>SCSI tape drives</entry>
	    <entry><literal>sa</literal>
            </row>
	  <row>
	    <entry>IDE tape drives</entry>
	    <entry><literal>ast</literal>
	  </row>
	  <row>
	    <entry>Flash drives</entry>
	    <entry><literal>fla</literal> for DiskOnChip Flash device
	  </row>
	  <row>
	    <entry>RAID drives</entry>
	    <entry><literal>myxd</literal> for Mylex, and
	      <literal>amrd</literal> for AMI MegaRAID,
	      <literal>idad</literal> for Compaq Smart RAID.
	  </row>
	</tbody>
      </tgroup>
    </table>
  </sect1>
    
  <sect1 id="disks-adding">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>David</firstname>
	  <surname>O'Brien</surname>
	  <contrib>Originally contributed by </contrib>
	</author>
      </authorgroup>
      <!-- 26 Apr 1998 -->
    </sect1info>

    <title>Adding Disks</title>

    <indexterm>
      <primary>disks</primary>
      <secondary>adding</secondary>
    </indexterm>

    <para>Lets say we want to add a new SCSI disk to a machine that
      currently only has a single drive.  First turn off the computer
      and install the drive in the computer following the instructions
      of the computer, controller, and drive manufacturer.  Due to the
      wide variations of procedures to do this, the details are beyond
      the scope of this document.</para>

    <para>Login as user <username>root</username>.  After you have installed the
      drive, inspect <filename>/var/run/dmesg.boot</filename> to ensure the new
      disk was found.  Continuing with our example, the newly added drive will
      be <devicename>da1</devicename> and we want to mount it on
      <filename>/1</filename> (if you are adding an IDE drive, the device name
      will be <devicename>wd1</devicename> in pre-4.0 systems, or
      <devicename>ad1</devicename> in most 4.X systems).</para>

    <indexterm><primary>partitions</primary></indexterm>
    <indexterm><primary>slices</primary></indexterm>
    <indexterm>
      <primary><command>fdisk</command></primary>
    </indexterm>

    <para>Because FreeBSD runs on IBM-PC compatible computers, it must
      take into account the PC BIOS partitions.  These are different
      from the traditional BSD partitions.  A PC disk has up to four
      BIOS partition entries.  If the disk is going to be truly
      dedicated to FreeBSD, you can use the
      <emphasis>dedicated</emphasis> mode.  Otherwise, FreeBSD will
      have to live within one of the PC BIOS partitions.  FreeBSD
      calls the PC BIOS partitions <emphasis>slices</emphasis> so as
      not to confuse them with traditional BSD partitions.  You may
      also use slices on a disk that is dedicated to FreeBSD, but used
      in a computer that also has another operating system installed.
      This is to not confuse the <command>fdisk</command> utility of
      the other operating system.</para>

    <para>In the slice case the drive will be added as
      <filename>/dev/da1s1e</filename>.  This is read as: SCSI disk,
      unit number 1 (second SCSI disk), slice 1 (PC BIOS partition 1),
      and <filename>e</filename> BSD partition.  In the dedicated
      case, the drive will be added simply as
      <filename>/dev/da1e</filename>.</para>

    <sect2>
      <title>Using &man.sysinstall.8;</title>
      <indexterm>
        <primary><application>sysinstall</application></primary>
        <secondary>adding disks</secondary>
      </indexterm>
      <indexterm>
	<primary>su</primary>
      </indexterm>
      <procedure>
	<step>
	  <title>Navigating <application>Sysinstall</application></title>

	  <para>You may use <command>/stand/sysinstall</command> to
	    partition and label a new disk using its easy to use menus.
	    Either login as user <username>root</username> or use the
	    <command>su</command> command.  Run
	    <command>/stand/sysinstall</command> and enter the
	    <literal>Configure</literal> menu.  Within the
	    <literal>FreeBSD Configuration Menu</literal>, scroll down and
	    select the <literal>Fdisk</literal> option.</para>
	</step>

	<step>
	  <title><application>fdisk</application> Partition Editor</title>
	  <para>Once inside <application>fdisk</application>, we can type <userinput>A</userinput> to
	    use the entire disk for FreeBSD.  When asked if you want to
	    <quote>remain cooperative with any future possible operating
	      systems</quote>, answer <literal>YES</literal>.  Write the
	    changes to the disk using <userinput>W</userinput>.  Now exit the
	    FDISK editor by typing <userinput>q</userinput>.  Next you will be
	    asked about the Master Boot Record.  Since you are adding a
	    disk to an already running system, choose
	    <literal>None</literal>.</para>
	</step>

	<step>
	  <title>Disk Label Editor</title>
	  <indexterm><primary>BSD partitions</primary></indexterm>

	  <para>Next, you need to exit <application>sysinstall</application>
            and start it again.  Follow the directions above, although this
            time choose the <literal>Label</literal> option. This will
	    enter the <literal>Disk Label Editor</literal>.  This
	    is where you will create the traditional BSD partitions.  A
	    disk can have up to eight partitions, labeled 
	    <literal>a-h</literal>.
	    A few of the partition labels have special uses.  The
	    <literal>a</literal> partition is used for the root partition
	    (<filename>/</filename>).  Thus only your system disk (e.g,
	    the disk you boot from) should have an <literal>a</literal>
	    partition.  The <literal>b</literal> partition is used for
	    swap partitions, and you may have many disks with swap
	    partitions.  The <literal>c</literal> partition addresses the
	    entire disk in dedicated mode, or the entire FreeBSD slice in
	    slice mode.  The other partitions are for general use.</para>

	  <para><application>sysinstall</application>'s Label editor 
	    favors the <literal>e</literal>
	    partition for non-root, non-swap partitions.  Within the
	    Label editor, create a single filesystem by typing
	    <userinput>C</userinput>.  When prompted if this will be a FS
	    (filesystem) or swap, choose <literal>FS</literal> and type in a
	    mount point (e.g, <filename>/mnt</filename>).  When adding a
	    disk in post-install mode, <application>sysinstall</application>
	    will not create entries
	    in <filename>/etc/fstab</filename> for you, so the mount point
	    you specify is not important.</para>

	  <para>You are now ready to write the new label to the disk and
	    create a filesystem on it.  Do this by typing
	    <userinput>W</userinput>.  Ignore any errors from 
	    <application>sysinstall</application> that
	    it could not mount the new partition.  Exit the Label Editor
	    and <application>sysinstall</application> completely.</para>
	</step>

	<step>
	  <title>Finish</title>

	  <para>The last step is to edit <filename>/etc/fstab</filename>
	    to add an entry for your new disk.</para>
	</step>
      </procedure>
    </sect2>

    <sect2>
      <title>Using Command Line Utilities</title>

      <sect3>
	<title>Using Slices</title>

	<para>This setup will allow your disk to work correctly with
	  other operating systems that might be installed on your
	  computer and will not confuse other operating systems' 
	  <command>fdisk</command> utilities.  It is recommended 
	  to use this method for new disk installs.  Only use 
	  <literal>dedicated</literal> mode if you have a good reason 
	  to do so!</para>

	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/rda1 bs=1k count=1</userinput>
&prompt.root; <userinput>fdisk -BI da1</userinput> #Initialize your new disk
&prompt.root; <userinput>disklabel -B -w -r da1s1 auto</userinput> #Label it.
&prompt.root; <userinput>disklabel -e da1s1</userinput> # Edit the disklabel just created and add any partitions.
&prompt.root; <userinput>mkdir -p /1</userinput>
&prompt.root; <userinput>newfs /dev/da1s1e</userinput> # Repeat this for every partition you created.
&prompt.root; <userinput>mount -t ufs /dev/da1s1e /1</userinput> # Mount the partition(s)
&prompt.root; <userinput>vi /etc/fstab</userinput> # Add the appropriate entry/entries to your <filename>/etc/fstab</filename>.</screen>

	<para>If you have an IDE disk, substitute <filename>ad</filename>
	  for <filename>da</filename>.  On pre-4.X systems use
	  <filename>wd</filename>.</para> 
      </sect3>
      
      <sect3>
	<title>Dedicated</title>
	<indexterm><primary>OS/2</primary></indexterm>

	<para>If you will not be sharing the new drive with another operating
	  system, you may use the <literal>dedicated</literal> mode.  Remember
	  this mode can confuse Microsoft operating systems; however, no damage
	  will be done by them.  IBM's OS/2 however, will
	  <quote>appropriate</quote> any partition it finds which it does not
	  understand.</para>
	
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/rda1 bs=1k count=1</userinput>
&prompt.root; <userinput>disklabel -Brw da1 auto</userinput>
&prompt.root; <userinput>disklabel -e da1</userinput>				# create the `e' partition
&prompt.root; <userinput>newfs -d0 /dev/rda1e</userinput>
&prompt.root; <userinput>mkdir -p /1</userinput>
&prompt.root; <userinput>vi /etc/fstab</userinput>				# add an entry for /dev/da1e
&prompt.root; <userinput>mount /1</userinput></screen>
      
	<para>An alternate method is:</para>
      
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/rda1 count=2</userinput>
&prompt.root; <userinput>disklabel /dev/rda1 | disklabel -BrR da1 /dev/stdin</userinput>
&prompt.root; <userinput>newfs /dev/rda1e</userinput>
&prompt.root; <userinput>mkdir -p /1</userinput>
&prompt.root; <userinput>vi /etc/fstab</userinput>					# add an entry for /dev/da1e
&prompt.root; <userinput>mount /1</userinput></screen>
      </sect3>
    </sect2>
  </sect1>

  <sect1 id="disks-virtual">
    <title>Network, Memory, and File-Based Filesystems</title>
    <indexterm><primary>virtual disks</primary></indexterm>
    <indexterm>
      <primary>disks</primary>
      <secondary>virtual</secondary>
    </indexterm>

    <para>Aside from the disks you physically insert into your computer:
      floppies, CDs, hard drives, and so forth; other forms of disks
      are understood by FreeBSD - the <firstterm>virtual
      disks</firstterm>.</para>

    <indexterm><primary>NFS</primary></indexterm>
    <indexterm><primary>Coda</primary></indexterm>
    <indexterm>
      <primary>disks</primary>
      <secondary>memory</secondary>
    </indexterm>
    <para>These include network filesystems such as the <link
	linkend="nfs">Network Filesystem</link> and Coda, memory-based
      filesystems such as <link linkend="disks-md">md</link> and
      file-backed filesystems created by <link
	linkend="disks-vnconfig">vnconfig</link> or 
	<command>mdconfig</command>.</para>

    <sect2 id="disks-vnconfig">
      <title>vnconfig: File-Backed Filesystem</title>
      <indexterm>
        <primary>disks</primary>
        <secondary>file-backed</secondary>
      </indexterm>

      <para>&man.vnconfig.8; configures and enables vnode pseudo-disk
	devices.  A <firstterm>vnode</firstterm> is a representation
	of a file, and is the focus of file activity.  This means that
	&man.vnconfig.8; uses files to create and operate a
	filesystem.  One possible use is the mounting of floppy or CD
	images kept in files.</para>

      <para>To mount an existing filesystem image:</para>

      <example>
	<title>Using vnconfig to mount an Existing Filesystem
	  Image</title>

	<screen>&prompt.root; <userinput>vnconfig vn<replaceable>0</replaceable> <replaceable>diskimage</replaceable></userinput>
&prompt.root; <userinput>mount /dev/vn<replaceable>0</replaceable>c <replaceable>/mnt</replaceable></userinput></screen>
      </example>

      <para>To create a new filesystem image with vnconfig:</para>

      <example>
	<title>Creating a New File-Backed Disk with vnconfig</title>
	
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>newimage</replaceable> bs=1k count=<replaceable>5</replaceable>k</userinput>
5120+0 records in
5120+0 records out
&prompt.root; <userinput>vnconfig -s labels -c vn<replaceable>0</replaceable> <replaceable>newimage</replaceable></userinput>
&prompt.root; <userinput>disklabel -r -w vn<replaceable>0</replaceable> auto</userinput>
&prompt.root; <userinput>newfs vn<replaceable>0</replaceable>c</userinput>
Warning: 2048 sector(s) in last cylinder unallocated
/dev/rvn0c:     10240 sectors in 3 cylinders of 1 tracks, 4096 sectors
        5.0MB in 1 cyl groups (16 c/g, 32.00MB/g, 1280 i/g)
super-block backups (for fsck -b #) at:
 32
&prompt.root; <userinput>mount /dev/vn<replaceable>0</replaceable>c <replaceable>/mnt</replaceable></userinput>
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
/dev/vn0c        4927        1     4532     0%    /mnt</screen>
      </example>
    </sect2>

    <sect2 id="disks-md">
      <title>md: Memory Filesystem</title>
      <indexterm>
        <primary>disks</primary>
        <secondary>memory filesystem</secondary>
      </indexterm>

      <para><devicename>md</devicename> is a simple, efficient means to create memory
	filesystems.</para>

      <para>Simply take a filesystem you have prepared with, for
	example, &man.vnconfig.8;, and:</para>

      <example>
	<title>md Memory Disk</title>

	<screen>&prompt.root; <userinput>dd if=<replaceable>newimage</replaceable> of=/dev/md<replaceable>0</replaceable></userinput>
5120+0 records in
5120+0 records out
&prompt.root; <userinput>mount /dev/md<replaceable>0c</replaceable> <replaceable>/mnt</replaceable></userinput>
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
/dev/md0c        4927        1     4532     0%    /mnt</screen>
      </example>
    </sect2>
  </sect1>
  
  <sect1 id="snapshots">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Tom</firstname>
	  <surname>Rhodes</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
      <!-- 15 JUL 2002 -->
    </sect1info>

    <title>Filesystem Snapshots</title>

    <indexterm>
      <primary>Filesystem Snapshots</primary>
      <secondary>Snapshots</secondary>
    </indexterm>
    
      <para>FreeBSD 5.0 offers a new feature in conjunction with
	<link linkend="soft-updates">Soft Updates</link>: Filesystem snapshots.</para>

      <para>Snapshots allow a user to create an image of specified file
	systems and treat this image as a file.
	Snapshot files must be created in the filesystem that the
	action is performed on, and a user may create no more than 20
	snapshots per filesystem.  Active snapshots are recorded
	in the superblock so they are persistent across unmount and
	remount operations along with system reboots.  When a snapshot
	is no longer required, it can be removed with the standard &man.rm.1;
	command, like regular files.  Snapshots may be removed in any order,
	however all the used space may not be acquired as another snapshot will
	possibly claim some of the blocks that were released.</para>

      <para>During initial creation, the <option>schg</option> flag (see &man.chflags.1; manual page)
	is set on to ensure that not even <username>root</username> can write to the snapshot.
	The &man.unlink.1; command makes an exception for snapshot files,
	however, in which it allows them to be removed even
	though they have the <option>schg</option> flag set, so it is not necessary to
	clear the <option>schg</option> flag before removing a snapshot file.</para>

      <para>Snapshots are created with the &man.mount.8; command.  To place
	a snapshot of <filename>/var</filename> in the file
	<filename>/var/snapshot/snap</filename> use the following
	command:</para>

<screen>&prompt.root; <userinput>mount -u -o snapshot /var/snapshot/snap /var</userinput></screen>

      <para>Once a snapshot has been created, there are several interesting
	things that an administrator can do with them:</para>
	
      <itemizedlist>
	<listitem>
	  <para>Some administrators will use a snapshot file for backup purposes,
	    where the snapshot can be transfered to a CD or tape.</para>
	</listitem>
	
	<listitem>
	  <para>File integrity, &man.fsck.8; may be ran on the snapshot file.
	    Assuming that the filesystem was clean when it was mounted, you
	    should always get a clean (and unchanging) result from running
	    &man.fsck.8; on the snapshot.  This is essentially what the
	    background &man.fsck.8; process does.</para>
	</listitem>
	
	<listitem>
	  <para>Run the &man.dump.8; utility on the snapshot.
	    A dump will be returned that is as consistent with the
	    filesystem as the timestamp of the snapshot.</para>

	  <warning><para>As of this writing &man.dump.8; has not yet
	    been changed to set the <filename>dumpdates</filename> file correctly, so
	    do not use this feature in production until that fix
	    is made.</para></warning>
	</listitem>
	
	<listitem>
	  <para>&man.mount.8; the snapshot as a frozen image of the filesystem.
	    To &man.mount.8; the snapshot
	    <filename>/var/snapshot/snap</filename>:</para>

<screen>&prompt.root; <userinput>mdconfig -a -t vnode -f /var/snapshot/snap -u 4</userinput></screen>
<screen>&prompt.root; <userinput>mount -r /dev/md4 /mnt</userinput></screen>

	</listitem>
      </itemizedlist>

      <para>You can now walk the hierarchy of your frozen <filename>/var</filename>
	filesystem mounted at <filename>/mnt</filename>.  Everything will
	be in the same state it was during the snapshot creation time.
	The only exception being that any earlier snapshots will appear
	as zero length files.  When the use of a snapshot has delimited,
	it can be unmounted with:</para>

<screen>&prompt.root; <userinput>umount /mnt</userinput></screen>
<screen>&prompt.root; <userinput>mdconfig -d -u 4</userinput></screen>

      <para>For more information about <option>softupdates</option> and
	filesystem snapshots, including technical papers, you can visit
	Marshall Kirk McKusick's website at
	<ulink url="http://www.mckusick.com/">http://www.mckusick.com</ulink></para>
  </sect1>
  
  <sect1 id="quotas">
    <title>Filesystem Quotas</title>
    <indexterm>
      <primary>accounting</primary>
      <secondary>disk space</secondary>
    </indexterm>
    <indexterm><primary>disk quotas</primary></indexterm>

    <para>Quotas are an optional feature of the operating system that
      allow you to limit the amount of disk space and/or the number of
      files a user or members of a group may allocate on a per-file
      system basis. This is used most often on timesharing systems where
      it is desirable to limit the amount of resources any one user or
      group of users may allocate.  This will prevent one user or group
      of users from consuming all of the available disk space.</para>

    <sect2>
      <title>Configuring Your System to Enable Disk Quotas</title>

      <para>Before attempting to use disk quotas, it is necessary to make
	sure that quotas are configured in your kernel.  This is done by
	adding the following line to your kernel configuration
	file:</para>

      <programlisting>options QUOTA</programlisting>

      <para>The stock <filename>GENERIC</filename> kernel does not have
	this enabled by default, so you will have to configure, build and
	install a custom kernel in order to use disk quotas.  Please refer
	to <xref linkend="kernelconfig"> for more information on kernel
	configuration.</para>

      <para>Next you will need to enable disk quotas in
	<filename>/etc/rc.conf</filename>.  This is done by adding the
	line:</para>

      <programlisting>enable_quotas="YES"</programlisting>
      <indexterm>
        <primary>disk quotas</primary>
        <secondary>checking</secondary>
      </indexterm>
      <para>For finer control over your quota startup, there is an
	additional configuration variable available. Normally on bootup,
	the quota integrity of each filesystem is checked by the
	<command>quotacheck</command> program.  The
	<command>quotacheck</command> facility insures that the data in
	the quota database properly reflects the data on the filesystem.
	This is a very time consuming process that will significantly
	affect the time your system takes to boot. If you would like to
	skip this step, a variable in <filename>/etc/rc.conf</filename>
	is made available for the purpose:</para>

      <programlisting>check_quotas="NO"</programlisting>

      <para>If you are running FreeBSD prior to 3.2-RELEASE, the
	configuration is simpler, and consists of only one variable.  Set
	the following in your <filename>/etc/rc.conf</filename>:</para>

      <programlisting>check_quotas="YES"</programlisting>

      <para>Finally you will need to edit <filename>/etc/fstab</filename>
	to enable disk quotas on a per-filesystem basis.  This is where
	you can either enable user or group quotas or both for all of your
	filesystems.</para>

      <para>To enable per-user quotas on a filesystem, add the
	<literal>userquota</literal> option to the options field in the
	<filename>/etc/fstab</filename> entry for the filesystem you want
	to enable quotas on.  For example:</para>

      <programlisting>/dev/da1s2g   /home    ufs rw,userquota 1 2</programlisting>

      <para>Similarly, to enable group quotas, use the
	<literal>groupquota</literal> option instead of 
	<literal>userquota</literal>.  To enable both user and
	group quotas, change the entry as follows:</para>

      <programlisting>/dev/da1s2g    /home    ufs rw,userquota,groupquota 1 2</programlisting>

      <para>By default, the quota files are stored in the root directory of
	the filesystem with the names <filename>quota.user</filename> and
	<filename>quota.group</filename> for user and group quotas
	respectively.  See &man.fstab.5; for more
	information.  Even though the &man.fstab.5; manual page says that 
	you can specify
	an alternate location for the quota files, this is not recommended
	because the various quota utilities do not seem to handle this
	properly.</para>

      <para>At this point you should reboot your system with your new
	kernel.  <filename>/etc/rc</filename> will automatically run the
	appropriate commands to  create the initial quota files for all of
	the quotas you enabled in <filename>/etc/fstab</filename>, so
	there is no need to manually create any zero length quota
	files.</para>

      <para>In the normal course of operations you should not be required
	to run the <command>quotacheck</command>,
	<command>quotaon</command>, or <command>quotaoff</command>
	commands manually.  However, you may want to read their manual pages
	just to be familiar with their operation.</para>
    </sect2>

    <sect2>
      <title>Setting Quota Limits</title>
      <indexterm>
        <primary>disk quotas</primary>
        <secondary>limits</secondary>
      </indexterm>

      <para>Once you have configured your system to enable quotas, verify
	that they really are enabled.  An easy way to do this is to
	run:</para>

      <screen>&prompt.root; <userinput>quota -v</userinput></screen>
	  
      <para>You should see a one line summary of disk usage and current
	quota limits for each filesystem that quotas are enabled
	on.</para>

      <para>You are now ready to start assigning quota limits with the
	<command>edquota</command> command.</para>

      <para>You have several options on how to enforce limits on the
	amount of disk space a user or group may allocate, and how many
	files they may create.  You may limit allocations based on disk
	space (block quotas) or number of files (inode quotas) or a
	combination of both.  Each of these limits are further broken down
	into two categories: hard and soft limits.</para>

      <indexterm><primary>hard limit</primary></indexterm>
      <para>A hard limit may not be exceeded.  Once a user reaches his
	hard limit he may not make any further allocations on the file
	system in question.  For example, if the user has a hard limit of
	500 blocks on a filesystem and is currently using 490 blocks, the
	user can only allocate an additional 10 blocks.  Attempting to
	allocate an additional 11 blocks will fail.</para>

      <indexterm><primary>soft limit</primary></indexterm>
      <para>Soft limits, on the other hand, can be exceeded for a limited
	amount of time.  This period of time is known as the grace period,
	which is one week by default.  If a user stays over his or her
	soft limit longer than the grace period, the soft limit will
	turn into a hard limit and no further allocations will be allowed.
	When the user drops back below the soft limit, the grace period
	will be reset.</para>

      <para>The following is an example of what you might see when you run
	the <command>edquota</command> command.  When the
	<command>edquota</command> command is invoked, you are placed into
	the editor specified by the <envar>EDITOR</envar> environment
	variable, or in the <command>vi</command> editor if the
	<envar>EDITOR</envar> variable is not set, to allow you to edit
	the quota limits.</para>

      <screen>&prompt.root; <userinput>edquota -u test</userinput></screen>

      <programlisting>Quotas for user test:
/usr: blocks in use: 65, limits (soft = 50, hard = 75)
        inodes in use: 7, limits (soft = 50, hard = 60)
/usr/var: blocks in use: 0, limits (soft = 50, hard = 75)
        inodes in use: 0, limits (soft = 50, hard = 60)</programlisting>

      <para>You will normally see two lines for each filesystem that has
	quotas enabled.  One line for the block limits, and one line for
	inode limits.  Simply change the value you want updated to modify
	the quota limit.  For example, to raise this user's block limit
	from a soft limit of 50 and a hard limit of 75 to a soft limit of
	500 and a hard limit of 600, change:</para>

      <programlisting>/usr: blocks in use: 65, limits (soft = 50, hard = 75)</programlisting>

      <para>to:</para>

      <programlisting> /usr: blocks in use: 65, limits (soft = 500, hard = 600)</programlisting>

      <para>The new quota limits will be in place when you exit the
	editor.</para>

      <para>Sometimes it is desirable to set quota limits on a range of
	uids.  This can be done by use of the <option>-p</option> option
	on the <command>edquota</command> command.  First, assign the
	desired quota limit to a user, and then run
	<command>edquota -p protouser startuid-enduid</command>.  For
	example, if user <username>test</username> has the desired quota
	limits, the following command can be used to duplicate those quota
	limits for uids 10,000 through 19,999:</para>

      <screen>&prompt.root; <userinput>edquota -p test 10000-19999</userinput></screen>
	  
      <para>For more information see &man.edquota.8;.</para>
    </sect2>

    <sect2>
      <title>Checking Quota Limits and Disk Usage</title>
      <indexterm>
        <primary>disk quotas</primary>
        <secondary>checking</secondary>
      </indexterm>

      <para>You can use either the <command>quota</command> or the
	<command>repquota</command> commands to check quota limits and
	disk usage.  The <command>quota</command> command can be used to
	check individual user or group quotas and disk usage.  A user
	may only examine his own quota, and the quota of a group he
	is a member of. Only the super-user may view all user and group
	quotas.  The
	<command>repquota</command> command can be used to get a summary
	of all quotas and disk usage for filesystems with quotas
	enabled.</para>

      <para>The following is some sample output from the
	<command>quota -v</command> command for a user that has quota
	limits on two filesystems.</para>

      <programlisting>Disk quotas for user test (uid 1002):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
           /usr      65*     50      75   5days       7      50      60
       /usr/var       0      50      75               0      50      60</programlisting>

      <indexterm><primary>grace period</primary></indexterm>
      <para>On the <filename>/usr</filename> filesystem in the above
	example, this user is currently 15 blocks over the soft limit of
	50 blocks and has 5 days of the grace period left.  Note the
	asterisk <literal>*</literal> which indicates that the user is
	currently over his quota limit.</para>

      <para>Normally filesystems that the user is not using any disk
	space on will not show up in the output from the
	<command>quota</command> command, even if he has a quota limit
	assigned for that filesystem.  The <option>-v</option> option
	will display those filesystems, such as the
	<filename>/usr/var</filename> filesystem in the above
	example.</para>
    </sect2>

    <sect2>
      <title>Quotas over NFS</title>
      <indexterm><primary>NFS</primary></indexterm>

      <para>Quotas are enforced by the quota subsystem on the NFS server.
	The &man.rpc.rquotad.8; daemon makes quota information available
	to the &man.quota.1; command on NFS clients, allowing users on
	those machines to see their quota statistics.</para>

      <para>Enable <command>rpc.rquotad</command> in
	<filename>/etc/inetd.conf</filename> like so:</para>

      <programlisting>rquotad/1      dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad</programlisting>

      <para>Now restart <command>inetd</command>:</para>

      <screen>&prompt.root; <userinput>kill -HUP `cat /var/run/inetd.pid`</userinput></screen>
    </sect2>
  </sect1>

  <sect1 id="creating-cds">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Mike</firstname>
	  <surname>Meyer</surname>
	  <contrib>Contributed by </contrib>
	  <!-- mwm@mired.org -->
	</author>
      </authorgroup>
      <!-- Apr 2001 -->
    </sect1info>

    <title>Creating and Using Optical Media (CDs &amp; DVDs)</title>
    <indexterm>
      <primary>CDROMs</primary>
      <secondary>creating</secondary>
    </indexterm>

    <sect2>
      <title>Introduction</title>

      <para>CDs have a number of features that differentiate them from
	conventional disks. Initially, they were not writable by the
	user. They are designed so that they can be read continuously without
	delays to move the head between tracks. They are also much easier
	to transport between systems than similarly sized media were at the
	time.</para>
    
      <para>CDs do have tracks, but this refers to a section of data to
	be read continuously and not a physical property of the disk. To
	produce a CD on FreeBSD, you prepare the data files that are going
	to make up the tracks on the CD, then write the tracks to the
	CD.</para>
    
      <indexterm><primary>ISO 9660</primary></indexterm>
      <indexterm>
        <primary>filesystems</primary>
        <secondary>ISO-9660</secondary>
      </indexterm>
      <para>The ISO 9660 filesystem was designed to deal with these
	differences. It unfortunately codifies filesystem limits that were
	common then. Fortunately, it provides an extension mechanism that
	allows properly written CDs to exceed those limits while still
	working with systems that do not support those extensions.</para>

      <indexterm>
        <primary><filename role="package">sysutils/mkisofs</filename></primary>
      </indexterm>
      <para>The <filename role="package">sysutils/mkisofs</filename>
	program is used to produce a data file containing an ISO 9660 file
	system. It has options that support various extensions, and is
	described below. You can install it with the 
	<filename role="package">sysutils/mkisofs</filename> ports.</para>
    
      <indexterm>
        <primary>CD burner</primary>
        <secondary>ATAPI</secondary>
      </indexterm>
      <para>Which tool to use to burn the CD depends on whether your CD burner
	is ATAPI or something else. ATAPI CD burners use the <command><link
	linkend="burncd">burncd</link></command> program that is part of
	the base system. SCSI and USB CD burners should use
	<command><link linkend="cdrecord">cdrecord</link></command> from
	the <filename role="package">sysutils/cdrtools</filename> port.</para>

      <para><command>burncd</command> has a limited number of
	supported drives. To find out if a drive is supported, see
	<ulink url="http://freebsd.dk/ata/">CD-R/RW supported
	  drives</ulink>.</para>
    </sect2>

    <sect2 id="mkisofs">
      <title>mkisofs</title>

      <para><filename role="package">sysutils/mkisofs</filename> produces an ISO 9660 filesystem
	that is an image of a directory tree in the Unix filesystem name
	space. The simplest usage is:</para>
    
      <screen>&prompt.root; <userinput>mkisofs <option>-o</option> <replaceable>imagefile.iso</replaceable> <replaceable>/path/to/tree</replaceable></userinput></screen>

      <indexterm>
        <primary>filesystems</primary>
        <secondary>ISO-9660</secondary>
      </indexterm>
      <para>This command will create an <replaceable>imagefile</replaceable>
	containing an ISO 9660 filesystem that is a copy of the tree at
	<replaceable>/path/to/tree</replaceable>. In the process, it will
	map the file names to names that fit the limitations of the
	standard ISO 9660 filesystem, and will exclude files that have
	names uncharacteristic of ISO filesystems.</para>
    
      <indexterm>
        <primary>filesystems</primary>
        <secondary>HFS</secondary>
      </indexterm>
      <indexterm>
        <primary>filesystems</primary>
        <secondary>Joliet</secondary>
      </indexterm>
      <para>A number of options are available to overcome those
	restrictions. In particular, <option>-R</option> enables the
	Rock Ridge extensions common to Unix systems, <option>-J</option>
	enables Joliet extensions used by Microsoft systems, and
	<option>-hfs</option> can be used to create HFS filesystems used
	by MacOS.</para>

      <para>For CDs that are going to be used only on FreeBSD systems,
	<option>-U</option> can be used to disable all filename
	restrictions. When used with <option>-R</option>, it produces a
	filesystem image that is identical to the FreeBSD tree you started
	from, though it may violate the ISO 9660 standard in a number of
	ways.</para>

      <indexterm>
        <primary>CDROMs</primary>
        <secondary>creating bootable</secondary>
      </indexterm>    
      <para>The last option of general use is <option>-b</option>. This is
	used to specify the location of the boot image for use in producing an
	<quote>El Torito</quote> bootable CD. This option takes an
	argument which is the path to a boot image from the top of the
	tree being written to the CD. So, given that
	<filename>/tmp/myboot</filename> holds a bootable FreeBSD system
	with the boot image in
	<filename>/tmp/myboot/boot/cdboot</filename>, you could produce the
	image of an ISO 9660 filesystem in
	<filename>/tmp/bootable.iso</filename> like so:</para>

      <screen>&prompt.root; <userinput>mkisofs -U -R -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot</userinput></screen>

      <para>Having done that, if you have <devicename>vn</devicename>
	configured in your kernel, you can mount the filesystem with:</para>

      <screen>&prompt.root; <userinput>vnconfig -e vn0c /tmp/bootable.iso</userinput>
&prompt.root; <userinput>mount -t cd9660 /dev/vn0c /mnt</userinput></screen>

      <para>At which point you can verify that <filename>/mnt</filename>
	and <filename>/tmp/myboot</filename> are identical.</para>

      <para>There are many other options you can use with
	<filename role="package">sysutils/mkisofs</filename> to fine-tune its behavior.  In particular:
	modifications to an ISO 9660 layout and the creation of Joilet
	and HFS discs.  See the	&man.mkisofs.8; manual page for details.</para>
    </sect2>

    <sect2 id="burncd">
      <title>burncd</title>
      <indexterm>
        <primary>CDROMs</primary>
        <secondary>burning</secondary>
      </indexterm>    
      <para>If you have an ATAPI CD burner, you can use the
	<command>burncd</command> command to burn an ISO image onto a
	CD. <command>burncd</command> is part of the base system, installed
	as <filename>/usr/sbin/burncd</filename>.  Usage is very simple, as
	it has few options:</para>
      
      <screen>&prompt.root; <userinput>burncd <option>-f</option> <replaceable>cddevice</replaceable> data <replaceable>imagefile.iso</replaceable> fixate</userinput></screen>

      <para>Will burn a copy of <replaceable>imagefile.iso</replaceable> on
	<replaceable>cddevice</replaceable>. The default device is
	<filename>/dev/acd0c</filename>. See &man.burncd.8; for options to
	set the write speed, eject the CD after burning, and write audio
	data.</para>
    </sect2>

    <sect2 id="cdrecord">
      <title>cdrecord</title>

      <para>If you do not have an ATAPI CD burner, you will have to use
	<command>cdrecord</command> to burn your
	CDs. <command>cdrecord</command> is not part of the base system;
	you must install it from either the port at <filename role="package">sysutils/cdrtools</filename>
	or the appropriate
	package. Changes to the base system can cause binary versions of
	this program to fail, possibly resulting in a
	<quote>coaster</quote>. You should therefore either upgrade the
	port when you upgrade your system, or if you are <link
	linkend="stable">tracking -STABLE</link>, upgrade the port when a
	new version becomes available.</para>
      
      <para>While <command>cdrecord</command> has many options, basic usage
	is even simpler than <command>burncd</command>. Burning an ISO 9660
	image is done with:</para>
      
      <screen>&prompt.root; <userinput>cdrecord <option>dev=</option><replaceable>device</replaceable> <replaceable>imagefile.iso</replaceable></userinput></screen>
      
      <para>The tricky part of using <command>cdrecord</command> is finding
	the <option>dev</option> to use. To find the proper setting, use
	the <option>-scanbus</option> flag of <command>cdrecord</command>,
	which might produce results like this:</para>
      <indexterm>
        <primary>CDROMs</primary>
        <secondary>burning</secondary>
      </indexterm>          
      <screen>&prompt.root; <userinput>cdrecord <option>-scanbus</option></userinput>
Cdrecord 1.9 (i386-unknown-freebsd4.2) Copyright (C) 1995-2000 J&ouml;rg Schilling
Using libscg version 'schily-0.1'
scsibus0:
        0,0,0     0) 'SEAGATE ' 'ST39236LW       ' '0004' Disk
        0,1,0     1) 'SEAGATE ' 'ST39173W        ' '5958' Disk
        0,2,0     2) *
        0,3,0     3) 'iomega  ' 'jaz 1GB         ' 'J.86' Removable Disk
        0,4,0     4) 'NEC     ' 'CD-ROM DRIVE:466' '1.26' Removable CD-ROM
        0,5,0     5) *
        0,6,0     6) *
        0,7,0     7) *
scsibus1:
        1,0,0   100) *
        1,1,0   101) *
        1,2,0   102) *
        1,3,0   103) *
        1,4,0   104) *
        1,5,0   105) 'YAMAHA  ' 'CRW4260         ' '1.0q' Removable CD-ROM
        1,6,0   106) 'ARTEC   ' 'AM12S           ' '1.06' Scanner
        1,7,0   107) *</screen>

      <para>This lists the appropriate <option>dev</option> value for the
	devices on the list. Locate your CD burner, and use the three
	numbers separated by commas as the value for
	<option>dev</option>. In this case, the CRW device is 1,5,0, so the
	appropriate input would be
	<userinput><option>dev</option>=1,5,0</userinput>. There are easier
	ways to specify this value; see &man.cdrecord.1; for
	details. That is also the place to look for information on writing
	audio tracks, controlling the speed, and other things.</para>
    </sect2>

    <sect2>
      <title>Duplicating Audio CDs</title>

      <para>You can duplicate an audio CD by extracting the audio data from
	the CD to a series of files, and then writing these files to a blank
	CD.  The process is slightly different for ATAPI and SCSI
	drives.</para>

      <procedure>
	<title>SCSI drives</title>

	<step>
	  <para>Use <command>cdda2wav</command> to extract the audio.</para>

	  <screen>&prompt.user; <userinput>cdda2wav -v255 -D2,0 -B -Owav</userinput></screen>
	</step>

	<step>
	  <para>Use <command>cdrecord</command> to write the
	    <filename>.wav</filename> files.</para>

	  <screen>&prompt.user; <userinput>cdrecord -v dev=<replaceable>2,0</replaceable> -dao -useinfo  *.wav</userinput></screen>

	  <para>Make sure that <replaceable>2.0</replaceable> is set
	    appropriately, as described in <xref linkend="cdrecord">.</para>
	</step>
      </procedure>

      <procedure>
	<title>ATAPI drives</title>
	
	<step>
	  <para>The ATAPI CD driver makes each track available as
	    <filename>/dev/acd<replaceable>d</replaceable>t<replaceable>n</replaceable></filename>, 
	    where <replaceable>d</replaceable> is the drive number, and
	    <replaceable>n</replaceable> is the track number.  So the first
	    track on the first disk is
	    <filename>/dev/acd0t1</filename>.</para>

	  <para>Make sure the appropriate files exist in
	    <filename>/dev</filename>.</para>
	  
	  <screen>&prompt.root; <userinput>cd /dev</userinput>
&prompt.root; <userinput>sh MAKEDEV acd0t99</userinput></screen>
	</step>

	<step>
	  <para>Extract each track using &man.dd.1;.  You must also use a 
	    specific blocksize when extracting the files.</para>

	  <screen>&prompt.root; <userinput>dd if=/dev/acd0t1 of=track1.cdr bs=2352</userinput>
&prompt.root; <userinput>dd if=/dev/acd0t2 of=track2.cdr bs=2352</userinput>
...
</screen>
	</step>

	<step>
	  <para>Burn the extracted files to disk using
	    <command>burncd</command>.  You must specify that these are audio
	    files, and that <command>burncd</command> should fixate the disk
	    when finished.</para>

	  <screen>&prompt.root; <userinput>burncd -f <replaceable>/dev/acd0c</replaceable> audio track1.cdr track2.cdr <replaceable>...</replaceable> fixate</userinput></screen>
	</step>
      </procedure>
    </sect2>

    <sect2 id="imaging-cd">
      <title>Duplicating Data CDs</title>

      <para>You can copy a data CD to a image file that is
	functionally equivalent to the image file created with
	<filename role="package">sysutils/mkisofs</filename>, and you can use it to duplicate
	any data CD.  The example given here assumes that your CDROM
	device is <devicename>acd0</devicename>.  Substitute your
	correct CDROM device.  A <literal>c</literal> must be appended
	to the end of the device name to indicate the entire partition
	or, in the case of CDROMs, the entire disc.</para>

      <screen>&prompt.root; <userinput>dd if=/dev/acd0c of=file.iso bs=2048</userinput></screen>

      <para>Now that you have an image, you can burn it to CD as
	described above.</para>
    </sect2>

    <sect2 id="mounting-cd">
      <title>Using Data CDs</title>

      <para>Now that you have created a standard data CDROM, you
	probably want to mount it and read the data on it.  By
	default, &man.mount.8; assumes that a filesystem is of type
	<literal>ufs</literal>.  If you try something like:</para>

      <screen>&prompt.root; <userinput>mount /dev/cd0c /mnt</userinput></screen>

      <para>you will get a complaint about <errorname>Incorrect super
	  block</errorname>, and no mount. The CDROM is not a
	  <literal>UFS</literal> filesystem, so attempts to mount it
	  as such will fail.  You just need to tell &man.mount.8; that
	  the filesystem is of type <literal>ISO9660</literal>, and
	  everything will work.  You do this by specifying the
	  <option>-t cd9660</option> option &man.mount.8;. For
	  example, if you want to mount the CDROM device,
	  <devicename>/dev/cd0c</devicename>, under
	  <filename>/mnt</filename>, you would execute:</para>

          <screen>&prompt.root; <userinput>mount -t cd9660 /dev/cd0c /mnt</userinput></screen>
          
      <para>Note that your device name
	(<devicename>/dev/cd0c</devicename> in this example) could be
	different, depending on the interface your CDROM uses. Also,
	the <option>-t cd9660</option> option just executes
	&man.mount.cd9660.8;. The above example could be shortened
	to:</para>

<screen>&prompt.root; <userinput>mount_cd9660 /dev/cd0c /mnt</userinput></screen>

      <para>You can generally use data CDROMs from any vendor in this
	way.  Disks with certain ISO 9660 extensions might behave
	oddly, however.  For example, Joliet disks store all filenames
	in two-byte Unicode characters.  The FreeBSD kernel does not
	speak Unicode (yet!), so non-English characters show up as
	question marks.  (If you are running FreeBSD 4.3 or later, the
	CD9660 driver includes hooks to load an appropriate Unicode
	conversion table on the fly.  Modules for some of the common
	encodings are available via the
	<filename role="package">sysutils/cd9660_unicode</filename> port.)</para>

      <para>Occasionally, you might get <errorname>Device not
	configured</errorname> when trying to mount a CDROM.  This
	usually means that the CDROM drive thinks that there is no
	disk in the tray, or that the drive is not visible on the bus.
	It can take a couple of seconds for a CDROM drive to realize
	that it has been fed, so be patient.</para>

      <para>Sometimes, a SCSI CDROM may be missed because it didn't
	have enough time to answer the bus reset.  If you have a SCSI
	CDROM please add the following option to your kernel
	configuration and <link linkend="kernelconfig-building">rebuild your kernel</link>.</para>

      <programlisting>options SCSI_DELAY=15000</programlisting>

      <para>This tells your SCSI bus to pause 15 seconds during boot,
	to give your CDROM drive every possible chance to answer the
	bus reset.</para>
    </sect2>

    <sect2 id="rawdata-cd">
      <title>Burning Raw Data CDs</title>

      <para>You can choose to burn a file directly to CD, without
	creating an ISO 9660 filesystem.  Some people do this for
	backup purposes.  This runs more quickly than burning a
	standard CD:</para>

      <screen>&prompt.root; <userinput>burncd -f /dev/acd1c -s 12 data archive.tar.gz fixate</userinput></screen>

      <para>In order to retrieve the data burned to such a CD, you
	  must read data from the raw device node:</para>

      <screen>&prompt.root; <userinput>tar xzvf /dev/acd1c</userinput></screen>

      <para>You cannot mount this disk as you would a normal CDROM.
	  Such a CDROM cannot be read under any operating system
	  except FreeBSD.  If you want to be able to mount the CD, or
	  share data with another operating system, you must use
	  <filename role="package">sysutils/mkisofs</filename> as described above.</para>
    </sect2>
  </sect1>
  
  <sect1 id="raid">
    <title>RAID</title>

    <sect2 id="raid-soft">
      <title>Software RAID</title>

      <sect3 id="ccd">
	<sect3info>
	  <authorgroup>
	    <author>
	      <firstname>Christopher</firstname>
	      <surname>Shumway</surname>
	      <contrib>Written by </contrib>
	    </author>
	  </authorgroup>
	  <authorgroup>
	    <author>
	      <firstname>Valentino</firstname>
	      <surname>Vaschetto</surname>
	      <contrib>Marked up by </contrib>
	    </author>
	  </authorgroup>
	</sect3info>

	<title>ccd (Concatenated Disk Configuration)</title>
	<para>When choosing a mass storage solution, the most important
	  factors to consider are speed, reliability, and cost.  It is very
	  rare to have all three in favor, normally a fast, reliable mass
	  storage device is expensive, and to cut back on cost either speed
	  or reliability must be sacrificed.  In designing my system, I
	  ranked the requirements by most favorable to least favorable.  In
	  this situation, cost was the biggest factor.  I needed a lot of
	  storage for a reasonable price.  The next factor, speed, is not
	  quite as important, since most of the usage would be over a one
	  hundred megabit switched Ethernet, and that would most likely be
	  the bottleneck.  The ability to spread the file input/output
	  operations out over several disks would be more than enough speed
	  for this network.  Finally, the consideration of reliability was
	  an easy one to answer.  All of the data being put on this mass
	  storage device was already backed up on CD-R's.  This drive was
	  primarily here for online live storage for easy access, so if a
	  drive went bad, I could just replace it, rebuild the filesystem,
	  and copy back the data from CD-R's.</para>

	<para>To sum it up, I need something that will give me the most
	  amount of storage space for my money.  The cost of large IDE disks
	  are cheap these days.  I found a place that was selling Western
	  Digital 30.7gb 5400 RPM IDE disks for about one-hundred and thirty
	  US dollars.  I bought three of them, giving me approximately
	  ninety gigabytes of online storage.</para>
    
	<sect4 id="ccd-installhw">
	  <title>Installing the Hardware</title>
      
	  <para>I installed the hard drives in a system that already
	    had one IDE disk in as the system disk.  The ideal solution
	    would be for each IDE disk to have its own IDE controller
	    and cable, but without fronting more costs to acquire a dual
	    IDE controller this would not be a possibility.  So, I
	    jumpered two disks as slaves, and one as master.  One went
	    on the first IDE controller as a slave to the system disk,
	    and the other two where slave/master on the secondary IDE
	    controller.</para>
      
	  <para>Upon reboot, the system BIOS was configured to
	    automatically detect the disks attached.  More importantly,
	    FreeBSD detected them on reboot:</para>
      
	  <programlisting>ad0: 19574MB &lt;WDC WD205BA&gt; [39770/16/63] at ata0-master UDMA33
ad1: 29333MB &lt;WDC WD307AA&gt; [59598/16/63] at ata0-slave UDMA33
ad2: 29333MB &lt;WDC WD307AA&gt; [59598/16/63] at ata1-master UDMA33
ad3: 29333MB &lt;WDC WD307AA&gt; [59598/16/63] at ata1-slave UDMA33</programlisting>
      
	  <para>At this point, if FreeBSD does not detect the disks, be
	    sure that you have jumpered them correctly.  I have heard
	    numerous reports with problems using cable select instead of
	    true slave/master configuration.</para>
      
	  <para>The next consideration was how to attach them as part of
	    the filesystem.  I did a little research on &man.vinum.8;
	      (<xref linkend="vinum-vinum">) and
	      &man.ccd.4;.  In this particular configuration, &man.ccd.4;
	    appeared to be a better choice mainly because it has fewer
	    parts.  Less parts tends to indicate less chance of breakage.
	    Vinum appears to be a bit of an overkill for my needs.</para>
	</sect4>
      
	<sect4 id="ccd-setup">
	  <title>Setting up the CCD</title>
      
	  <para><application>CCD</application> allows me to take
	    several identical disks and concatenate them into one
	    logical filesystem.  In order to use
	    <application>ccd</application>, I need a kernel with
	    <application>ccd</application> support built into it.  I
	    added this line to my kernel configuration file and rebuilt
	    the kernel:</para>
      
	  <programlisting>pseudo-device   ccd     4</programlisting>
      
	  <para><application>ccd</application> support can also be
	    loaded as a kernel loadable module in FreeBSD 4.0 or
	    later.</para>
      
	  <para>To set up <application>ccd</application>, first I need
	    to disklabel the disks.  Here is how I disklabeled
	    them:</para>
      
	  <programlisting>disklabel -r -w ad1 auto
disklabel -r -w ad2 auto
disklabel -r -w ad3 auto</programlisting>
      
	  <para>This created a disklabel ad1c, ad2c and ad3c that
	    spans the entire disk.</para>
      
	  <para>The next step is to change the disklabel type.  To do
	    that I had to edit the disklabel:</para>
      
	  <programlisting>disklabel -e ad1
disklabel -e ad2
disklabel -e ad3</programlisting>
      
	  <para>This opened up the current disklabel on each disk
	    respectively in whatever editor the <envar>EDITOR</envar>
	    environment variable was set to, in my case, &man.vi.1;.
	    Inside the editor I had a section like this:</para>
      
	  <programlisting>8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c: 60074784        0    unused        0     0     0   # (Cyl.    0 - 59597)</programlisting>
      
	  <para>I needed to add a new "e" partition for &man.ccd.4; to
	    use. This usually can be copied of the "c" partition, but
	    the <option>fstype</option> must be <userinput>4.2BSD</userinput>.
	    Once I was done,
	    my disklabel should look like this:</para>
      
	  <programlisting>8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c: 60074784        0    unused        0     0     0   # (Cyl.    0 - 59597)
  e: 60074784        0    4.2BSD        0     0     0   # (Cyl.    0 - 59597)</programlisting>
      
	</sect4>
    
	<sect4 id="ccd-buildingfs">
	  <title>Building the Filesystem</title>
      
	  <para>Now that I have all of the disks labeled, I needed to
	    build the <application>ccd</application>.  To do that, I
	    used a utility called &man.ccdconfig.8;.
	    <command>ccdconfig</command> takes several arguments, the
	    first argument being the device to configure, in this case,
	    <devicename>/dev/ccd0c</devicename>.  The device node for
	    <devicename>ccd0c</devicename> may not exist yet, so to
	    create it, perform the following commands:</para>
      
	  <programlisting>cd /dev
sh MAKEDEV ccd0</programlisting>
      
	  <para>The next argument <command>ccdconfig</command> expects
	    is the interleave for the filesystem.  The interleave
	    defines the size of a stripe in disk blocks, normally five
	    hundred and twelve bytes.  So, an interleave of thirty-two
	    would be sixteen thousand three hundred and eighty-four
	    bytes.</para>
      
	  <para>After the interleave comes the flags for
	    <command>ccdconfig</command>.  If you want to enable drive
	    mirroring, you can specify a flag here.  In this
	    configuration, I am not mirroring the
	    <application>ccd</application>, so I left it as zero.</para>
      
	  <para>The final arguments to <command>ccdconfig</command>
	    are the devices to place into the array.  Putting it all
	    together I get this command:</para>
      
	  <programlisting>ccdconfig ccd0 32 0 /dev/ad1e /dev/ad2e /dev/ad3e</programlisting>
      
	  <para>This configures the <application>ccd</application>.
	    I can now &man.newfs.8; the filesystem.</para>
      
	  <programlisting>newfs /dev/ccd0c</programlisting>
      
	</sect4>

	<sect4 id="ccd-auto">
	  <title>Making it all Automatic</title>
      
	  <para>Finally, if I want to be able to mount the 
	    <application>ccd</application>, I need to
	    configure it first.  I write out my current configuration to
	    <filename>/etc/ccd.conf</filename> using the following command:</para>
      
	  <programlisting>ccdconfig -g &gt; /etc/ccd.conf</programlisting>
      
	  <para>When I reboot, the script <command>/etc/rc</command>
	    runs <command>ccdconfig -C</command> if /etc/ccd.conf
	    exists. This automatically configures the
	    <application>ccd</application> so it can be mounted.</para>
      
	  <para>If you are booting into single user mode, before you can
	    <command>mount</command> the <application>ccd</application>, you
	    need to issue the following command to configure the
	    array:</para>
      
	  <programlisting>ccdconfig -C</programlisting>
      
	  <para>Then, we need an entry for the
	    <application>ccd</application> in
	    <filename>/etc/fstab</filename> so it will be mounted at
	    boot time.</para>
      
	  <programlisting>/dev/ccd0c              /media       ufs     rw      2       2</programlisting>
	</sect4>
      </sect3>

      <sect3 id="vinum">
	<title>The Vinum Volume Manager</title>

	<para>The Vinum Volume Manager is a block device driver which
	  implements virtual disk drives.  It isolates disk hardware
	  from the block device interface and maps data in ways which
	  result in an increase in flexibility, performance and
	  reliability compared to the traditional slice view of disk
	  storage.  &man.vinum.8; implements the RAID-0, RAID-1 and
	  RAID-5 models, both individually and in combination.</para>

	<para>See the <xref linkend="vinum-vinum"> for more
	  information about &man.vinum.8;.</para>
      </sect3>
    </sect2>

    <sect2 id="raid-hard">
      <title>Hardware RAID</title>

      <indexterm>
	<primary>RAID</primary>
	<secondary>Hardware</secondary>
      </indexterm>
      <para>FreeBSD also supports a variety of hardware <acronym>RAID</acronym>
        controllers.  In which case the actual <acronym>RAID</acronym> system
	is built and controlled by the card itself.  Using an on-card
	<acronym>BIOS</acronym>, the card will control most of the disk operations
	itself.  The following is a brief setup using a Promise <acronym>IDE RAID</acronym>
	controller.  When this card is installed and the system started up, it will
	display a prompt requesting information.  Follow the on screen instructions
	to enter the cards setup screen.  From here a user should have the ability to
	combine all the attached drives.  When doing this, the disk(s) will look like
	a single drive to FreeBSD.  Other <acronym>RAID</acronym> levels can be setup
	accordingly.
      </para>
    </sect2>
  </sect1>
  
  <sect1 id="backup-basics">
    <title>Backup Programs</title>
    <indexterm><primary>backup software and basics</primary></indexterm>

    <para>The three major backup programs are
	&man.dump.8;,
	&man.tar.1;,
      and
	&man.cpio.1;.</para>
    
    <sect2>
      <title>Dump and Restore</title>
      <indexterm>
        <primary>backup software</primary>
	<secondary>dump / restore</secondary>
      </indexterm>      
      <indexterm><primary><command>dump</command></primary></indexterm>      
      <indexterm><primary><command>restore</command></primary></indexterm>

      <para>The traditional Unix backup programs are
	<command>dump</command> and <command>restore</command>.  They
	operate on the drive as a collection of disk blocks, below the
	abstractions of files, links and directories that are created by
	the filesystems. <command>dump</command> backs up an entire
	filesystem on a device.  It is unable to backup only part of a
	filesystem or a directory tree that spans more than one
	filesystem.  <command>dump</command> does not write files and
	directories to tape, but rather writes the raw data blocks that
	comprise files and directories.</para>

      <note><para>If you use <command>dump</command> on your root directory, you
        would not back up <filename>/home</filename>,
        <filename>/usr</filename> or many other directories since
        these are typically mount points for other filesystems or
        symbolic links into those filesystems.</para></note>

      <para><command>dump</command>has quirks that remain from its early days in
	Version 6 of AT&amp;T Unix (circa 1975).  The default
	parameters are suitable for 9-track tapes (6250 bpi), not the
	high-density media available today (up to 62,182 ftpi).  These
	defaults must be overridden on the command line to utilize the
	capacity of current tape drives.</para>

      <indexterm><primary><filename>rhosts</filename></primary></indexterm>
      <para>It is also possible to backup data across the network to a
        tape drive attached to another computer with <command>rdump</command> and
        <command>rrestore</command>.  Both programs rely upon <command>rcmd</command> and
        <command>ruserok</command> to access the remote tape drive.  Therefore,
        the user performing the backup must have
        <literal>rhosts</literal> access to the remote computer.  The
        arguments to <command>rdump</command> and <command>rrestore</command> must be suitable
        to use on the remote computer.  (e.g. When
        <command>rdump</command>ing from a FreeBSD computer to an
        Exabyte tape drive connected to a Sun called
        <hostid>komodo</hostid>, use: <command>/sbin/rdump 0dsbfu
        54000 13000 126 komodo:/dev/nrsa8 /dev/rda0a
        2>&amp;1</command>) Beware: there are security implications to
        allowing <literal>rhosts</literal> commands.  Evaluate your
        situation carefully.</para>

      <para>It is also possible to use <command>rdump</command> and
        <command>rrestore</command> in a more secure fashion over
        <command>ssh</command>.</para>

      <example>
	<title>Using <command>rdump</command> over <application>ssh</application></title>

	<screen>&prompt.root; <userinput>/sbin/dump -0uan -f - /usr | gzip -2 | ssh1 -c blowfish \
          targetuser@targetmachine.example.com dd of=/mybigfiles/dump-usr-l0.gz</userinput></screen>

      </example>
    </sect2>

    <sect2>
      <title><command>tar</command></title>
      <indexterm>
        <primary>backup software</primary>
        <secondary><command>tar</command></secondary>
      </indexterm>
      
      <para>&man.tar.1; also dates back to Version 6 of AT&amp;T Unix
	(circa 1975).  <command>tar</command> operates in cooperation
	with the filesystem; <command>tar</command> writes files and
	directories to tape. <command>tar</command> does not support the
	full range of options that are available from &man.cpio.1;, but
	<command>tar</command> does not require the unusual command
	pipeline that <command>cpio</command> uses.</para>

      <indexterm><primary><command>tar</command></primary></indexterm>
      <para>Most versions of <command>tar</command> do not support
	backups across the network.  The GNU version of
	<command>tar</command>, which FreeBSD utilizes, supports remote
	devices using the same syntax as <command>rdump</command>.  To
	<command>tar</command> to an Exabyte tape drive connected to a
	Sun called <hostid>komodo</hostid>, use: <command>/usr/bin/tar
	  cf komodo:/dev/nrsa8 . 2>&amp;1</command>.  For versions without
	remote device support, you can use a pipeline and
	<command>rsh</command> to send the data to a remote tape
	drive.</para>

      <screen>&prompt.root; <userinput>tar cf - . | rsh <replaceable>hostname</replaceable> dd of=<replaceable>tape-device</replaceable> obs=20b</userinput></screen>

      <para>If you are worried about the security of backing up over a
	network you should use the <command>ssh</command> command
	instead of <command>rsh</command>.</para>
    </sect2>
    
    <sect2>
      <title><command>cpio</command></title>
      <indexterm>
        <primary>backup software</primary>
        <secondary><command>cpio</command></secondary>
      </indexterm>

      <para>&man.cpio.1; is the original Unix file interchange tape
	program for magnetic media.  <command>cpio</command> has options
	(among many others) to perform byte-swapping, write a number of
	different archive formats, and pipe the data to other programs.
	This last feature makes <command>cpio</command> and excellent
	choice for installation media.  <command>cpio</command> does not
	know how to walk the directory tree and a list of files must be
	provided through <filename>stdin</filename>.</para>
      <indexterm><primary><command>cpio</command></primary></indexterm>

      <para><command>cpio</command> does not support backups across
	the network.  You can use a pipeline and <command>rsh</command>
	to send the data to a remote tape drive.</para>

      <screen>&prompt.root; <userinput>for f in <replaceable>directory_list; do</replaceable></userinput>
<userinput>find $f >> backup.list</userinput>
<userinput>done</userinput>
&prompt.root; <userinput>cpio -v -o --format=newc < backup.list | ssh <replaceable>user</replaceable>@<replaceable>host</replaceable> "cat > <replaceable>backup_device</replaceable>"</userinput></screen>

      <para>Where <replaceable>directory_list</replaceable> is the list of
	directories you want to back up,
	<replaceable>user</replaceable>@<replaceable>host</replaceable> is the
	user/hostname combination that will be performing the backups, and
	<replaceable>backup_device</replaceable> is where the backups should
	be written to (e.g., <filename>/dev/nrsa0</filename>).</para>
    </sect2>
    
    <sect2>
      <title><command>pax</command></title>
      <indexterm>
        <primary>backup software</primary>
        <secondary><command>pax</command></secondary>
      </indexterm>
      <indexterm><primary><command>pax</command></primary></indexterm>
      <indexterm><primary>POSIX</primary></indexterm>
      <indexterm><primary>IEEE</primary></indexterm>

      <para>&man.pax.1; is IEEE/POSIX's answer to
	<command>tar</command> and <command>cpio</command>.  Over the
	years the various versions of <command>tar</command> and
	<command>cpio</command> have gotten slightly incompatible.  So
	rather than fight it out to fully standardize them, POSIX
	created a new archive utility. <command>pax</command> attempts
	to read and write many of the various <command>cpio</command>
	and <command>tar</command> formats, plus new formats of its own.
	Its command set more resembles <command>cpio</command> than
	<command>tar</command>.</para>
    </sect2>

    <sect2 id="backups-programs-amanda">
      <title><application>Amanda</application></title>
      <indexterm>
        <primary>backup software</primary>
        <secondary><application>Amanda</application></secondary>
      </indexterm>      
      <indexterm><primary><application>Amanda</application></primary></indexterm>
      
      <!-- Remove link until <port> tag is available -->
      <para><application>Amanda</application> (Advanced Maryland
        Network Disk Archiver) is a client/server backup system,
        rather than a single program.  An Amanda server will backup to
        a single tape drive any number of computers that have Amanda
        clients and a network connection to the Amanda server.  A
        common problem at sites with a number of large disks is
        that the length of time required to backup to data directly to tape
        exceeds the amount of time available for the task.  Amanda
        solves this problem.  Amanda can use a <quote>holding disk</quote> to
        backup several filesystems at the same time.  Amanda creates
        <quote>archive sets</quote>: a group of tapes used over a period of time to
        create full backups of all the filesystems listed in Amanda's
        configuration file.  The <quote>archive set</quote> also contains nightly
        incremental (or differential) backups of all the filesystems.
        Restoring a damaged filesystem requires the most recent full
        backup and the incremental backups.</para>

      <para>The configuration file provides fine control of backups and the
	network traffic that Amanda generates.  Amanda will use any of the
	above backup programs to write the data to tape.  Amanda is available
	as either a port or a package, it is not installed by default.</para>
      </sect2>

    <sect2>
      <title>Do Nothing</title>
      
      <para><quote>Do nothing</quote> is not a computer program, but it is the
	most widely used backup strategy.  There are no initial costs.  There
	is no backup schedule to follow.  Just say no.  If something happens
	to your data, grin and bear it!</para>

      <para>If your time and your data is worth little to nothing, then
	<quote>Do nothing</quote> is the most suitable backup program for your
	computer.  But beware, Unix is a useful tool, you may find that within
	six months you have a collection of files that are valuable to
	you.</para>

      <para><quote>Do nothing</quote> is the correct backup method for
	<filename>/usr/obj</filename> and other directory trees that can be
	exactly recreated by your computer.  An example is the files that
	comprise the HTML or PostScript version of this Handbook.
	These document formats have been created from SGML input
	files.  Creating backups of the HTML or PostScript files is
	not necessary.  The SGML files are backed up regularly.</para>
    </sect2>
    
    <sect2>
      <title>Which Backup Program Is Best?</title>
      <indexterm>
        <primary>LISA</primary>
      </indexterm>

      <para>&man.dump.8; <emphasis>Period.</emphasis> Elizabeth D. Zwicky
	torture tested all the backup programs discussed here.  The clear
	choice for preserving all your data and all the peculiarities of Unix
	filesystems is <command>dump</command>.  Elizabeth created filesystems containing
	a large variety of unusual conditions (and some not so unusual ones)
	and tested each program by doing a backup and restore of those
	filesystems.  The peculiarities included: files with holes, files with
	holes and a block of nulls, files with funny characters in their
	names, unreadable and unwritable files, devices, files that change
	size during the backup, files that are created/deleted during the
	backup and more.  She presented the results at LISA V in Oct. 1991.
	See <ulink
	  url="http://reality.sgi.com/zwicky_neu/testdump.doc.html">torture-testing
	  Backup and Archive Programs</ulink>.</para>
    </sect2>
    
    <sect2>
      <title>Emergency Restore Procedure</title>
      
      <sect3>
	<title>Before the Disaster</title>

	<para>There are only four steps that you need to perform in
	  preparation for any disaster that may occur.</para>
	<indexterm>
    <primary><command>disklabel</command></primary>
  </indexterm>	    

	<para>First, print the disklabel from each of your disks
	  (<command>e.g. disklabel da0 | lpr</command>), your filesystem table
	  (<filename>/etc/fstab</filename>) and all boot messages,
	  two copies of
	  each.</para>

	<indexterm><primary>fix-it floppies</primary></indexterm>	    
	<para>Second, determine that the boot and fix-it floppies
	  (<filename>boot.flp</filename> and <filename>fixit.flp</filename>)
	  have all your devices.  The easiest way to check is to reboot your
	  machine with the boot floppy in the floppy drive and check the boot
	  messages.  If all your devices are listed and functional, skip on to
	  step three.</para>

	<para>Otherwise, you have to create two custom bootable
	  floppies which have a kernel that can mount all of your disks
	  and access your tape drive.  These floppies must contain:
	  <command>fdisk</command>, <command>disklabel</command>,
	  <command>newfs</command>, <command>mount</command>, and
	  whichever backup program you use.  These programs must be
	  statically linked.  If you use <command>dump</command>, the
	  floppy must contain <command>restore</command>.</para>

	<para>Third, create backup tapes regularly.  Any changes that you make
	  after your last backup may be irretrievably lost.  Write-protect the
	  backup tapes.</para>

	<para>Fourth, test the floppies (either <filename>boot.flp</filename>
	  and <filename>fixit.flp</filename> or the two custom bootable
	  floppies you made in step two.) and backup tapes.  Make notes of the
	  procedure.  Store these notes with the bootable floppy, the
	  printouts and the backup tapes.  You will be so distraught when
	  restoring that the notes may prevent you from destroying your backup
	  tapes (How? In place of <command>tar xvf /dev/rsa0</command>, you
	  might accidentally type <command>tar cvf /dev/rsa0</command> and
	  over-write your backup tape).</para>

	<para>For an added measure of security, make bootable floppies and two
	  backup tapes each time.  Store one of each at a remote location.  A
	  remote location is NOT the basement of the same office building.  A
	  number of firms in the World Trade Center learned this lesson the
	  hard way.  A remote location should be physically separated from
	  your computers and disk drives by a significant distance.</para>

	<example>
	  <title>A Script for Creating a Bootable Floppy</title>
	  
	<programlisting><![ CDATA [#!/bin/sh
#
# create a restore floppy
#
# format the floppy
#
PATH=/bin:/sbin:/usr/sbin:/usr/bin

fdformat -q fd0
if [ $? -ne 0 ]
then
	 echo "Bad floppy, please use a new one"
	 exit 1
fi

# place boot blocks on the floppy
#
disklabel -w -B /dev/fd0c fd1440

#
# newfs the one and only partition
#
newfs -t 2 -u 18 -l 1 -c 40 -i 5120 -m 5 -o space /dev/fd0a

#
# mount the new floppy
#
mount /dev/fd0a /mnt

#
# create required directories 
#
mkdir /mnt/dev
mkdir /mnt/bin
mkdir /mnt/sbin
mkdir /mnt/etc
mkdir /mnt/root
mkdir /mnt/mnt			# for the root partition
mkdir /mnt/tmp
mkdir /mnt/var

#
# populate the directories
#
if [ ! -x /sys/compile/MINI/kernel ] 
then
	 cat << EOM
The MINI kernel does not exist, please create one.
Here is an example config file:
#
# MINI -- A kernel to get FreeBSD onto a disk.
#
machine         "i386"
cpu             "I486_CPU"
ident           MINI
maxusers        5

options         INET                    # needed for _tcp _icmpstat _ipstat
                                        #            _udpstat _tcpstat _udb
options         FFS                     #Berkeley Fast File System
options         FAT_CURSOR              #block cursor in syscons or pccons
options         SCSI_DELAY=15           #Be pessimistic about Joe SCSI device
options         NCONS=2                 #1 virtual consoles
options         USERCONFIG              #Allow user configuration with -c XXX

config          kernel	root on da0 swap on da0 and da1 dumps on da0

device          isa0
device          pci0

device          fdc0	at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr
device          fd0	at fdc0 drive 0

device          ncr0

device          scbus0

device          sc0	at isa? port "IO_KBD" tty irq 1 vector scintr
device          npx0	at isa? port "IO_NPX" irq 13 vector npxintr

device          da0
device          da1
device          da2

device          sa0

pseudo-device   loop            # required by INET
pseudo-device   gzip            # Exec gzipped a.out's
EOM
	 exit 1
fi

cp -f /sys/compile/MINI/kernel /mnt

gzip -c -best /sbin/init > /mnt/sbin/init
gzip -c -best /sbin/fsck > /mnt/sbin/fsck
gzip -c -best /sbin/mount > /mnt/sbin/mount
gzip -c -best /sbin/halt > /mnt/sbin/halt
gzip -c -best /sbin/restore > /mnt/sbin/restore

gzip -c -best /bin/sh > /mnt/bin/sh
gzip -c -best /bin/sync > /mnt/bin/sync

cp /root/.profile /mnt/root

cp -f /dev/MAKEDEV /mnt/dev
chmod 755 /mnt/dev/MAKEDEV

chmod 500 /mnt/sbin/init
chmod 555 /mnt/sbin/fsck /mnt/sbin/mount /mnt/sbin/halt
chmod 555 /mnt/bin/sh /mnt/bin/sync
chmod 6555 /mnt/sbin/restore

#
# create the devices nodes 
#
cd /mnt/dev
./MAKEDEV std
./MAKEDEV da0
./MAKEDEV da1
./MAKEDEV da2
./MAKEDEV sa0
./MAKEDEV pty0
cd /

#
# create minimum filesystem table
#
cat > /mnt/etc/fstab <<EOM
/dev/fd0a    /    ufs    rw  1  1
EOM

#
# create minimum passwd file
#
cat > /mnt/etc/passwd <<EOM
root:*:0:0:Charlie &:/root:/bin/sh
EOM

cat > /mnt/etc/master.passwd <<EOM
root::0:0::0:0:Charlie &:/root:/bin/sh
EOM

chmod 600 /mnt/etc/master.passwd
chmod 644 /mnt/etc/passwd
/usr/sbin/pwd_mkdb -d/mnt/etc /mnt/etc/master.passwd

#
# umount the floppy and inform the user
#
/sbin/umount /mnt
echo "The floppy has been unmounted and is now ready."]]></programlisting>

        </example>

      </sect3>
      
      <sect3>
	<title>After the Disaster</title>

	<para>The key question is: did your hardware survive?  You have been
	  doing regular backups so there is no need to worry about the
	  software.</para>

	<para>If the hardware has been damaged.  First, replace those parts
	  that have been damaged.</para>

	<para>If your hardware is okay, check your floppies.  If you are using
	  a custom boot floppy, boot single-user (type <literal>-s</literal>
	  at the <prompt>boot:</prompt> prompt).  Skip the following
	  paragraph.</para>
	  
	<para>If you are using the <filename>boot.flp</filename> and
	  <filename>fixit.flp</filename> floppies, keep reading.  Insert the
	  <filename>boot.flp</filename> floppy in the first floppy drive and
	  boot the computer.  The original install menu will be displayed on
	  the screen.  Select the <literal>Fixit--Repair mode with CDROM or
	    floppy.</literal> option.  Insert the
	  <filename>fixit.flp</filename> when prompted.
	  <command>restore</command> and the other programs that you need are
	  located in <filename>/mnt2/stand</filename>.</para>

	<para>Recover each filesystem separately.</para>

	<indexterm>
    <primary><command>mount</command></primary>
  </indexterm>	    
	<indexterm><primary>root partition</primary></indexterm>
	<indexterm>
    <primary><command>disklabel</command></primary>
  </indexterm> 
	<indexterm>
    <primary><command>newfs</command></primary>
  </indexterm> 
	<para>Try to <command>mount</command> (e.g. <command>mount /dev/da0a
	    /mnt</command>)  the root partition of your first disk.  If the
	  disklabel was damaged, use <command>disklabel</command> to re-partition and
	  label the disk to match the label that you printed and saved.  Use
	    <command>newfs</command> to re-create the filesystems.  Re-mount the root
	  partition of the floppy read-write (<command>mount -u -o rw
	    /mnt</command>).  Use your backup program and backup tapes to
	  recover the data for this filesystem (e.g. <command>restore vrf
	    /dev/sa0</command>).  Unmount the filesystem (e.g. <command>umount
	    /mnt</command>) Repeat for each filesystem that was
	  damaged.</para>

	<para>Once your system is running, backup your data onto new tapes.
	  Whatever caused the crash or data loss may strike again.  Another
	  hour spent now may save you from further distress later.</para>
      </sect3>

<![ %not.published; [

      <sect3>
	<title>* I did not prepare for the Disaster, What Now?</title>

	<para></para>
      </sect3>
]]>

    </sect2>
  </sect1>

  <sect1 id="floppies">
    <sect1info>
      <authorgroup>
	<author>
	  <firstname>Julio</firstname>
	  <surname>Merino</surname>
	  <contrib>Contributed by </contrib>
	</author>
      </authorgroup>
      <!-- 24 Dec 2001 -->
    </sect1info>

    <title>Floppy disks</title>

    <para>Floppy disks are, nowadays, an old-fashioned medium to
      store/share data. Although, there are still some times when you
      need to use them, because you do not have any other removable
      storage media or you need to use what you have saved in them on
      any other computer.</para>

    <para>This section will explain how to use floppy disks in
      FreeBSD, that is, formating and copying/restoring data from
      them. But... I really have written this to help you about how to
      create forced-size floppies.</para>

    <sect2>
      <title>The device</title>

      <para>Floppy disks are accessed through entries in
        <filename>/dev</filename> (like any other device). To access the
        raw floppy disk you can use <filename>/dev/rfd<replaceable>X</replaceable></filename>,
        where <replaceable>X</replaceable> stands for the drive number, usually 0. When the disk is
        formatted you can use <filename>/dev/fd<replaceable>X</replaceable></filename>, or
        whichever of the other devices named
        <filename>/dev/fd<replaceable>XY</replaceable></filename>, where <replaceable>Y</replaceable> stands for a
        letter. These are all the same.</para>

      <para>Other important devices are
        <filename>/dev/fd<replaceable>X</replaceable>.<replaceable>size</replaceable></filename>, where <replaceable>size</replaceable> is a floppy disk
        size in kilobytes. These entries are used at low-level format
        time to determine the disk size.</para>

      <para>Sometimes you will have to (re)create these entries under
        <filename>/dev</filename>. To do it, you can issue:</para>

      <screen>&prompt.root; <userinput>cd /dev && ./MAKEDEV "fd*"</userinput></screen>
    </sect2>

    <sect2>
      <title>Formatting</title>

      <para>A floppy disk needs to be low-level formated before it can
        be used.  This is usually done by the vendor but you may want to
        do it to check media integrity or to force the disk capacity to
        be bigger.</para>

      <para>To format the floppy at a low-level fashion you need to
        use <application>fdformat</application>. This utility expects
        the device name as an argument. We will use those
        <filename>/dev/fd<replaceable>X</replaceable>.<replaceable>size</replaceable></filename> devices, which will allow us
        to format the floppy to its real size, or force them.  So you
        insert a new 3.5inch floppy disk in your drive and issue:</para>

      <screen>&prompt.root; <userinput>/usr/sbin/fdformat /dev/rfd0.1440</userinput></screen>

      <para>This will take a while... You should notice any disk error
        here (this can help you determining which disks are good or
        bad).</para>

      <para>To force the floppy disk size, we will use other entries
        in <filename>/dev</filename>.  Get the same floppy and issue:

      <screen>&prompt.root; <userinput>/usr/sbin/fdformat /dev/rfd0.1720</userinput></screen>

      <para>It will take some more time than before (forced disks are
        slower).  When it finishes, you will have a 1720kb floppy disk,
        but for the moment you will not notice any difference. You may
        use other disk sizes that you can find in <filename>/dev</filename>, but the most
        stable/compatible is the 1720kb for 3.5inch disks.</para>
    </sect2>

    <sect2>
      <title>The disklabel</title>

      <para>After low-level formatting the disk, you will need to
        place a disklabel on it.  This disklabel will be destroyed
        later, but it is needed by the system to determine the size of
        the disk and its geometry later.</para>

      <para>The new disklabel will take over the whole disk, and will
        contain all the proper information about the geometry of the
        normal or forced floppy.  Take a look to
        <filename>/etc/disktab</filename> now; you will see geometry
        values of all kinds of floppy disks.

      <para>You can run now <application>disklabel</application>
        like:</para>

      <screen>&prompt.root; <userinput>/sbin/disklabel -B -r -w /dev/rfd0 <replaceable>fdsize</replaceable></userinput></screen>

      <para>Replace <replaceable>fdsize</replaceable> with <literal>fd1440</literal>, <literal>fd1720</literal> or whichever size you
        want.  The last field instructs disklabel which entry to take
        from <filename>/etc/disktab</filename> to use.</para>
    </sect2>

    <sect2>
      <title>The filesystem</title>

      <para>Now your floppy is ready to be high-level formated. This
        will place a new filesystem on it, which will let FreeBSD read
        and write to the disk. After creating the new filesystem, the
        disklabel is destroyed, so if you want to reformat the disk, you
        will have to recreate the disklabel another time.</para>

      <para>You can choose now which filesystem to use on your floppy.
        You can use UFS or FAT, though UFS is not a good idea for
        floppies.  Choose FAT which is nice for floppies.</para>

      <para>To put a new filesystem on the floppy do this:</para>

      <screen>&prompt.root; <userinput>/sbin/newfs_msdos /dev/fd0</userinput></screen>

      <para>As we created a disklabel before, <application>newfs</application>
        will be able to fetch disk data and construct the new
        filesystem. And now, your disk is ready for use...</para>
    </sect2>

    <sect2>
      <title>Using the floppy</title>

      <para>You have two choices to use the floppy. You can either
        mount the disk with <application>mount_msdos</application>, or you can
        use <application>mtools</application>.
        <application>Mtools</application> are great, but you will need
        to install them from the ports system.</para>

      <para>Try it; issue a <application>mdir</application>. If you forced the
        disk, you will notice its extra size!</para>

      <para>A last note about forced disks: they are compatible with
        practically all other operating systems without any external
        utility to read/write them.  Microsoft systems will recognize
        them without problems. But note that there may be times when the
        floppy drive itself is not able to read them (this may happen
        with very old drives).</para>
    </sect2>
  </sect1>

  <sect1 id="backups-floppybackups">
    <title>Backups to Floppies</title>

    <sect2 id="floppies-using">
      <title>Can I Use floppies for Backing Up My Data?</title>
      <indexterm><primary>backup floppies</primary></indexterm>
      <indexterm><primary>floppy disks</primary></indexterm>

      <para>Floppy disks are not really a suitable media for
        making backups as:</para>

      <itemizedlist>
	<listitem>
	  <para>The media is unreliable, especially over long periods of
	    time.</para>
	</listitem>

	<listitem>
	  <para>Backing up and restoring is very slow.</para>
	</listitem>

	<listitem>
	  <para>They have a very limited capacity (the days of backing up
	    an entire hard disk onto a dozen or so floppies has long since
	    passed).</para>
	</listitem>
      </itemizedlist>

      <para>However, if you have no other method of backing up your data then
	floppy disks are better than no backup at all.</para>

      <para>If you do have to use floppy disks then ensure that you use good
	quality ones. Floppies that have been lying around the office for a
	couple of years are a bad choice. Ideally use new ones from a
	reputable manufacturer.</para>
    </sect2>
    
    <sect2 id="floppies-creating">
      <title>So How Do I Backup My Data to Floppies?</title>

      <para>The best way to backup to floppy disk is to use
	<command>tar</command> with the <option>-M</option> (multi
	volume) option, which allows backups to span multiple
	floppies.</para>

      <para>To backup all the files in the current directory and sub-directory
	use this (as root):</para>

      <screen>&prompt.root; <userinput>tar Mcvf /dev/fd0 *</userinput></screen>

      <para>When the first floppy is full <command>tar</command> will prompt you to
	insert the next volume (because <command>tar</command> is media independent it
	refers to volumes; in this context it means floppy disk).</para>

      <screen>Prepare volume #2 for /dev/fd0 and hit return:</screen>

      <para>This is repeated (with the volume number incrementing) until all
	the specified files have been archived.</para>
    </sect2>

    <sect2 id="floppies-compress">
      <title>Can I Compress My Backups?</title>
      <indexterm>
        <primary><command>tar</command></primary>
      </indexterm> 
      <indexterm>
        <primary><command>gzip</command></primary>
      </indexterm> 
      <indexterm><primary>compression</primary></indexterm> 

      <para>Unfortunately, <command>tar</command> will not allow the
	<option>-z</option> option to be used for multi-volume archives.
	You could, of course, <command>gzip</command> all the files,
	<command>tar</command> them to the floppies, then
	<command>gunzip</command> the files again!</para>
    </sect2>

    <sect2 id="floppies-restoring">
      <title>How Do I Restore My Backups?</title>
      
      <para>To restore the entire archive use:</para>

      <screen>&prompt.root; <userinput>tar Mxvf /dev/fd0</userinput></screen>

      <para>There are two ways that you can use to restore only
	specific files.  First, you can start with the first floppy
	and use:</para>

      <screen>&prompt.root; <userinput>tar Mxvf /dev/fd0 <replaceable>filename</replaceable></userinput></screen>

      <para><command>tar</command> will prompt you to insert subsequent floppies until it
	finds the required file.</para>

      <para>Alternatively, if you know which floppy the file is on then you
	can simply insert that floppy and use the same command as above. Note
	that if the first file on the floppy is a continuation from the
	previous one then <command>tar</command> will warn you that it cannot
	restore it, even if you have not asked it to!</para>
    </sect2>
  </sect1>
  
    <sect1 id="backups-tapebackups">
    <title>Tape Backup Media</title>

    <indexterm><primary>tape media</primary></indexterm>
    <para>The major tape media are the 4mm, 8mm, QIC, mini-cartridge and
      DLT.</para>

    <sect2 id="backups-tapebackups-4mm">
      <title>4mm (DDS: Digital Data Storage)</title>

      <indexterm>
        <primary>tape media</primary>
	<secondary>DDS (4mm) tapes</secondary>
      </indexterm>
      <indexterm>
        <primary>tape media</primary>
	<secondary>QIC tapes</secondary>
      </indexterm>
      <para>4mm tapes are replacing QIC as the workstation backup media of
	choice.  This trend accelerated greatly when Conner purchased Archive,
	a leading manufacturer of QIC drives, and then stopped production of
	QIC drives.  4mm drives are small and quiet but do not have the
	reputation for reliability that is enjoyed by 8mm drives.  The
	cartridges are less expensive and smaller (3 x 2 x 0.5 inches, 76 x 51
	x 12 mm) than 8mm cartridges.  4mm, like 8mm, has comparatively short
	head life for the same reason, both use helical scan.</para>

      <para>Data throughput on these drives starts ~150kB/s, peaking at ~500kB/s.
	Data capacity starts at 1.3 GB and ends at 2.0 GB.  Hardware
	compression, available with most of these drives, approximately
	doubles the capacity.  Multi-drive tape library units can have 6
	drives in a single cabinet with automatic tape changing.  Library
	capacities reach 240 GB.</para>

      <para>The DDS-3 standard now supports tape capacities up to 12 GB (or
	24 GB compressed).</para>

      <para>4mm drives, like 8mm drives, use helical-scan.  All the benefits
	and drawbacks of helical-scan apply to both 4mm and 8mm drives.</para>

      <para>Tapes should be retired from use after 2,000 passes or 100 full
	backups.</para>
    </sect2>

    <sect2 id="backups-tapebackups-8mm">
      <title>8mm (Exabyte)</title>
      <indexterm>
        <primary>tape media</primary>
	<secondary>Exabyte (8mm) tapes</secondary>
      </indexterm>

      <para>8mm tapes are the most common SCSI tape drives; they are the best
	choice of exchanging tapes.  Nearly every site has an Exabyte 2 GB 8mm
	tape drive.  8mm drives are reliable, convenient and quiet. Cartridges
	are inexpensive and small (4.8 x 3.3 x 0.6 inches; 122 x 84 x 15 mm).
	One downside of 8mm tape is relatively short head and tape life due to
	the high rate of relative motion of the tape across the heads.</para>

      <para>Data throughput ranges from ~250kB/s to ~500kB/s.  Data sizes start
	at 300 MB and go up to 7 GB.  Hardware compression, available with
	most of these drives, approximately doubles the capacity.  These
	drives are available as single units or multi-drive tape libraries
	with 6 drives and 120 tapes in a single cabinet.  Tapes are changed
	automatically by the unit.  Library capacities reach 840+ GB.</para>

      <para>The Exabyte <quote>Mammoth</quote> model supports 12 GB on one tape
	(24 GB with compression) and costs approximately twice as much as
	conventional tape drives.</para>

      <para>Data is recorded onto the tape using helical-scan, the heads are
	positioned at an angle to the media (approximately 6 degrees).  The
	tape wraps around 270 degrees of the spool that holds the heads.  The
	spool spins while the tape slides over the spool.  The result is a
	high density of data and closely packed tracks that angle across the
	tape from one edge to the other.</para>
    </sect2>

    <sect2 id="backups-tapebackups-qic">
      <title>QIC</title>
      <indexterm>
        <primary>tape media</primary>
	<secondary>QIC-150</secondary>
      </indexterm>

      <para>QIC-150 tapes and drives are, perhaps, the most common tape drive
	and media around.  QIC tape drives are the least expensive "serious"
	backup drives.  The downside is the cost of media.  QIC tapes are
	expensive compared to 8mm or 4mm tapes, up to 5 times the price per GB
	data storage.  But, if your needs can be satisfied with a half-dozen
	tapes, QIC may be the correct choice.  QIC is the
	<emphasis>most</emphasis> common tape drive.  Every site has a QIC
	drive of some density or another.  Therein lies the rub, QIC has a
	large number of densities on physically similar (sometimes identical)
	tapes.  QIC drives are not quiet.  These drives audibly seek before
	they begin to record data and are clearly audible whenever reading,
	writing or seeking.  QIC tapes measure (6 x 4 x 0.7 inches; 15.2 x
	10.2 x 1.7 mm).  <link
	  linkend="backups-tapebackups-mini">Mini-cartridges</link>, which
	also use 1/4" wide tape are discussed separately.  Tape libraries and
	changers are not available.</para>

      <para>Data throughput ranges from ~150kB/s to ~500kB/s.  Data capacity
	ranges from 40 MB to 15 GB.  Hardware compression is available on many
	of the newer QIC drives.  QIC drives are less frequently installed;
	they are being supplanted by DAT drives.</para>

      <para>Data is recorded onto the tape in tracks.  The tracks run along
	the long axis of the tape media from one end to the other.  The number
	of tracks, and therefore the width of a track, varies with the tape's
	capacity.  Most if not all newer drives provide backward-compatibility
	at least for reading (but often also for writing).  QIC has a good
	reputation regarding the safety of the data (the mechanics are simpler
	and more robust than for helical scan drives).</para>

      <para>Tapes should be retired from use after 5,000 backups.</para>
    </sect2>

    <sect2 id="backups-tapebackups-mini">
      <title>XXX* Mini-Cartridge</title>

      <para></para>
    </sect2>

    <sect2 id="backups-tapebackups-dlt">
      <title>DLT</title>
      <indexterm>
        <primary>tape media</primary>
	<secondary>DLT</secondary>
      </indexterm>

      <para>DLT has the fastest data transfer rate of all the drive types
	listed here.  The 1/2" (12.5mm) tape is contained in a single spool
	cartridge (4 x 4 x 1 inches; 100 x 100 x 25 mm).  The cartridge has a
	swinging gate along one entire side of the cartridge.  The drive
	mechanism opens this gate to extract the tape leader.  The tape leader
	has an oval hole in it which the drive uses to "hook" the tape.  The
	take-up spool is located inside the tape drive.  All the other tape
	cartridges listed here (9 track tapes are the only exception) have
	both the supply and take-up spools located inside the tape cartridge
	itself.</para>

      <para>Data throughput is approximately 1.5MB/s, three times the throughput of
	4mm, 8mm, or QIC tape drives.  Data capacities range from 10 GB to 20 GB
	for a single drive.  Drives are available in both multi-tape changers
	and multi-tape, multi-drive tape libraries containing from 5 to 900
	tapes over 1 to 20 drives, providing from 50 GB to 9 TB of
	storage.</para>

      <para>With compression, DLT Type IV format supports up to 70 GB
	capacity.</para>

      <para>Data is recorded onto the tape in tracks parallel to the direction
	of travel (just like QIC tapes).  Two tracks are written at once.
	Read/write head lifetimes are relatively long; once the tape stops
	moving, there is no relative motion between the heads and the
	tape.</para>
    </sect2>

    <sect2>
      <title id="backups-tapebackups-ait">AIT</title>
      <indexterm>
        <primary>tape media</primary>
	<secondary>AIT</secondary>
      </indexterm>

      <para>AIT is a new format from Sony, and can hold up to 50 GB (with
	compression) per tape.  The tapes contain memory chips which retain an
	index of the tape's contents.  This index can be rapidly read by the
	tape drive to determine the position of files on the tape, instead of
	the several minutes that would be required for other tapes.  Software
	such as SAMS:Alexandria can operate forty or more AIT tape libraries,
	communicating directly with the tape's memory chip to display the
	contents on screen, determine what files were backed up to which
	tape, locate the correct tape, load it, and restore the data from the
	tape.</para>

      <para>Libraries like this cost in the region of $20,000, pricing them a
	little out of the hobbyist market.</para>
    </sect2>

    <sect2>
      <title>Using a New Tape for the First Time</title>

      <para>The first time that you try to read or write a new, completely
	blank tape, the operation will fail.  The console messages should be
	similar to:</para>

      <screen>sa0(ncr1:4:0): NOT READY asc:4,1
sa0(ncr1:4:0):  Logical unit is in process of becoming ready</screen>

      <para>The tape does not contain an Identifier Block (block number 0).
	All QIC tape drives since the adoption of QIC-525 standard write an
	Identifier Block to the tape.  There are two solutions:</para>

      <para><command>mt fsf 1</command> causes the tape drive to write an
	Identifier Block to the tape.</para>
      
      <para>Use the front panel button to eject the tape.</para>

      <para>Re-insert the tape and <command>dump</command> data to the tape.</para>
      
      <para><command>dump</command> will report <literal>DUMP: End of tape
	  detected</literal> and the console will show: <literal>HARDWARE
	  FAILURE info:280 asc:80,96</literal>.</para>

      <para>rewind the tape using: <command>mt rewind</command>.</para>

      <para>Subsequent tape operations are successful.</para>
    </sect2>
  </sect1>
</chapter>

<!-- 
     Local Variables:
     mode: sgml
     sgml-declaration: "../chapter.decl"
     sgml-indent-data: t
     sgml-omittag: nil
     sgml-always-quote-attributes: t
     sgml-parent-document: ("../book.sgml" "part" "chapter")
     End:
-->