| 1 |
<?xml version="1.0" encoding="iso-8859-1"?> |
| 2 |
<!-- |
| 3 |
The FreeBSD Documentation Project |
| 4 |
|
| 5 |
$FreeBSD$ |
| 6 |
--> |
| 7 |
|
| 8 |
<chapter xmlns="http://docbook.org/ns/docbook" |
| 9 |
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" |
| 10 |
xml:id="disks"> |
| 11 |
|
| 12 |
<title>Storage</title> |
| 13 |
|
| 14 |
<sect1 xml:id="disks-synopsis"> |
| 15 |
<title>Synopsis</title> |
| 16 |
|
| 17 |
<para>This chapter covers the use of disks and storage media in |
| 18 |
&os;. This includes <acronym>SCSI</acronym> and |
| 19 |
<acronym>IDE</acronym> disks, <acronym>CD</acronym> and |
| 20 |
<acronym>DVD</acronym> media, memory-backed disks, and |
| 21 |
<acronym>USB</acronym> storage devices.</para> |
| 22 |
|
| 23 |
<para>After reading this chapter, you will know:</para> |
| 24 |
|
| 25 |
<itemizedlist> |
| 26 |
<listitem> |
| 27 |
<para>How to add additional hard disks to a &os; |
| 28 |
system.</para> |
| 29 |
</listitem> |
| 30 |
|
| 31 |
<listitem> |
| 32 |
<para>How to grow the size of a disk's partition on |
| 33 |
&os;.</para> |
| 34 |
</listitem> |
| 35 |
|
| 36 |
<listitem> |
| 37 |
<para>How to configure &os; to use <acronym>USB</acronym> |
| 38 |
storage devices.</para> |
| 39 |
</listitem> |
| 40 |
|
| 41 |
<listitem> |
| 42 |
<para>How to use <acronym>CD</acronym> and |
| 43 |
<acronym>DVD</acronym> media on a &os; system.</para> |
| 44 |
</listitem> |
| 45 |
|
| 46 |
<listitem> |
| 47 |
<para>How to use the backup programs available under |
| 48 |
&os;.</para> |
| 49 |
</listitem> |
| 50 |
|
| 51 |
<listitem> |
| 52 |
<para>How to set up memory disks.</para> |
| 53 |
</listitem> |
| 54 |
|
| 55 |
<listitem> |
| 56 |
<para>What file system snapshots are and how to use them |
| 57 |
efficiently.</para> |
| 58 |
</listitem> |
| 59 |
|
| 60 |
<listitem> |
| 61 |
<para>How to use quotas to limit disk space usage.</para> |
| 62 |
</listitem> |
| 63 |
|
| 64 |
<listitem> |
| 65 |
<para>How to encrypt disks and swap to secure them against |
| 66 |
attackers.</para> |
| 67 |
</listitem> |
| 68 |
|
| 69 |
<listitem> |
| 70 |
<para>How to configure a highly available storage |
| 71 |
network.</para> |
| 72 |
</listitem> |
| 73 |
</itemizedlist> |
| 74 |
|
| 75 |
<para>Before reading this chapter, you should:</para> |
| 76 |
|
| 77 |
<itemizedlist> |
| 78 |
<listitem> |
| 79 |
<para>Know how to <link linkend="kernelconfig">configure and |
| 80 |
install a new &os; kernel</link>.</para> |
| 81 |
</listitem> |
| 82 |
</itemizedlist> |
| 83 |
</sect1> |
| 84 |
|
| 85 |
<sect1 xml:id="disks-adding"> |
| 86 |
<info> |
| 87 |
<title>Adding Disks</title> |
| 88 |
|
| 89 |
<authorgroup> |
| 90 |
<author> |
| 91 |
<personname> |
| 92 |
<firstname>David</firstname> |
| 93 |
<surname>O'Brien</surname> |
| 94 |
</personname> |
| 95 |
<contrib>Originally contributed by </contrib> |
| 96 |
</author> |
| 97 |
</authorgroup> |
| 98 |
</info> |
| 99 |
|
| 100 |
<indexterm> |
| 101 |
<primary>disks</primary> |
| 102 |
<secondary>adding</secondary> |
| 103 |
</indexterm> |
| 104 |
|
| 105 |
<para>This section describes how to add a new |
| 106 |
<acronym>SATA</acronym> disk to a machine that currently only |
| 107 |
has a single drive. First, turn off the computer and install |
| 108 |
the drive in the computer following the instructions of the |
| 109 |
computer, controller, and drive manufacturers. Reboot the |
| 110 |
system and become |
| 111 |
<systemitem class="username">root</systemitem>.</para> |
| 112 |
|
| 113 |
<para>Inspect <filename>/var/run/dmesg.boot</filename> to ensure |
| 114 |
the new disk was found. In this example, the newly added |
| 115 |
<acronym>SATA</acronym> drive will appear as |
| 116 |
<filename>ada1</filename>.</para> |
| 117 |
|
| 118 |
<indexterm><primary>partitions</primary></indexterm> |
| 119 |
<indexterm> |
| 120 |
<primary><command>gpart</command></primary> |
| 121 |
</indexterm> |
| 122 |
|
| 123 |
<para>For this example, a single large partition will be created |
| 124 |
on the new disk. The <link |
| 125 |
xlink:href="http://en.wikipedia.org/wiki/GUID_Partition_Table"> |
| 126 |
<acronym>GPT</acronym></link> partitioning scheme will be |
| 127 |
used in preference to the older and less versatile |
| 128 |
<acronym>MBR</acronym> scheme.</para> |
| 129 |
|
| 130 |
<note> |
| 131 |
<para>If the disk to be added is not blank, old partition |
| 132 |
information can be removed with |
| 133 |
<command>gpart delete</command>. See &man.gpart.8; for |
| 134 |
details.</para> |
| 135 |
</note> |
| 136 |
|
| 137 |
<para>The partition scheme is created, and then a single partition |
| 138 |
is added. To improve performance on newer disks with larger |
| 139 |
hardware block sizes, the partition is aligned to one megabyte |
| 140 |
boundaries:</para> |
| 141 |
|
| 142 |
<screen>&prompt.root; <userinput>gpart create -s GPT ada1</userinput> |
| 143 |
&prompt.root; <userinput>gpart add -t freebsd-ufs -a 1M ada1</userinput></screen> |
| 144 |
|
| 145 |
<para>Depending on use, several smaller partitions may be desired. |
| 146 |
See &man.gpart.8; for options to create partitions smaller than |
| 147 |
a whole disk.</para> |
| 148 |
|
| 149 |
<para>The disk partition information can be viewed with |
| 150 |
<command>gpart show</command>:</para> |
| 151 |
|
| 152 |
<screen>&prompt.user; <userinput>gpart show ada1</userinput> |
| 153 |
=> 34 1465146988 ada1 GPT (699G) |
| 154 |
34 2014 - free - (1.0M) |
| 155 |
2048 1465143296 1 freebsd-ufs (699G) |
| 156 |
1465145344 1678 - free - (839K)</screen> |
| 157 |
|
| 158 |
<para>A file system is created in the new partition on the new disk:</para> |
| 159 |
|
| 160 |
<screen>&prompt.root; <userinput>newfs -U /dev/ada1p1</userinput></screen> |
| 161 |
|
| 162 |
<para>An empty directory is created as a |
| 163 |
<emphasis>mountpoint</emphasis>, a location for mounting the new |
| 164 |
disk in the original disk's file system:</para> |
| 165 |
|
| 166 |
<screen>&prompt.root; <userinput>mkdir /newdisk</userinput></screen> |
| 167 |
|
| 168 |
<para>Finally, an entry is added to |
| 169 |
<filename>/etc/fstab</filename> so the new disk will be mounted |
| 170 |
automatically at startup:</para> |
| 171 |
|
| 172 |
<programlisting>/dev/ada1p1 /newdisk ufs rw 2 2</programlisting> |
| 173 |
|
| 174 |
<para>The new disk can be mounted manually, without restarting the |
| 175 |
system:</para> |
| 176 |
|
| 177 |
<screen>&prompt.root; <userinput>mount /newdisk</userinput></screen> |
| 178 |
</sect1> |
| 179 |
|
| 180 |
<sect1 xml:id="disks-growing"> |
| 181 |
<info> |
| 182 |
<title>Resizing and Growing Disks</title> |
| 183 |
|
| 184 |
<authorgroup> |
| 185 |
<author> |
| 186 |
<personname> |
| 187 |
<firstname>Allan</firstname> |
| 188 |
<surname>Jude</surname> |
| 189 |
</personname> |
| 190 |
<contrib>Originally contributed by </contrib> |
| 191 |
</author> |
| 192 |
</authorgroup> |
| 193 |
</info> |
| 194 |
|
| 195 |
<indexterm> |
| 196 |
<primary>disks</primary> |
| 197 |
<secondary>resizing</secondary> |
| 198 |
</indexterm> |
| 199 |
|
| 200 |
<para>A disk's capacity can increase without any changes to the |
| 201 |
data already present. This happens commonly with virtual |
| 202 |
machines, when the virtual disk turns out to be too small and is |
| 203 |
enlarged. Sometimes a disk image is written to a |
| 204 |
<acronym>USB</acronym> memory stick, but does not use the full |
| 205 |
capacity. Here we describe how to resize or |
| 206 |
<emphasis>grow</emphasis> disk contents to take advantage of |
| 207 |
increased capacity.</para> |
| 208 |
|
| 209 |
<para>Determine the device name of the disk to be resized by |
| 210 |
inspecting <filename>/var/run/dmesg.boot</filename>. In this |
| 211 |
example, there is only one <acronym>SATA</acronym> disk in the |
| 212 |
system, so the drive will appear as |
| 213 |
<filename>ada0</filename>.</para> |
| 214 |
|
| 215 |
<indexterm><primary>partitions</primary></indexterm> |
| 216 |
<indexterm> |
| 217 |
<primary><command>gpart</command></primary> |
| 218 |
</indexterm> |
| 219 |
|
| 220 |
<para>List the partitions on the disk to see the current |
| 221 |
configuration:</para> |
| 222 |
|
| 223 |
<screen>&prompt.root; <userinput>gpart show <replaceable>ada0</replaceable></userinput> |
| 224 |
=> 34 83886013 ada0 GPT (48G) [CORRUPT] |
| 225 |
34 128 1 freebsd-boot (64k) |
| 226 |
162 79691648 2 freebsd-ufs (38G) |
| 227 |
79691810 4194236 3 freebsd-swap (2G) |
| 228 |
83886046 1 - free - (512B)</screen> |
| 229 |
|
| 230 |
<note> |
| 231 |
<para>If the disk was formatted with the <link |
| 232 |
xlink:href="http://en.wikipedia.org/wiki/GUID_Partition_Table"> |
| 233 |
<acronym>GPT</acronym></link> partitioning scheme, it may show |
| 234 |
as <quote>corrupted</quote> because the <acronym>GPT</acronym> |
| 235 |
backup partition table is no longer at the end of the |
| 236 |
drive. Fix the backup |
| 237 |
partition table with |
| 238 |
<command>gpart</command>:</para> |
| 239 |
|
| 240 |
<screen>&prompt.root; <userinput>gpart recover <replaceable>ada0</replaceable></userinput> |
| 241 |
ada0 recovered</screen> |
| 242 |
</note> |
| 243 |
|
| 244 |
<para>Now the additional space on the disk is available for |
| 245 |
use by a new partition, or an existing partition can be |
| 246 |
expanded:</para> |
| 247 |
|
| 248 |
<screen>&prompt.root; <userinput>gpart show <replaceable>ada0</replaceable></userinput> |
| 249 |
=> 34 102399933 ada0 GPT (48G) |
| 250 |
34 128 1 freebsd-boot (64k) |
| 251 |
162 79691648 2 freebsd-ufs (38G) |
| 252 |
79691810 4194236 3 freebsd-swap (2G) |
| 253 |
83886046 18513921 - free - (8.8G)</screen> |
| 254 |
|
| 255 |
<para>Partitions can only be resized into contiguous free space. |
| 256 |
Here, the last partition on the disk is the swap partition, but |
| 257 |
the second partition is the one that needs to be resized. Swap |
| 258 |
partitions only contain temporary data, so it can safely be |
| 259 |
unmounted, deleted, and then recreate the third partition after |
| 260 |
resizing the second partition.</para> |
| 261 |
|
| 262 |
<para>Disable the swap partition:</para> |
| 263 |
|
| 264 |
<screen>&prompt.root; <userinput>swapoff <replaceable>/dev/ada0p3</replaceable></userinput></screen> |
| 265 |
|
| 266 |
<para>Delete the third partition, specified by the |
| 267 |
<option>-i</option> flag, from the disk |
| 268 |
<replaceable>ada0</replaceable>.</para> |
| 269 |
|
| 270 |
<screen> |
| 271 |
&prompt.root; <userinput>gpart delete -i <replaceable>3</replaceable> <replaceable>ada0</replaceable></userinput> |
| 272 |
ada0p3 deleted |
| 273 |
&prompt.root; <userinput>gpart show <replaceable>ada0</replaceable></userinput> |
| 274 |
=> 34 102399933 ada0 GPT (48G) |
| 275 |
34 128 1 freebsd-boot (64k) |
| 276 |
162 79691648 2 freebsd-ufs (38G) |
| 277 |
79691810 22708157 - free - (10G)</screen> |
| 278 |
|
| 279 |
<warning> |
| 280 |
<para>There is risk of data loss when modifying the partition |
| 281 |
table of a mounted file system. It is best to perform the |
| 282 |
following steps on an unmounted file system while running from |
| 283 |
a live <acronym>CD-ROM</acronym> or <acronym>USB</acronym> |
| 284 |
device. However, if absolutely necessary, a mounted file |
| 285 |
system can be resized after disabling GEOM safety |
| 286 |
features:</para> |
| 287 |
|
| 288 |
<screen>&prompt.root; <userinput>sysctl kern.geom.debugflags=16</userinput></screen> |
| 289 |
</warning> |
| 290 |
|
| 291 |
<para>Resize the partition, leaving room to recreate a swap |
| 292 |
partition of the desired size. The partition to resize is |
| 293 |
specified with <option>-i</option>, and the new desired size |
| 294 |
with <option>-s</option>. Optionally, alignment of the |
| 295 |
partition is controlled with <option>-a</option>. This only |
| 296 |
modifies the size of the partition. The file system in the |
| 297 |
partition will be expanded in a separate step.</para> |
| 298 |
|
| 299 |
<screen>&prompt.root; <userinput>gpart resize -i <replaceable>2</replaceable> -s <replaceable>47G</replaceable> -a 4k <replaceable>ada0</replaceable></userinput> |
| 300 |
ada0p2 resized |
| 301 |
&prompt.root; <userinput>gpart show <replaceable>ada0</replaceable></userinput> |
| 302 |
=> 34 102399933 ada0 GPT (48G) |
| 303 |
34 128 1 freebsd-boot (64k) |
| 304 |
162 98566144 2 freebsd-ufs (47G) |
| 305 |
98566306 3833661 - free - (1.8G)</screen> |
| 306 |
|
| 307 |
<para>Recreate the swap partition and activate it. If no size |
| 308 |
is specified with <option>-s</option>, all remaining space is |
| 309 |
used:</para> |
| 310 |
|
| 311 |
<screen>&prompt.root; <userinput>gpart add -t freebsd-swap -a 4k <replaceable>ada0</replaceable></userinput> |
| 312 |
ada0p3 added |
| 313 |
&prompt.root; <userinput>gpart show <replaceable>ada0</replaceable></userinput> |
| 314 |
=> 34 102399933 ada0 GPT (48G) |
| 315 |
34 128 1 freebsd-boot (64k) |
| 316 |
162 98566144 2 freebsd-ufs (47G) |
| 317 |
98566306 3833661 3 freebsd-swap (1.8G) |
| 318 |
&prompt.root; <userinput>swapon <replaceable>/dev/ada0p3</replaceable></userinput></screen> |
| 319 |
|
| 320 |
<para>Grow the <acronym>UFS</acronym> file system to use the new |
| 321 |
capacity of the resized partition:</para> |
| 322 |
|
| 323 |
<screen>&prompt.root; <userinput>growfs <replaceable>/dev/ada0p2</replaceable></userinput> |
| 324 |
Device is mounted read-write; resizing will result in temporary write suspension for /. |
| 325 |
It's strongly recommended to make a backup before growing the file system. |
| 326 |
OK to grow file system on /dev/ada0p2, mounted on /, from 38GB to 47GB? [Yes/No] <userinput>Yes</userinput> |
| 327 |
super-block backups (for fsck -b #) at: |
| 328 |
80781312, 82063552, 83345792, 84628032, 85910272, 87192512, 88474752, |
| 329 |
89756992, 91039232, 92321472, 93603712, 94885952, 96168192, 97450432</screen> |
| 330 |
|
| 331 |
<para>If the file system is <acronym>ZFS</acronym>, the resize is |
| 332 |
triggered by running the <option>online</option> subcommand with |
| 333 |
<option>-e</option>:</para> |
| 334 |
|
| 335 |
<screen>&prompt.root; <userinput>zpool online -e <replaceable>zroot</replaceable> <replaceable>/dev/ada0p2</replaceable></userinput></screen> |
| 336 |
|
| 337 |
<para>Both the partition and the file system on it have now been |
| 338 |
resized to use the newly-available disk space.</para> |
| 339 |
</sect1> |
| 340 |
|
| 341 |
<sect1 xml:id="usb-disks"> |
| 342 |
<info> |
| 343 |
<title><acronym>USB</acronym> Storage Devices</title> |
| 344 |
|
| 345 |
<authorgroup> |
| 346 |
<author> |
| 347 |
<personname> |
| 348 |
<firstname>Marc</firstname> |
| 349 |
<surname>Fonvieille</surname> |
| 350 |
</personname> |
| 351 |
<contrib>Contributed by </contrib> |
| 352 |
</author> |
| 353 |
</authorgroup> |
| 354 |
</info> |
| 355 |
|
| 356 |
<indexterm> |
| 357 |
<primary>USB</primary> |
| 358 |
<secondary>disks</secondary> |
| 359 |
</indexterm> |
| 360 |
|
| 361 |
<para>Many external storage solutions, such as hard drives, |
| 362 |
<acronym>USB</acronym> thumbdrives, and <acronym>CD</acronym> |
| 363 |
and <acronym>DVD</acronym> burners, use the Universal Serial Bus |
| 364 |
(<acronym>USB</acronym>). &os; provides support for |
| 365 |
<acronym>USB</acronym> 1.x, 2.0, and 3.0 devices.</para> |
| 366 |
|
| 367 |
<note> |
| 368 |
<para><acronym>USB</acronym> 3.0 support is not compatible with |
| 369 |
some hardware, including Haswell (Lynx point) chipsets. If |
| 370 |
&os; boots with a <errorname>failed with error 19</errorname> |
| 371 |
message, disable xHCI/USB3 in the system |
| 372 |
<acronym>BIOS</acronym>.</para> |
| 373 |
</note> |
| 374 |
|
| 375 |
<para>Support for <acronym>USB</acronym> storage devices is built |
| 376 |
into the <filename>GENERIC</filename> kernel. For a custom |
| 377 |
kernel, be sure that the following lines are present in the |
| 378 |
kernel configuration file:</para> |
| 379 |
|
| 380 |
<programlisting>device scbus # SCSI bus (required for ATA/SCSI) |
| 381 |
device da # Direct Access (disks) |
| 382 |
device pass # Passthrough device (direct ATA/SCSI access) |
| 383 |
device uhci # provides USB 1.x support |
| 384 |
device ohci # provides USB 1.x support |
| 385 |
device ehci # provides USB 2.0 support |
| 386 |
device xhci # provides USB 3.0 support |
| 387 |
device usb # USB Bus (required) |
| 388 |
device umass # Disks/Mass storage - Requires scbus and da |
| 389 |
device cd # needed for CD and DVD burners</programlisting> |
| 390 |
|
| 391 |
<para>&os; uses the &man.umass.4; driver which uses the |
| 392 |
<acronym>SCSI</acronym> subsystem to access |
| 393 |
<acronym>USB</acronym> storage devices. Since any |
| 394 |
<acronym>USB</acronym> device will be seen as a |
| 395 |
<acronym>SCSI</acronym> device by the system, if the |
| 396 |
<acronym>USB</acronym> device is a <acronym>CD</acronym> or |
| 397 |
<acronym>DVD</acronym> burner, do <emphasis>not</emphasis> |
| 398 |
include <option>device atapicam</option> in a custom kernel |
| 399 |
configuration file.</para> |
| 400 |
|
| 401 |
<para>The rest of this section demonstrates how to verify that a |
| 402 |
<acronym>USB</acronym> storage device is recognized by &os; and |
| 403 |
how to configure the device so that it can be used.</para> |
| 404 |
|
| 405 |
<sect2> |
| 406 |
<title>Device Configuration</title> |
| 407 |
|
| 408 |
<para>To test the <acronym>USB</acronym> configuration, plug in |
| 409 |
the <acronym>USB</acronym> device. Use |
| 410 |
<command>dmesg</command> to confirm that the drive appears in |
| 411 |
the system message buffer. It should look something like |
| 412 |
this:</para> |
| 413 |
|
| 414 |
<screen>umass0: <STECH Simple Drive, class 0/0, rev 2.00/1.04, addr 3> on usbus0 |
| 415 |
umass0: SCSI over Bulk-Only; quirks = 0x0100 |
| 416 |
umass0:4:0:-1: Attached to scbus4 |
| 417 |
da0 at umass-sim0 bus 0 scbus4 target 0 lun 0 |
| 418 |
da0: <STECH Simple Drive 1.04> Fixed Direct Access SCSI-4 device |
| 419 |
da0: Serial Number WD-WXE508CAN263 |
| 420 |
da0: 40.000MB/s transfers |
| 421 |
da0: 152627MB (312581808 512 byte sectors: 255H 63S/T 19457C) |
| 422 |
da0: quirks=0x2<NO_6_BYTE></screen> |
| 423 |
|
| 424 |
<para>The brand, device node (<filename>da0</filename>), speed, |
| 425 |
and size will differ according to the device.</para> |
| 426 |
|
| 427 |
<para>Since the <acronym>USB</acronym> device is seen as a |
| 428 |
<acronym>SCSI</acronym> one, <command>camcontrol</command> can |
| 429 |
be used to list the <acronym>USB</acronym> storage devices |
| 430 |
attached to the system:</para> |
| 431 |
|
| 432 |
<screen>&prompt.root; <userinput>camcontrol devlist</userinput> |
| 433 |
<STECH Simple Drive 1.04> at scbus4 target 0 lun 0 (pass3,da0)</screen> |
| 434 |
|
| 435 |
<para>Alternately, <command>usbconfig</command> can be used to |
| 436 |
list the device. Refer to &man.usbconfig.8; for more |
| 437 |
information about this command.</para> |
| 438 |
|
| 439 |
<screen>&prompt.root; <userinput>usbconfig</userinput> |
| 440 |
ugen0.3: <Simple Drive STECH> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)</screen> |
| 441 |
|
| 442 |
<para>If the device has not been formatted, refer to <xref |
| 443 |
linkend="disks-adding"/> for instructions on how to format |
| 444 |
and create partitions on the <acronym>USB</acronym> drive. If |
| 445 |
the drive comes with a file system, it can be mounted by |
| 446 |
<systemitem class="username">root</systemitem> using the |
| 447 |
instructions in <xref linkend="mount-unmount"/>.</para> |
| 448 |
|
| 449 |
<warning> |
| 450 |
<para>Allowing untrusted users to mount arbitrary media, by |
| 451 |
enabling <varname>vfs.usermount</varname> as described |
| 452 |
below, should not be considered safe from a security point |
| 453 |
of view. Most file systems were not built to safeguard |
| 454 |
against malicious devices.</para> |
| 455 |
</warning> |
| 456 |
|
| 457 |
<para>To make the device mountable as a normal user, one |
| 458 |
solution is to make all users of the device a member of the |
| 459 |
<systemitem class="groupname">operator</systemitem> group |
| 460 |
using &man.pw.8;. Next, ensure that <systemitem |
| 461 |
class="groupname">operator</systemitem> is able to read and |
| 462 |
write the device by adding these lines to |
| 463 |
<filename>/etc/devfs.rules</filename>:</para> |
| 464 |
|
| 465 |
<programlisting>[localrules=5] |
| 466 |
add path 'da*' mode 0660 group operator</programlisting> |
| 467 |
|
| 468 |
<note> |
| 469 |
<para>If internal <acronym>SCSI</acronym> disks are also |
| 470 |
installed in the system, change the second line as |
| 471 |
follows:</para> |
| 472 |
|
| 473 |
<programlisting>add path 'da[<replaceable>3</replaceable>-9]*' mode 0660 group operator</programlisting> |
| 474 |
|
| 475 |
<para>This will exclude the first three |
| 476 |
<acronym>SCSI</acronym> disks (<filename>da0</filename> to |
| 477 |
<filename>da2</filename>)from belonging to the <systemitem |
| 478 |
class="groupname">operator</systemitem> group. Replace |
| 479 |
<replaceable>3</replaceable> with the number of internal |
| 480 |
<acronym>SCSI</acronym> disks. Refer to &man.devfs.rules.5; |
| 481 |
for more information about this file.</para> |
| 482 |
</note> |
| 483 |
|
| 484 |
<para>Next, enable the ruleset in |
| 485 |
<filename>/etc/rc.conf</filename>:</para> |
| 486 |
|
| 487 |
<programlisting>devfs_system_ruleset="localrules"</programlisting> |
| 488 |
|
| 489 |
<para>Then, instruct the system to allow regular users to mount |
| 490 |
file systems by adding the following line to |
| 491 |
<filename>/etc/sysctl.conf</filename>:</para> |
| 492 |
|
| 493 |
<programlisting>vfs.usermount=1</programlisting> |
| 494 |
|
| 495 |
<para>Since this only takes effect after the next reboot, use |
| 496 |
<command>sysctl</command> to set this variable now:</para> |
| 497 |
|
| 498 |
<screen>&prompt.root; <userinput>sysctl vfs.usermount=1</userinput> |
| 499 |
vfs.usermount: 0 -> 1</screen> |
| 500 |
|
| 501 |
<para>The final step is to create a directory where the file |
| 502 |
system is to be mounted. This directory needs to be owned by |
| 503 |
the user that is to mount the file system. One way to do that |
| 504 |
is for <systemitem class="username">root</systemitem> to |
| 505 |
create a subdirectory owned by that user as <filename |
| 506 |
>/mnt/<replaceable>username</replaceable></filename>. |
| 507 |
In the following example, replace |
| 508 |
<replaceable>username</replaceable> with the login name of the |
| 509 |
user and <replaceable>usergroup</replaceable> with the user's |
| 510 |
primary group:</para> |
| 511 |
|
| 512 |
<screen>&prompt.root; <userinput>mkdir /mnt/<replaceable>username</replaceable></userinput> |
| 513 |
&prompt.root; <userinput>chown <replaceable>username</replaceable>:<replaceable>usergroup</replaceable> /mnt/<replaceable>username</replaceable></userinput></screen> |
| 514 |
|
| 515 |
<para>Suppose a <acronym>USB</acronym> thumbdrive is plugged in, |
| 516 |
and a device <filename>/dev/da0s1</filename> appears. If the |
| 517 |
device is formatted with a <acronym>FAT</acronym> file system, |
| 518 |
the user can mount it using:</para> |
| 519 |
|
| 520 |
<screen>&prompt.user; <userinput>mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/<replaceable>username</replaceable></userinput></screen> |
| 521 |
|
| 522 |
<para>Before the device can be unplugged, it |
| 523 |
<emphasis>must</emphasis> be unmounted first:</para> |
| 524 |
|
| 525 |
<screen>&prompt.user; <userinput>umount /mnt/<replaceable>username</replaceable></userinput></screen> |
| 526 |
|
| 527 |
<para>After device removal, the system message buffer will show |
| 528 |
messages similar to the following:</para> |
| 529 |
|
| 530 |
<screen>umass0: at uhub3, port 2, addr 3 (disconnected) |
| 531 |
da0 at umass-sim0 bus 0 scbus4 target 0 lun 0 |
| 532 |
da0: <STECH Simple Drive 1.04> s/n WD-WXE508CAN263 detached |
| 533 |
(da0:umass-sim0:0:0:0): Periph destroyed</screen> |
| 534 |
</sect2> |
| 535 |
|
| 536 |
<sect2> |
| 537 |
<title>Automounting Removable Media</title> |
| 538 |
|
| 539 |
<para><acronym>USB</acronym> devices can be automatically |
| 540 |
mounted by uncommenting this line in |
| 541 |
<filename>/etc/auto_master</filename>:</para> |
| 542 |
|
| 543 |
<screen>/media -media -nosuid</screen> |
| 544 |
|
| 545 |
<para>Then add these lines to |
| 546 |
<filename>/etc/devd.conf</filename>:</para> |
| 547 |
|
| 548 |
<screen>notify 100 { |
| 549 |
match "system" "GEOM"; |
| 550 |
match "subsystem" "DEV"; |
| 551 |
action "/usr/sbin/automount -c"; |
| 552 |
};</screen> |
| 553 |
|
| 554 |
<para>Reload the configuration if &man.autofs.5; |
| 555 |
and &man.devd.8; are already running:</para> |
| 556 |
|
| 557 |
<screen>&prompt.root; <userinput>service automount restart</userinput> |
| 558 |
&prompt.root; <userinput>service devd restart</userinput></screen> |
| 559 |
|
| 560 |
<para>&man.autofs.5; can be set to start at boot by adding this |
| 561 |
line to <filename>/etc/rc.conf</filename>:</para> |
| 562 |
|
| 563 |
<programlisting>autofs_enable="YES"</programlisting> |
| 564 |
|
| 565 |
<para>&man.autofs.5; requires &man.devd.8; to be enabled, as it |
| 566 |
is by default.</para> |
| 567 |
|
| 568 |
<para>Start the services immediately with:</para> |
| 569 |
|
| 570 |
<screen>&prompt.root; <userinput>service automount start</userinput> |
| 571 |
&prompt.root; <userinput>service automountd start</userinput> |
| 572 |
&prompt.root; <userinput>service autounmountd start</userinput> |
| 573 |
&prompt.root; <userinput>service devd start</userinput></screen> |
| 574 |
|
| 575 |
<para>Each file system that can be automatically mounted appears |
| 576 |
as a directory in <filename>/media/</filename>. The directory |
| 577 |
is named after the file system label. If the label is |
| 578 |
missing, the directory is named after the device node.</para> |
| 579 |
|
| 580 |
<para>The file system is transparently mounted on the first |
| 581 |
access, and unmounted after a period of inactivity. |
| 582 |
Automounted drives can also be unmounted manually:</para> |
| 583 |
|
| 584 |
<screen>&prompt.root; <userinput>automount -fu</userinput></screen> |
| 585 |
|
| 586 |
<para>This mechanism is typically used for memory cards and |
| 587 |
<acronym>USB</acronym> memory sticks. It can be used with |
| 588 |
any block device, including optical drives or |
| 589 |
<acronym>iSCSI</acronym> <acronym>LUN</acronym>s.</para> |
| 590 |
</sect2> |
| 591 |
</sect1> |
| 592 |
|
| 593 |
<sect1 xml:id="creating-cds"> |
| 594 |
<info> |
| 595 |
<title>Creating and Using <acronym>CD</acronym> Media</title> |
| 596 |
|
| 597 |
<authorgroup> |
| 598 |
<author> |
| 599 |
<personname> |
| 600 |
<firstname>Mike</firstname> |
| 601 |
<surname>Meyer</surname> |
| 602 |
</personname> |
| 603 |
<contrib>Contributed by </contrib> |
| 604 |
</author> |
| 605 |
</authorgroup> |
| 606 |
</info> |
| 607 |
|
| 608 |
<indexterm> |
| 609 |
<primary><acronym>CD-ROM</acronym>s</primary> |
| 610 |
<secondary>creating</secondary> |
| 611 |
</indexterm> |
| 612 |
|
| 613 |
<para>Compact Disc (<acronym>CD</acronym>) media provide a number |
| 614 |
of features that differentiate them from conventional disks. |
| 615 |
They are designed so that they can be read continuously without |
| 616 |
delays to move the head between tracks. While |
| 617 |
<acronym>CD</acronym> media do have tracks, these refer to a |
| 618 |
section of data to be read continuously, and not a physical |
| 619 |
property of the disk. The <acronym>ISO</acronym> 9660 file |
| 620 |
system was designed to deal with these differences.</para> |
| 621 |
|
| 622 |
<indexterm><primary><acronym>ISO</acronym> |
| 623 |
9660</primary></indexterm> |
| 624 |
<indexterm> |
| 625 |
<primary>file systems</primary> |
| 626 |
<secondary>ISO 9660</secondary> |
| 627 |
</indexterm> |
| 628 |
|
| 629 |
<indexterm> |
| 630 |
<primary><acronym>CD</acronym> burner</primary> |
| 631 |
<secondary><acronym>ATAPI</acronym></secondary> |
| 632 |
</indexterm> |
| 633 |
|
| 634 |
<para>The &os; Ports Collection provides several utilities for |
| 635 |
burning and duplicating audio and data <acronym>CD</acronym>s. |
| 636 |
This chapter demonstrates the use of several command line |
| 637 |
utilities. For <acronym>CD</acronym> burning software with a |
| 638 |
graphical utility, consider installing the |
| 639 |
<package>sysutils/xcdroast</package> or |
| 640 |
<package>sysutils/k3b</package> packages or ports.</para> |
| 641 |
|
| 642 |
<sect2 xml:id="atapicam"> |
| 643 |
<info> |
| 644 |
<title>Supported Devices</title> |
| 645 |
|
| 646 |
<authorgroup> |
| 647 |
<author> |
| 648 |
<personname> |
| 649 |
<firstname>Marc</firstname> |
| 650 |
<surname>Fonvieille</surname> |
| 651 |
</personname> |
| 652 |
<contrib>Contributed by </contrib> |
| 653 |
</author> |
| 654 |
</authorgroup> |
| 655 |
</info> |
| 656 |
|
| 657 |
<indexterm> |
| 658 |
<primary><acronym>CD</acronym> burner</primary> |
| 659 |
<secondary>ATAPI/CAM driver</secondary> |
| 660 |
</indexterm> |
| 661 |
|
| 662 |
<para>The <filename>GENERIC</filename> kernel provides support |
| 663 |
for <acronym>SCSI</acronym>, <acronym>USB</acronym>, and |
| 664 |
<acronym>ATAPI</acronym> <acronym>CD</acronym> readers and |
| 665 |
burners. If a custom kernel is used, the options that need to |
| 666 |
be present in the kernel configuration file vary by the type |
| 667 |
of device.</para> |
| 668 |
|
| 669 |
<para>For a <acronym>SCSI</acronym> burner, make sure these |
| 670 |
options are present:</para> |
| 671 |
|
| 672 |
<programlisting>device scbus # SCSI bus (required for ATA/SCSI) |
| 673 |
device da # Direct Access (disks) |
| 674 |
device pass # Passthrough device (direct ATA/SCSI access) |
| 675 |
device cd # needed for CD and DVD burners</programlisting> |
| 676 |
|
| 677 |
<para>For a <acronym>USB</acronym> burner, make sure these |
| 678 |
options are present:</para> |
| 679 |
|
| 680 |
<programlisting>device scbus # SCSI bus (required for ATA/SCSI) |
| 681 |
device da # Direct Access (disks) |
| 682 |
device pass # Passthrough device (direct ATA/SCSI access) |
| 683 |
device cd # needed for CD and DVD burners |
| 684 |
device uhci # provides USB 1.x support |
| 685 |
device ohci # provides USB 1.x support |
| 686 |
device ehci # provides USB 2.0 support |
| 687 |
device xhci # provides USB 3.0 support |
| 688 |
device usb # USB Bus (required) |
| 689 |
device umass # Disks/Mass storage - Requires scbus and da</programlisting> |
| 690 |
|
| 691 |
<para>For an <acronym>ATAPI</acronym> burner, make sure these |
| 692 |
options are present:</para> |
| 693 |
|
| 694 |
<programlisting>device ata # Legacy ATA/SATA controllers |
| 695 |
device scbus # SCSI bus (required for ATA/SCSI) |
| 696 |
device pass # Passthrough device (direct ATA/SCSI access) |
| 697 |
device cd # needed for CD and DVD burners</programlisting> |
| 698 |
|
| 699 |
<note> |
| 700 |
<para>On &os; versions prior to 10.x, this line is also |
| 701 |
needed in the kernel configuration file if the burner is an |
| 702 |
<acronym>ATAPI</acronym> device:</para> |
| 703 |
|
| 704 |
<programlisting>device atapicam</programlisting> |
| 705 |
|
| 706 |
<para>Alternately, this driver can be loaded at boot time by |
| 707 |
adding the following line to |
| 708 |
<filename>/boot/loader.conf</filename>:</para> |
| 709 |
|
| 710 |
<programlisting>atapicam_load="YES"</programlisting> |
| 711 |
|
| 712 |
<para>This will require a reboot of the system as this driver |
| 713 |
can only be loaded at boot time.</para> |
| 714 |
</note> |
| 715 |
|
| 716 |
<para>To verify that &os; recognizes the device, run |
| 717 |
<command>dmesg</command> and look for an entry for the device. |
| 718 |
On systems prior to 10.x, the device name in the first line of |
| 719 |
the output will be <filename>acd0</filename> instead of |
| 720 |
<filename>cd0</filename>.</para> |
| 721 |
|
| 722 |
<screen>&prompt.user; <userinput>dmesg | grep cd</userinput> |
| 723 |
cd0 at ahcich1 bus 0 scbus1 target 0 lun 0 |
| 724 |
cd0: <HL-DT-ST DVDRAM GU70N LT20> Removable CD-ROM SCSI-0 device |
| 725 |
cd0: Serial Number M3OD3S34152 |
| 726 |
cd0: 150.000MB/s transfers (SATA 1.x, UDMA6, ATAPI 12bytes, PIO 8192bytes) |
| 727 |
cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed</screen> |
| 728 |
</sect2> |
| 729 |
|
| 730 |
<sect2 xml:id="cdrecord"> |
| 731 |
<title>Burning a <acronym>CD</acronym></title> |
| 732 |
|
| 733 |
<para>In &os;, <command>cdrecord</command> can be used to burn |
| 734 |
<acronym>CD</acronym>s. This command is installed with the |
| 735 |
<package>sysutils/cdrtools</package> package or port.</para> |
| 736 |
|
| 737 |
<para>While <command>cdrecord</command> has many options, basic |
| 738 |
usage is simple. Specify the name of the |
| 739 |
<acronym>ISO</acronym> file to burn and, if the system has |
| 740 |
multiple burner devices, specify the name of the device to |
| 741 |
use:</para> |
| 742 |
|
| 743 |
<screen>&prompt.root; <userinput>cdrecord <replaceable>dev=device</replaceable> <replaceable>imagefile.iso</replaceable></userinput></screen> |
| 744 |
|
| 745 |
<para>To determine the device name of the burner, use |
| 746 |
<option>-scanbus</option> which might produce results like |
| 747 |
this:</para> |
| 748 |
|
| 749 |
<indexterm> |
| 750 |
<primary><acronym>CD-ROM</acronym>s</primary> |
| 751 |
<secondary>burning</secondary> |
| 752 |
</indexterm> |
| 753 |
<screen>&prompt.root; <userinput>cdrecord -scanbus</userinput> |
| 754 |
ProDVD-ProBD-Clone 3.00 (amd64-unknown-freebsd10.0) Copyright (C) 1995-2010 Jörg Schilling |
| 755 |
Using libscg version 'schily-0.9' |
| 756 |
scsibus0: |
| 757 |
0,0,0 0) 'SEAGATE ' 'ST39236LW ' '0004' Disk |
| 758 |
0,1,0 1) 'SEAGATE ' 'ST39173W ' '5958' Disk |
| 759 |
0,2,0 2) * |
| 760 |
0,3,0 3) 'iomega ' 'jaz 1GB ' 'J.86' Removable Disk |
| 761 |
0,4,0 4) 'NEC ' 'CD-ROM DRIVE:466' '1.26' Removable CD-ROM |
| 762 |
0,5,0 5) * |
| 763 |
0,6,0 6) * |
| 764 |
0,7,0 7) * |
| 765 |
scsibus1: |
| 766 |
1,0,0 100) * |
| 767 |
1,1,0 101) * |
| 768 |
1,2,0 102) * |
| 769 |
1,3,0 103) * |
| 770 |
1,4,0 104) * |
| 771 |
1,5,0 105) 'YAMAHA ' 'CRW4260 ' '1.0q' Removable CD-ROM |
| 772 |
1,6,0 106) 'ARTEC ' 'AM12S ' '1.06' Scanner |
| 773 |
1,7,0 107) *</screen> |
| 774 |
|
| 775 |
<para>Locate the entry for the <acronym>CD</acronym> burner and |
| 776 |
use the three numbers separated by commas as the value for |
| 777 |
<option>dev</option>. In this case, the Yamaha burner device |
| 778 |
is <literal>1,5,0</literal>, so the appropriate input to |
| 779 |
specify that device is <option>dev=1,5,0</option>. Refer to |
| 780 |
the manual page for <command>cdrecord</command> for other ways |
| 781 |
to specify this value and for information on writing audio |
| 782 |
tracks and controlling the write speed.</para> |
| 783 |
|
| 784 |
<para>Alternately, run the following command to get the device |
| 785 |
address of the burner:</para> |
| 786 |
|
| 787 |
<screen>&prompt.root; <userinput>camcontrol devlist</userinput> |
| 788 |
<MATSHITA CDRW/DVD UJDA740 1.00> at scbus1 target 0 lun 0 (cd0,pass0)</screen> |
| 789 |
|
| 790 |
<para>Use the numeric values for <literal>scbus</literal>, |
| 791 |
<literal>target</literal>, and <literal>lun</literal>. For |
| 792 |
this example, <literal>1,0,0</literal> is the device name to |
| 793 |
use.</para> |
| 794 |
</sect2> |
| 795 |
|
| 796 |
<sect2 xml:id="mkisofs"> |
| 797 |
<title>Writing Data to an <acronym>ISO</acronym> File |
| 798 |
System</title> |
| 799 |
|
| 800 |
<para>In order to produce a data <acronym>CD</acronym>, the data |
| 801 |
files that are going to make up the tracks on the |
| 802 |
<acronym>CD</acronym> must be prepared before they can be |
| 803 |
burned to the <acronym>CD</acronym>. In &os;, |
| 804 |
<package>sysutils/cdrtools</package> installs |
| 805 |
<command>mkisofs</command>, which can be used to produce an |
| 806 |
<acronym>ISO</acronym> 9660 file system that is an image of a |
| 807 |
directory tree within a &unix; file system. The simplest |
| 808 |
usage is to specify the name of the <acronym>ISO</acronym> |
| 809 |
file to create and the path to the files to place into the |
| 810 |
<acronym>ISO</acronym> 9660 file system:</para> |
| 811 |
|
| 812 |
<screen>&prompt.root; <userinput>mkisofs -o <replaceable>imagefile.iso</replaceable> <replaceable>/path/to/tree</replaceable></userinput></screen> |
| 813 |
|
| 814 |
<indexterm> |
| 815 |
<primary>file systems</primary> |
| 816 |
<secondary>ISO 9660</secondary> |
| 817 |
</indexterm> |
| 818 |
|
| 819 |
<para>This command maps the file names in the specified path to |
| 820 |
names that fit the limitations of the standard |
| 821 |
<acronym>ISO</acronym> 9660 file system, and will exclude |
| 822 |
files that do not meet the standard for <acronym>ISO</acronym> |
| 823 |
file systems.</para> |
| 824 |
|
| 825 |
<indexterm> |
| 826 |
<primary>file systems</primary> |
| 827 |
<secondary>Joliet</secondary> |
| 828 |
</indexterm> |
| 829 |
|
| 830 |
<para>A number of options are available to overcome the |
| 831 |
restrictions imposed by the standard. In particular, |
| 832 |
<option>-R</option> enables the Rock Ridge extensions common |
| 833 |
to &unix; systems and <option>-J</option> enables Joliet |
| 834 |
extensions used by µsoft; systems.</para> |
| 835 |
|
| 836 |
<para>For <acronym>CD</acronym>s that are going to be used only |
| 837 |
on &os; systems, <option>-U</option> can be used to disable |
| 838 |
all filename restrictions. When used with |
| 839 |
<option>-R</option>, it produces a file system image that is |
| 840 |
identical to the specified &os; tree, even if it violates the |
| 841 |
<acronym>ISO</acronym> 9660 standard.</para> |
| 842 |
|
| 843 |
<indexterm> |
| 844 |
<primary><acronym>CD-ROM</acronym>s</primary> |
| 845 |
<secondary>creating bootable</secondary> |
| 846 |
</indexterm> |
| 847 |
|
| 848 |
<para>The last option of general use is <option>-b</option>. |
| 849 |
This is used to specify the location of a boot image for use |
| 850 |
in producing an <quote>El Torito</quote> bootable |
| 851 |
<acronym>CD</acronym>. This option takes an argument which is |
| 852 |
the path to a boot image from the top of the tree being |
| 853 |
written to the <acronym>CD</acronym>. By default, |
| 854 |
<command>mkisofs</command> creates an <acronym>ISO</acronym> |
| 855 |
image in <quote>floppy disk emulation</quote> mode, and thus |
| 856 |
expects the boot image to be exactly 1200, 1440 or |
| 857 |
2880 KB in size. Some boot loaders, like the one used by |
| 858 |
the &os; distribution media, do not use emulation mode. In |
| 859 |
this case, <option>-no-emul-boot</option> should be used. So, |
| 860 |
if <filename>/tmp/myboot</filename> holds a bootable &os; |
| 861 |
system with the boot image in |
| 862 |
<filename>/tmp/myboot/boot/cdboot</filename>, this command |
| 863 |
would produce |
| 864 |
<filename>/tmp/bootable.iso</filename>:</para> |
| 865 |
|
| 866 |
<screen>&prompt.root; <userinput>mkisofs -R -no-emul-boot -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot</userinput></screen> |
| 867 |
|
| 868 |
<para>The resulting <acronym>ISO</acronym> image can be mounted |
| 869 |
as a memory disk with:</para> |
| 870 |
|
| 871 |
<screen>&prompt.root; <userinput>mdconfig -a -t vnode -f /tmp/bootable.iso -u 0</userinput> |
| 872 |
&prompt.root; <userinput>mount -t cd9660 /dev/md0 /mnt</userinput></screen> |
| 873 |
|
| 874 |
<para>One can then verify that <filename>/mnt</filename> and |
| 875 |
<filename>/tmp/myboot</filename> are identical.</para> |
| 876 |
|
| 877 |
<para>There are many other options available for |
| 878 |
<command>mkisofs</command> to fine-tune its behavior. Refer |
| 879 |
to &man.mkisofs.8; for details.</para> |
| 880 |
|
| 881 |
<note> |
| 882 |
<para>It is possible to copy a data <acronym>CD</acronym> to |
| 883 |
an image file that is functionally equivalent to the image |
| 884 |
file created with <command>mkisofs</command>. To do so, use |
| 885 |
<filename>dd</filename> with the device name as the input |
| 886 |
file and the name of the <acronym>ISO</acronym> to create as |
| 887 |
the output file:</para> |
| 888 |
|
| 889 |
<screen>&prompt.root; <userinput>dd if=/dev/<replaceable>cd0</replaceable> of=<replaceable>file.iso</replaceable> bs=2048</userinput></screen> |
| 890 |
|
| 891 |
<para>The resulting image file can be burned to |
| 892 |
<acronym>CD</acronym> as described in <xref |
| 893 |
linkend="cdrecord"/>.</para> |
| 894 |
</note> |
| 895 |
</sect2> |
| 896 |
|
| 897 |
<sect2 xml:id="mounting-cd"> |
| 898 |
<title>Using Data <acronym>CD</acronym>s</title> |
| 899 |
|
| 900 |
<para>Once an <acronym>ISO</acronym> has been burned to a |
| 901 |
<acronym>CD</acronym>, it can be mounted by specifying the |
| 902 |
file system type, the name of the device containing the |
| 903 |
<acronym>CD</acronym>, and an existing mount point:</para> |
| 904 |
|
| 905 |
<screen>&prompt.root; <userinput>mount -t cd9660 <replaceable>/dev/cd0</replaceable> <replaceable>/mnt</replaceable></userinput></screen> |
| 906 |
|
| 907 |
<para>Since <command>mount</command> assumes that a file system |
| 908 |
is of type <literal>ufs</literal>, a <errorname>Incorrect |
| 909 |
super block</errorname> error will occur if <literal>-t |
| 910 |
cd9660</literal> is not included when mounting a data |
| 911 |
<acronym>CD</acronym>.</para> |
| 912 |
|
| 913 |
<para>While any data <acronym>CD</acronym> can be mounted this |
| 914 |
way, disks with certain <acronym>ISO</acronym> 9660 extensions |
| 915 |
might behave oddly. For example, Joliet disks store all |
| 916 |
filenames in two-byte Unicode characters. If some non-English |
| 917 |
characters show up as question marks, specify the local |
| 918 |
charset with <option>-C</option>. For more information, refer |
| 919 |
to &man.mount.cd9660.8;.</para> |
| 920 |
|
| 921 |
<note> |
| 922 |
<para>In order to do this character conversion with the help |
| 923 |
of <option>-C</option>, the kernel requires the |
| 924 |
<filename>cd9660_iconv.ko</filename> module to be loaded. |
| 925 |
This can be done either by adding this line to |
| 926 |
<filename>loader.conf</filename>:</para> |
| 927 |
|
| 928 |
<programlisting>cd9660_iconv_load="YES"</programlisting> |
| 929 |
|
| 930 |
<para>and then rebooting the machine, or by directly loading |
| 931 |
the module with <command>kldload</command>.</para> |
| 932 |
</note> |
| 933 |
|
| 934 |
<para>Occasionally, <errorname>Device not configured</errorname> |
| 935 |
will be displayed when trying to mount a data |
| 936 |
<acronym>CD</acronym>. This usually means that the |
| 937 |
<acronym>CD</acronym> drive has not detected a disk in |
| 938 |
the tray, or that the drive is not visible on the bus. It |
| 939 |
can take a couple of seconds for a <acronym>CD</acronym> |
| 940 |
drive to detect media, so be |
| 941 |
patient.</para> |
| 942 |
|
| 943 |
<para>Sometimes, a <acronym>SCSI</acronym> |
| 944 |
<acronym>CD</acronym> drive may be missed because it did not |
| 945 |
have enough time to answer the bus reset. To resolve this, |
| 946 |
a custom kernel can be created which increases the default |
| 947 |
<acronym>SCSI</acronym> delay. Add the following option to |
| 948 |
the custom kernel configuration file and rebuild the kernel |
| 949 |
using the instructions in <xref |
| 950 |
linkend="kernelconfig-building"/>:</para> |
| 951 |
|
| 952 |
<programlisting>options SCSI_DELAY=15000</programlisting> |
| 953 |
|
| 954 |
<para>This tells the <acronym>SCSI</acronym> bus to pause 15 |
| 955 |
seconds during boot, to give the <acronym>CD</acronym> |
| 956 |
drive every possible chance to answer the bus reset.</para> |
| 957 |
|
| 958 |
<note> |
| 959 |
<para>It is possible to burn a file directly to |
| 960 |
<acronym>CD</acronym>, without creating an |
| 961 |
<acronym>ISO</acronym> 9660 file system. This is known as |
| 962 |
burning a raw data <acronym>CD</acronym> and some people do |
| 963 |
this for backup purposes.</para> |
| 964 |
|
| 965 |
<para>This type of disk can not be mounted as a normal data |
| 966 |
<acronym>CD</acronym>. In order to retrieve the data burned |
| 967 |
to such a <acronym>CD</acronym>, the data must be read from |
| 968 |
the raw device node. For example, this command will extract |
| 969 |
a compressed tar file located on the second |
| 970 |
<acronym>CD</acronym> device into the current working |
| 971 |
directory:</para> |
| 972 |
|
| 973 |
<screen>&prompt.root; <userinput>tar xzvf /dev/<replaceable>cd1</replaceable></userinput></screen> |
| 974 |
|
| 975 |
<para> In order to mount a data <acronym>CD</acronym>, the |
| 976 |
data must be written using |
| 977 |
<command>mkisofs</command>.</para> |
| 978 |
</note> |
| 979 |
</sect2> |
| 980 |
|
| 981 |
<sect2 xml:id="duplicating-audiocds"> |
| 982 |
<title>Duplicating Audio <acronym>CD</acronym>s</title> |
| 983 |
|
| 984 |
<para>To duplicate an audio <acronym>CD</acronym>, extract the |
| 985 |
audio data from the <acronym>CD</acronym> to a series of |
| 986 |
files, then write these files to a blank |
| 987 |
<acronym>CD</acronym>.</para> |
| 988 |
|
| 989 |
<para><xref linkend="using-cdrecord"/> describes how to |
| 990 |
duplicate and burn an audio <acronym>CD</acronym>. If the |
| 991 |
&os; version is less than 10.0 and the device is |
| 992 |
<acronym>ATAPI</acronym>, the <option>atapicam</option> module |
| 993 |
must be first loaded using the instructions in <xref |
| 994 |
linkend="atapicam"/>.</para> |
| 995 |
|
| 996 |
<procedure xml:id="using-cdrecord"> |
| 997 |
<title>Duplicating an Audio <acronym>CD</acronym></title> |
| 998 |
|
| 999 |
<step> |
| 1000 |
<para>The <package>sysutils/cdrtools</package> package or |
| 1001 |
port installs <command>cdda2wav</command>. This command |
| 1002 |
can be used to extract all of the audio tracks, with each |
| 1003 |
track written to a separate <acronym>WAV</acronym> file in |
| 1004 |
the current working directory:</para> |
| 1005 |
|
| 1006 |
<screen>&prompt.user; <userinput>cdda2wav -vall -B -Owav</userinput></screen> |
| 1007 |
|
| 1008 |
<para>A device name does not need to be specified if there |
| 1009 |
is only one <acronym>CD</acronym> device on the system. |
| 1010 |
Refer to the <command>cdda2wav</command> manual page for |
| 1011 |
instructions on how to specify a device and to learn more |
| 1012 |
about the other options available for this command.</para> |
| 1013 |
</step> |
| 1014 |
|
| 1015 |
<step> |
| 1016 |
<para>Use <command>cdrecord</command> to write the |
| 1017 |
<filename>.wav</filename> files:</para> |
| 1018 |
|
| 1019 |
<screen>&prompt.user; <userinput>cdrecord -v dev=<replaceable>2,0</replaceable> -dao -useinfo *.wav</userinput></screen> |
| 1020 |
|
| 1021 |
<para>Make sure that <replaceable>2,0</replaceable> is set |
| 1022 |
appropriately, as described in <xref |
| 1023 |
linkend="cdrecord"/>.</para> |
| 1024 |
</step> |
| 1025 |
</procedure> |
| 1026 |
</sect2> |
| 1027 |
</sect1> |
| 1028 |
|
| 1029 |
<sect1 xml:id="creating-dvds"> |
| 1030 |
<info> |
| 1031 |
<title>Creating and Using <acronym>DVD</acronym> Media</title> |
| 1032 |
|
| 1033 |
<authorgroup> |
| 1034 |
<author> |
| 1035 |
<personname> |
| 1036 |
<firstname>Marc</firstname> |
| 1037 |
<surname>Fonvieille</surname> |
| 1038 |
</personname> |
| 1039 |
<contrib>Contributed by </contrib> |
| 1040 |
</author> |
| 1041 |
</authorgroup> |
| 1042 |
<authorgroup> |
| 1043 |
<author> |
| 1044 |
<personname> |
| 1045 |
<firstname>Andy</firstname> |
| 1046 |
<surname>Polyakov</surname> |
| 1047 |
</personname> |
| 1048 |
<contrib>With inputs from </contrib> |
| 1049 |
</author> |
| 1050 |
</authorgroup> |
| 1051 |
</info> |
| 1052 |
|
| 1053 |
<indexterm> |
| 1054 |
<primary><acronym>DVD</acronym></primary> |
| 1055 |
<secondary>burning</secondary> |
| 1056 |
</indexterm> |
| 1057 |
|
| 1058 |
<para>Compared to the <acronym>CD</acronym>, the |
| 1059 |
<acronym>DVD</acronym> is the next generation of optical media |
| 1060 |
storage technology. The <acronym>DVD</acronym> can hold more |
| 1061 |
data than any <acronym>CD</acronym> and is the standard for |
| 1062 |
video publishing.</para> |
| 1063 |
|
| 1064 |
<para>Five physical recordable formats can be defined for a |
| 1065 |
recordable <acronym>DVD</acronym>:</para> |
| 1066 |
|
| 1067 |
<itemizedlist> |
| 1068 |
<listitem> |
| 1069 |
<para>DVD-R: This was the first <acronym>DVD</acronym> |
| 1070 |
recordable format available. The DVD-R standard is defined |
| 1071 |
by the <link |
| 1072 |
xlink:href="http://www.dvdforum.org/forum.shtml"><acronym>DVD</acronym> |
| 1073 |
Forum</link>. This format is write once.</para> |
| 1074 |
</listitem> |
| 1075 |
|
| 1076 |
<listitem> |
| 1077 |
<para><acronym>DVD-RW</acronym>: This is the rewritable |
| 1078 |
version of the DVD-R standard. A |
| 1079 |
<acronym>DVD-RW</acronym> can be rewritten about 1000 |
| 1080 |
times.</para> |
| 1081 |
</listitem> |
| 1082 |
|
| 1083 |
<listitem> |
| 1084 |
<para><acronym>DVD-RAM</acronym>: This is a rewritable format |
| 1085 |
which can be seen as a removable hard drive. However, this |
| 1086 |
media is not compatible with most |
| 1087 |
<acronym>DVD-ROM</acronym> drives and DVD-Video players as |
| 1088 |
only a few <acronym>DVD</acronym> writers support the |
| 1089 |
<acronym>DVD-RAM</acronym> format. Refer to <xref |
| 1090 |
linkend="creating-dvd-ram"/> for more information on |
| 1091 |
<acronym>DVD-RAM</acronym> use.</para> |
| 1092 |
</listitem> |
| 1093 |
|
| 1094 |
<listitem> |
| 1095 |
<para><acronym>DVD+RW</acronym>: This is a rewritable format |
| 1096 |
defined by the <link |
| 1097 |
xlink:href="https://en.wikipedia.org/wiki/DVD%2BRW_Alliance"> |
| 1098 |
<acronym>DVD+RW</acronym> Alliance</link>. A |
| 1099 |
<acronym>DVD+RW</acronym> can be rewritten about 1000 |
| 1100 |
times.</para> |
| 1101 |
</listitem> |
| 1102 |
|
| 1103 |
<listitem> |
| 1104 |
<para>DVD+R: This format is the write once variation of the |
| 1105 |
<acronym>DVD+RW</acronym> format.</para> |
| 1106 |
</listitem> |
| 1107 |
</itemizedlist> |
| 1108 |
|
| 1109 |
<para>A single layer recordable <acronym>DVD</acronym> can hold up |
| 1110 |
to 4,700,000,000 bytes which is actually 4.38 GB or |
| 1111 |
4485 MB as 1 kilobyte is 1024 bytes.</para> |
| 1112 |
|
| 1113 |
<note> |
| 1114 |
<para>A distinction must be made between the physical media and |
| 1115 |
the application. For example, a DVD-Video is a specific file |
| 1116 |
layout that can be written on any recordable |
| 1117 |
<acronym>DVD</acronym> physical media such as DVD-R, DVD+R, or |
| 1118 |
<acronym>DVD-RW</acronym>. Before choosing the type of media, |
| 1119 |
ensure that both the burner and the DVD-Video player are |
| 1120 |
compatible with the media under consideration.</para> |
| 1121 |
</note> |
| 1122 |
|
| 1123 |
<sect2> |
| 1124 |
<title>Configuration</title> |
| 1125 |
|
| 1126 |
<para>To perform <acronym>DVD</acronym> recording, use |
| 1127 |
&man.growisofs.1;. This command is part of the |
| 1128 |
<package>sysutils/dvd+rw-tools</package> utilities which |
| 1129 |
support all <acronym>DVD</acronym> media types.</para> |
| 1130 |
|
| 1131 |
<para>These tools use the <acronym>SCSI</acronym> subsystem to |
| 1132 |
access the devices, therefore <link |
| 1133 |
linkend="atapicam">ATAPI/CAM support</link> must be loaded |
| 1134 |
or statically compiled into the kernel. This support is not |
| 1135 |
needed if the burner uses the <acronym>USB</acronym> |
| 1136 |
interface. Refer to <xref linkend="usb-disks"/> for more |
| 1137 |
details on <acronym>USB</acronym> device configuration.</para> |
| 1138 |
|
| 1139 |
<para>DMA access must also be enabled for |
| 1140 |
<acronym>ATAPI</acronym> devices, by adding the following line |
| 1141 |
to <filename>/boot/loader.conf</filename>:</para> |
| 1142 |
|
| 1143 |
<programlisting>hw.ata.atapi_dma="1"</programlisting> |
| 1144 |
|
| 1145 |
<para>Before attempting to use |
| 1146 |
<application>dvd+rw-tools</application>, consult the <link |
| 1147 |
xlink:href="http://fy.chalmers.se/~appro/linux/DVD+RW/hcn.html">Hardware |
| 1148 |
Compatibility Notes</link>.</para> |
| 1149 |
|
| 1150 |
<note> |
| 1151 |
<para>For a graphical user interface, consider using |
| 1152 |
<package>sysutils/k3b</package> which provides a user |
| 1153 |
friendly interface to &man.growisofs.1; and many other |
| 1154 |
burning tools.</para> |
| 1155 |
</note> |
| 1156 |
</sect2> |
| 1157 |
|
| 1158 |
<sect2> |
| 1159 |
<title>Burning Data <acronym>DVD</acronym>s</title> |
| 1160 |
|
| 1161 |
<para>Since &man.growisofs.1; is a front-end to <link |
| 1162 |
linkend="mkisofs">mkisofs</link>, it will invoke |
| 1163 |
&man.mkisofs.8; to create the file system layout and perform |
| 1164 |
the write on the <acronym>DVD</acronym>. This means that an |
| 1165 |
image of the data does not need to be created before the |
| 1166 |
burning process.</para> |
| 1167 |
|
| 1168 |
<para>To burn to a DVD+R or a DVD-R the data in |
| 1169 |
<filename>/path/to/data</filename>, use the following |
| 1170 |
command:</para> |
| 1171 |
|
| 1172 |
<screen>&prompt.root; <userinput>growisofs -dvd-compat -Z <replaceable>/dev/cd0</replaceable> -J -R <replaceable>/path/to/data</replaceable></userinput></screen> |
| 1173 |
|
| 1174 |
<para>In this example, <option>-J -R</option> is passed to |
| 1175 |
&man.mkisofs.8; to create an ISO 9660 file system with Joliet |
| 1176 |
and Rock Ridge extensions. Refer to &man.mkisofs.8; for more |
| 1177 |
details.</para> |
| 1178 |
|
| 1179 |
<para>For the initial session recording, <option>-Z</option> is |
| 1180 |
used for both single and multiple sessions. Replace |
| 1181 |
<replaceable>/dev/cd0</replaceable>, with the name of the |
| 1182 |
<acronym>DVD</acronym> device. Using |
| 1183 |
<option>-dvd-compat</option> indicates that the disk will be |
| 1184 |
closed and that the recording will be unappendable. This |
| 1185 |
should also provide better media compatibility with |
| 1186 |
<acronym>DVD-ROM</acronym> drives.</para> |
| 1187 |
|
| 1188 |
<para>To burn a pre-mastered image, such as |
| 1189 |
<replaceable>imagefile.iso</replaceable>, use:</para> |
| 1190 |
|
| 1191 |
<screen>&prompt.root; <userinput>growisofs -dvd-compat -Z <replaceable>/dev/cd0</replaceable>=<replaceable>imagefile.iso</replaceable></userinput></screen> |
| 1192 |
|
| 1193 |
<para>The write speed should be detected and automatically set |
| 1194 |
according to the media and the drive being used. To force the |
| 1195 |
write speed, use <option>-speed=</option>. Refer to |
| 1196 |
&man.growisofs.1; for example usage.</para> |
| 1197 |
|
| 1198 |
<note> |
| 1199 |
<para>In order to support working files larger than 4.38GB, an |
| 1200 |
UDF/ISO-9660 hybrid file system must be created by passing |
| 1201 |
<option>-udf -iso-level 3</option> to &man.mkisofs.8; and |
| 1202 |
all related programs, such as &man.growisofs.1;. This is |
| 1203 |
required only when creating an ISO image file or when |
| 1204 |
writing files directly to a disk. Since a disk created this |
| 1205 |
way must be mounted as an UDF file system with |
| 1206 |
&man.mount.udf.8;, it will be usable only on an UDF aware |
| 1207 |
operating system. Otherwise it will look as if it contains |
| 1208 |
corrupted files.</para> |
| 1209 |
|
| 1210 |
<para>To create this type of ISO file:</para> |
| 1211 |
|
| 1212 |
<screen>&prompt.user; <userinput>mkisofs -R -J -udf -iso-level 3 -o <replaceable>imagefile.iso</replaceable> <replaceable>/path/to/data</replaceable></userinput></screen> |
| 1213 |
|
| 1214 |
<para>To burn files directly to a disk:</para> |
| 1215 |
|
| 1216 |
<screen>&prompt.root; <userinput>growisofs -dvd-compat -udf -iso-level 3 -Z <replaceable>/dev/cd0</replaceable> -J -R <replaceable>/path/to/data</replaceable></userinput></screen> |
| 1217 |
|
| 1218 |
<para>When an ISO image already contains large files, no |
| 1219 |
additional options are required for &man.growisofs.1; to |
| 1220 |
burn that image on a disk.</para> |
| 1221 |
|
| 1222 |
<para>Be sure to use an up-to-date version of |
| 1223 |
<package>sysutils/cdrtools</package>, which contains |
| 1224 |
&man.mkisofs.8;, as an older version may not contain large |
| 1225 |
files support. If the latest version does not work, install |
| 1226 |
<package>sysutils/cdrtools-devel</package> and read its |
| 1227 |
&man.mkisofs.8;.</para> |
| 1228 |
</note> |
| 1229 |
</sect2> |
| 1230 |
|
| 1231 |
<sect2> |
| 1232 |
<title>Burning a <acronym>DVD</acronym>-Video</title> |
| 1233 |
|
| 1234 |
<indexterm> |
| 1235 |
<primary><acronym>DVD</acronym></primary> |
| 1236 |
<secondary>DVD-Video</secondary> |
| 1237 |
</indexterm> |
| 1238 |
|
| 1239 |
<para>A DVD-Video is a specific file layout based on the ISO |
| 1240 |
9660 and micro-UDF (M-UDF) specifications. Since DVD-Video |
| 1241 |
presents a specific data structure hierarchy, a particular |
| 1242 |
program such as <package>multimedia/dvdauthor</package> is |
| 1243 |
needed to author the <acronym>DVD</acronym>.</para> |
| 1244 |
|
| 1245 |
<para>If an image of the DVD-Video file system already exists, |
| 1246 |
it can be burned in the same way as any other image. If |
| 1247 |
<command>dvdauthor</command> was used to make the |
| 1248 |
<acronym>DVD</acronym> and the result is in |
| 1249 |
<filename>/path/to/video</filename>, the following command |
| 1250 |
should be used to burn the DVD-Video:</para> |
| 1251 |
|
| 1252 |
<screen>&prompt.root; <userinput>growisofs -Z <replaceable>/dev/cd0</replaceable> -dvd-video <replaceable>/path/to/video</replaceable></userinput></screen> |
| 1253 |
|
| 1254 |
<para><option>-dvd-video</option> is passed to &man.mkisofs.8; |
| 1255 |
to instruct it to create a DVD-Video file system layout. |
| 1256 |
This option implies the <option>-dvd-compat</option> |
| 1257 |
&man.growisofs.1; option.</para> |
| 1258 |
</sect2> |
| 1259 |
|
| 1260 |
<sect2> |
| 1261 |
<title>Using a <acronym>DVD+RW</acronym></title> |
| 1262 |
|
| 1263 |
<indexterm> |
| 1264 |
<primary><acronym>DVD</acronym></primary> |
| 1265 |
<secondary><acronym>DVD+RW</acronym></secondary> |
| 1266 |
</indexterm> |
| 1267 |
|
| 1268 |
<para>Unlike CD-RW, a virgin <acronym>DVD+RW</acronym> needs to |
| 1269 |
be formatted before first use. It is |
| 1270 |
<emphasis>recommended</emphasis> to let &man.growisofs.1; take |
| 1271 |
care of this automatically whenever appropriate. However, it |
| 1272 |
is possible to use <command>dvd+rw-format</command> to format |
| 1273 |
the <acronym>DVD+RW</acronym>:</para> |
| 1274 |
|
| 1275 |
<screen>&prompt.root; <userinput>dvd+rw-format <replaceable>/dev/cd0</replaceable></userinput></screen> |
| 1276 |
|
| 1277 |
<para>Only perform this operation once and keep in mind that |
| 1278 |
only virgin <acronym>DVD+RW</acronym> medias need to be |
| 1279 |
formatted. Once formatted, the <acronym>DVD+RW</acronym> can |
| 1280 |
be burned as usual.</para> |
| 1281 |
|
| 1282 |
<para>To burn a totally new file system and not just append some |
| 1283 |
data onto a <acronym>DVD+RW</acronym>, the media does not need |
| 1284 |
to be blanked first. Instead, write over the previous |
| 1285 |
recording like this:</para> |
| 1286 |
|
| 1287 |
<screen>&prompt.root; <userinput>growisofs -Z <replaceable>/dev/cd0</replaceable> -J -R <replaceable>/path/to/newdata</replaceable></userinput></screen> |
| 1288 |
|
| 1289 |
<para>The <acronym>DVD+RW</acronym> format supports appending |
| 1290 |
data to a previous recording. This operation consists of |
| 1291 |
merging a new session to the existing one as it is not |
| 1292 |
considered to be multi-session writing. &man.growisofs.1; |
| 1293 |
will <emphasis>grow</emphasis> the ISO 9660 file system |
| 1294 |
present on the media.</para> |
| 1295 |
|
| 1296 |
<para>For example, to append data to a |
| 1297 |
<acronym>DVD+RW</acronym>, use the following:</para> |
| 1298 |
|
| 1299 |
<screen>&prompt.root; <userinput>growisofs -M <replaceable>/dev/cd0</replaceable> -J -R <replaceable>/path/to/nextdata</replaceable></userinput></screen> |
| 1300 |
|
| 1301 |
<para>The same &man.mkisofs.8; options used to burn the |
| 1302 |
initial session should be used during next writes.</para> |
| 1303 |
|
| 1304 |
<note> |
| 1305 |
<para>Use <option>-dvd-compat</option> for better media |
| 1306 |
compatibility with <acronym>DVD-ROM</acronym> drives. When |
| 1307 |
using <acronym>DVD+RW</acronym>, this option will not |
| 1308 |
prevent the addition of data.</para> |
| 1309 |
</note> |
| 1310 |
|
| 1311 |
<para>To blank the media, use:</para> |
| 1312 |
|
| 1313 |
<screen>&prompt.root; <userinput>growisofs -Z <replaceable>/dev/cd0</replaceable>=<replaceable>/dev/zero</replaceable></userinput></screen> |
| 1314 |
</sect2> |
| 1315 |
|
| 1316 |
<sect2> |
| 1317 |
<title>Using a <acronym>DVD-RW</acronym></title> |
| 1318 |
|
| 1319 |
<indexterm> |
| 1320 |
<primary><acronym>DVD</acronym></primary> |
| 1321 |
<secondary><acronym>DVD-RW</acronym></secondary> |
| 1322 |
</indexterm> |
| 1323 |
|
| 1324 |
<para>A <acronym>DVD-RW</acronym> accepts two disc formats: |
| 1325 |
incremental sequential and restricted overwrite. By default, |
| 1326 |
<acronym>DVD-RW</acronym> discs are in sequential |
| 1327 |
format.</para> |
| 1328 |
|
| 1329 |
<para>A virgin <acronym>DVD-RW</acronym> can be directly written |
| 1330 |
without being formatted. However, a non-virgin |
| 1331 |
<acronym>DVD-RW</acronym> in sequential format needs to be |
| 1332 |
blanked before writing a new initial session.</para> |
| 1333 |
|
| 1334 |
<para>To blank a <acronym>DVD-RW</acronym> in sequential |
| 1335 |
mode:</para> |
| 1336 |
|
| 1337 |
<screen>&prompt.root; <userinput>dvd+rw-format -blank=full <replaceable>/dev/cd0</replaceable></userinput></screen> |
| 1338 |
|
| 1339 |
<note> |
| 1340 |
<para>A full blanking using <option>-blank=full</option> will |
| 1341 |
take about one hour on a 1x media. A fast blanking can be |
| 1342 |
performed using <option>-blank</option>, if the |
| 1343 |
<acronym>DVD-RW</acronym> will be recorded in Disk-At-Once |
| 1344 |
(DAO) mode. To burn the <acronym>DVD-RW</acronym> in DAO |
| 1345 |
mode, use the command:</para> |
| 1346 |
|
| 1347 |
<screen>&prompt.root; <userinput>growisofs -use-the-force-luke=dao -Z <replaceable>/dev/cd0</replaceable>=<replaceable>imagefile.iso</replaceable></userinput></screen> |
| 1348 |
|
| 1349 |
<para>Since &man.growisofs.1; automatically attempts to detect |
| 1350 |
fast blanked media and engage DAO write, |
| 1351 |
<option>-use-the-force-luke=dao</option> should not be |
| 1352 |
required.</para> |
| 1353 |
|
| 1354 |
<para>One should instead use restricted overwrite mode with |
| 1355 |
any <acronym>DVD-RW</acronym> as this format is more |
| 1356 |
flexible than the default of incremental sequential.</para> |
| 1357 |
</note> |
| 1358 |
|
| 1359 |
<para>To write data on a sequential <acronym>DVD-RW</acronym>, |
| 1360 |
use the same instructions as for the other |
| 1361 |
<acronym>DVD</acronym> formats:</para> |
| 1362 |
|
| 1363 |
<screen>&prompt.root; <userinput>growisofs -Z <replaceable>/dev/cd0</replaceable> -J -R <replaceable>/path/to/data</replaceable></userinput></screen> |
| 1364 |
|
| 1365 |
<para>To append some data to a previous recording, use |
| 1366 |
<option>-M</option> with &man.growisofs.1;. However, if data |
| 1367 |
is appended on a <acronym>DVD-RW</acronym> in incremental |
| 1368 |
sequential mode, a new session will be created on the disc and |
| 1369 |
the result will be a multi-session disc.</para> |
| 1370 |
|
| 1371 |
<para>A <acronym>DVD-RW</acronym> in restricted overwrite format |
| 1372 |
does not need to be blanked before a new initial session. |
| 1373 |
Instead, overwrite the disc with <option>-Z</option>. It is |
| 1374 |
also possible to grow an existing ISO 9660 file system written |
| 1375 |
on the disc with <option>-M</option>. The result will be a |
| 1376 |
one-session <acronym>DVD</acronym>.</para> |
| 1377 |
|
| 1378 |
<para>To put a <acronym>DVD-RW</acronym> in restricted overwrite |
| 1379 |
format, the following command must be used:</para> |
| 1380 |
|
| 1381 |
<screen>&prompt.root; <userinput>dvd+rw-format <replaceable>/dev/cd0</replaceable></userinput></screen> |
| 1382 |
|
| 1383 |
<para>To change back to sequential format, use:</para> |
| 1384 |
|
| 1385 |
<screen>&prompt.root; <userinput>dvd+rw-format -blank=full <replaceable>/dev/cd0</replaceable></userinput></screen> |
| 1386 |
</sect2> |
| 1387 |
|
| 1388 |
<sect2> |
| 1389 |
<title>Multi-Session</title> |
| 1390 |
|
| 1391 |
<para>Few <acronym>DVD-ROM</acronym> drives support |
| 1392 |
multi-session DVDs and most of the time only read the first |
| 1393 |
session. DVD+R, DVD-R and <acronym>DVD-RW</acronym> in |
| 1394 |
sequential format can accept multiple sessions. The notion |
| 1395 |
of multiple sessions does not exist for the |
| 1396 |
<acronym>DVD+RW</acronym> and the <acronym>DVD-RW</acronym> |
| 1397 |
restricted overwrite formats.</para> |
| 1398 |
|
| 1399 |
<para>Using the following command after an initial non-closed |
| 1400 |
session on a DVD+R, DVD-R, or <acronym>DVD-RW</acronym> in |
| 1401 |
sequential format, will add a new session to the disc:</para> |
| 1402 |
|
| 1403 |
<screen>&prompt.root; <userinput>growisofs -M <replaceable>/dev/cd0</replaceable> -J -R <replaceable>/path/to/nextdata</replaceable></userinput></screen> |
| 1404 |
|
| 1405 |
<para>Using this command with a <acronym>DVD+RW</acronym> or a |
| 1406 |
<acronym>DVD-RW</acronym> in restricted overwrite mode will |
| 1407 |
append data while merging the new session to the existing one. |
| 1408 |
The result will be a single-session disc. Use this method to |
| 1409 |
add data after an initial write on these types of |
| 1410 |
media.</para> |
| 1411 |
|
| 1412 |
<note> |
| 1413 |
<para>Since some space on the media is used between each |
| 1414 |
session to mark the end and start of sessions, one should |
| 1415 |
add sessions with a large amount of data to optimize media |
| 1416 |
space. The number of sessions is limited to 154 for a |
| 1417 |
DVD+R, about 2000 for a DVD-R, and 127 for a DVD+R Double |
| 1418 |
Layer.</para> |
| 1419 |
</note> |
| 1420 |
</sect2> |
| 1421 |
|
| 1422 |
<sect2> |
| 1423 |
<title>For More Information</title> |
| 1424 |
|
| 1425 |
<para>To obtain more information about a <acronym>DVD</acronym>, |
| 1426 |
use <command>dvd+rw-mediainfo |
| 1427 |
<replaceable>/dev/cd0</replaceable></command> while the |
| 1428 |
disc in the specified drive.</para> |
| 1429 |
|
| 1430 |
<para>More information about |
| 1431 |
<application>dvd+rw-tools</application> can be found in |
| 1432 |
&man.growisofs.1;, on the <link |
| 1433 |
xlink:href="http://fy.chalmers.se/~appro/linux/DVD+RW/">dvd+rw-tools |
| 1434 |
web site</link>, and in the <link |
| 1435 |
xlink:href="http://lists.debian.org/cdwrite/">cdwrite |
| 1436 |
mailing list</link> archives.</para> |
| 1437 |
|
| 1438 |
<note> |
| 1439 |
<para>When creating a problem report related to the use of |
| 1440 |
<application>dvd+rw-tools</application>, always include the |
| 1441 |
output of <command>dvd+rw-mediainfo</command>.</para> |
| 1442 |
</note> |
| 1443 |
</sect2> |
| 1444 |
|
| 1445 |
<sect2 xml:id="creating-dvd-ram"> |
| 1446 |
<title>Using a <acronym>DVD-RAM</acronym></title> |
| 1447 |
|
| 1448 |
<indexterm> |
| 1449 |
<primary><acronym>DVD</acronym></primary> |
| 1450 |
<secondary><acronym>DVD-RAM</acronym></secondary> |
| 1451 |
</indexterm> |
| 1452 |
|
| 1453 |
<para><acronym>DVD-RAM</acronym> writers can use either a |
| 1454 |
<acronym>SCSI</acronym> or <acronym>ATAPI</acronym> interface. |
| 1455 |
For <acronym>ATAPI</acronym> devices, DMA access has to be |
| 1456 |
enabled by adding the following line to |
| 1457 |
<filename>/boot/loader.conf</filename>:</para> |
| 1458 |
|
| 1459 |
<programlisting>hw.ata.atapi_dma="1"</programlisting> |
| 1460 |
|
| 1461 |
<para>A <acronym>DVD-RAM</acronym> can be seen as a removable |
| 1462 |
hard drive. Like any other hard drive, the |
| 1463 |
<acronym>DVD-RAM</acronym> must be formatted before it can be |
| 1464 |
used. In this example, the whole disk space will be formatted |
| 1465 |
with a standard UFS2 file system:</para> |
| 1466 |
|
| 1467 |
<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>/dev/acd0</replaceable> bs=2k count=1</userinput> |
| 1468 |
&prompt.root; <userinput>bsdlabel -Bw <replaceable>acd0</replaceable></userinput> |
| 1469 |
&prompt.root; <userinput>newfs <replaceable>/dev/acd0</replaceable></userinput></screen> |
| 1470 |
|
| 1471 |
<para>The <acronym>DVD</acronym> device, |
| 1472 |
<filename>acd0</filename>, must be changed according to the |
| 1473 |
configuration.</para> |
| 1474 |
|
| 1475 |
<para>Once the <acronym>DVD-RAM</acronym> has been formatted, it |
| 1476 |
can be mounted as a normal hard drive:</para> |
| 1477 |
|
| 1478 |
<screen>&prompt.root; <userinput>mount <replaceable>/dev/acd0</replaceable> <replaceable>/mnt</replaceable></userinput></screen> |
| 1479 |
|
| 1480 |
<para>Once mounted, the <acronym>DVD-RAM</acronym> will be both |
| 1481 |
readable and writeable.</para> |
| 1482 |
</sect2> |
| 1483 |
</sect1> |
| 1484 |
|
| 1485 |
<sect1 xml:id="floppies"> |
| 1486 |
<title>Creating and Using Floppy Disks</title> |
| 1487 |
|
| 1488 |
<!-- |
| 1489 |
<authorgroup> |
| 1490 |
<author> |
| 1491 |
<personname> |
| 1492 |
<firstname>Julio</firstname> |
| 1493 |
<surname>Merino</surname> |
| 1494 |
</personname> |
| 1495 |
<contrib>Original work by </contrib> |
| 1496 |
</author> |
| 1497 |
</authorgroup> |
| 1498 |
|
| 1499 |
<authorgroup> |
| 1500 |
<author> |
| 1501 |
<personname> |
| 1502 |
<firstname>Martin</firstname> |
| 1503 |
<surname>Karlsson</surname> |
| 1504 |
</personname> |
| 1505 |
<contrib>Rewritten by </contrib> |
| 1506 |
</author> |
| 1507 |
</authorgroup> |
| 1508 |
--> |
| 1509 |
|
| 1510 |
<para>This section explains how to format a 3.5 inch floppy disk |
| 1511 |
in &os;.</para> |
| 1512 |
|
| 1513 |
<procedure> |
| 1514 |
<title>Steps to Format a Floppy</title> |
| 1515 |
|
| 1516 |
<para>A floppy disk needs to be low-level formatted before it |
| 1517 |
can be used. This is usually done by the vendor, but |
| 1518 |
formatting is a good way to check media integrity. To |
| 1519 |
low-level format the floppy disk on &os;, use |
| 1520 |
&man.fdformat.1;. When using this utility, make note of any |
| 1521 |
error messages, as these can help determine if the disk is |
| 1522 |
good or bad.</para> |
| 1523 |
|
| 1524 |
<step> |
| 1525 |
<para>To format the floppy, insert a new 3.5 inch floppy disk |
| 1526 |
into the first floppy drive and issue:</para> |
| 1527 |
|
| 1528 |
<screen>&prompt.root; <userinput>/usr/sbin/fdformat -f 1440 /dev/fd0</userinput></screen> |
| 1529 |
</step> |
| 1530 |
|
| 1531 |
<step> |
| 1532 |
<para>After low-level formatting the disk, create a disk label |
| 1533 |
as it is needed by the system to determine the size of the |
| 1534 |
disk and its geometry. The supported geometry values are |
| 1535 |
listed in <filename>/etc/disktab</filename>.</para> |
| 1536 |
|
| 1537 |
<para>To write the disk label, use &man.bsdlabel.8;:</para> |
| 1538 |
|
| 1539 |
<screen>&prompt.root; <userinput>/sbin/bsdlabel -B -w /dev/fd0 fd1440</userinput></screen> |
| 1540 |
</step> |
| 1541 |
|
| 1542 |
<step> |
| 1543 |
<para>The floppy is now ready to be high-level formatted with |
| 1544 |
a file system. The floppy's file system can be either UFS |
| 1545 |
or FAT, where FAT is generally a better choice for |
| 1546 |
floppies.</para> |
| 1547 |
|
| 1548 |
<para>To format the floppy with FAT, issue:</para> |
| 1549 |
|
| 1550 |
<screen>&prompt.root; <userinput>/sbin/newfs_msdos /dev/fd0</userinput></screen> |
| 1551 |
</step> |
| 1552 |
</procedure> |
| 1553 |
|
| 1554 |
<para>The disk is now ready for use. To use the floppy, mount it |
| 1555 |
with &man.mount.msdosfs.8;. One can also install and use |
| 1556 |
<package>emulators/mtools</package> from the Ports |
| 1557 |
Collection.</para> |
| 1558 |
</sect1> |
| 1559 |
|
| 1560 |
<sect1 xml:id="backup-basics"> |
| 1561 |
<title>Backup Basics</title> |
| 1562 |
|
| 1563 |
<!-- |
| 1564 |
<authorgroup> |
| 1565 |
<author> |
| 1566 |
<personname> |
| 1567 |
<firstname>Lowell</firstname> |
| 1568 |
<surname>Gilbert</surname> |
| 1569 |
</personname> |
| 1570 |
<contrib>Original work by </contrib> |
| 1571 |
</author> |
| 1572 |
</authorgroup> |
| 1573 |
--> |
| 1574 |
|
| 1575 |
<para>Implementing a backup plan is essential in order to have the |
| 1576 |
ability to recover from disk failure, accidental file deletion, |
| 1577 |
random file corruption, or complete machine destruction, |
| 1578 |
including destruction of on-site backups.</para> |
| 1579 |
|
| 1580 |
<para>The backup type and schedule will vary, depending upon the |
| 1581 |
importance of the data, the granularity needed for file |
| 1582 |
restores, and the amount of acceptable downtime. Some possible |
| 1583 |
backup techniques include:</para> |
| 1584 |
|
| 1585 |
<itemizedlist> |
| 1586 |
<listitem> |
| 1587 |
<para>Archives of the whole system, backed up onto permanent, |
| 1588 |
off-site media. This provides protection against all of the |
| 1589 |
problems listed above, but is slow and inconvenient to |
| 1590 |
restore from, especially for non-privileged users.</para> |
| 1591 |
</listitem> |
| 1592 |
|
| 1593 |
<listitem> |
| 1594 |
<para>File system snapshots, which are useful for restoring |
| 1595 |
deleted files or previous versions of files.</para> |
| 1596 |
</listitem> |
| 1597 |
|
| 1598 |
<listitem> |
| 1599 |
<para>Copies of whole file systems or disks which are |
| 1600 |
synchronized with another system on the network using a |
| 1601 |
scheduled <package>net/rsync</package>.</para> |
| 1602 |
</listitem> |
| 1603 |
|
| 1604 |
<listitem> |
| 1605 |
<para>Hardware or software <acronym>RAID</acronym>, which |
| 1606 |
minimizes or avoids downtime when a disk fails.</para> |
| 1607 |
</listitem> |
| 1608 |
</itemizedlist> |
| 1609 |
|
| 1610 |
<para>Typically, a mix of backup techniques is used. For |
| 1611 |
example, one could create a schedule to automate a weekly, full |
| 1612 |
system backup that is stored off-site and to supplement this |
| 1613 |
backup with hourly ZFS snapshots. In addition, one could make a |
| 1614 |
manual backup of individual directories or files before making |
| 1615 |
file edits or deletions.</para> |
| 1616 |
|
| 1617 |
<para>This section describes some of the utilities which can be |
| 1618 |
used to create and manage backups on a &os; system.</para> |
| 1619 |
|
| 1620 |
<sect2> |
| 1621 |
<title>File System Backups</title> |
| 1622 |
|
| 1623 |
<indexterm> |
| 1624 |
<primary>backup software</primary> |
| 1625 |
<secondary>dump / restore</secondary> |
| 1626 |
</indexterm> |
| 1627 |
<indexterm> |
| 1628 |
<primary><command>dump</command></primary> |
| 1629 |
</indexterm> |
| 1630 |
<indexterm> |
| 1631 |
<primary><command>restore</command></primary> |
| 1632 |
</indexterm> |
| 1633 |
|
| 1634 |
<para>The traditional &unix; programs for backing up a file |
| 1635 |
system are &man.dump.8;, which creates the backup, and |
| 1636 |
&man.restore.8;, which restores the backup. These utilities |
| 1637 |
work at the disk block level, below the abstractions of the |
| 1638 |
files, links, and directories that are created by file |
| 1639 |
systems. Unlike other backup software, |
| 1640 |
<command>dump</command> backs up an entire file system and is |
| 1641 |
unable to backup only part of a file system or a directory |
| 1642 |
tree that spans multiple file systems. Instead of writing |
| 1643 |
files and directories, <command>dump</command> writes the raw |
| 1644 |
data blocks that comprise files and directories.</para> |
| 1645 |
|
| 1646 |
<note> |
| 1647 |
<para>If <command>dump</command> is used on the root |
| 1648 |
directory, it will not back up <filename>/home</filename>, |
| 1649 |
<filename>/usr</filename> or many other directories since |
| 1650 |
these are typically mount points for other file systems or |
| 1651 |
symbolic links into those file systems.</para> |
| 1652 |
</note> |
| 1653 |
|
| 1654 |
<para>When used to restore data, <command>restore</command> |
| 1655 |
stores temporary files in <filename>/tmp/</filename> by |
| 1656 |
default. When using a recovery disk with a small |
| 1657 |
<filename>/tmp</filename>, set <envar>TMPDIR</envar> to a |
| 1658 |
directory with more free space in order for the restore to |
| 1659 |
succeed.</para> |
| 1660 |
|
| 1661 |
<para>When using <command>dump</command>, be aware that some |
| 1662 |
quirks remain from its early days in Version 6 of |
| 1663 |
AT&T &unix;,circa 1975. The default parameters assume a |
| 1664 |
backup to a 9-track tape, rather than to another type of media |
| 1665 |
or to the high-density tapes available today. These defaults |
| 1666 |
must be overridden on the command line.</para> |
| 1667 |
|
| 1668 |
<indexterm> |
| 1669 |
<primary><filename>.rhosts</filename></primary> |
| 1670 |
</indexterm> |
| 1671 |
<para>It is possible to backup a file system across the network |
| 1672 |
to a another system or to a tape drive attached to another |
| 1673 |
computer. While the &man.rdump.8; and &man.rrestore.8; |
| 1674 |
utilities can be used for this purpose, they are not |
| 1675 |
considered to be secure.</para> |
| 1676 |
|
| 1677 |
<para>Instead, one can use <command>dump</command> and |
| 1678 |
<command>restore</command> in a more secure fashion over an |
| 1679 |
<acronym>SSH</acronym> connection. This example creates a |
| 1680 |
full, compressed backup of <filename>/usr</filename> and sends |
| 1681 |
the backup file to the specified host over a |
| 1682 |
<acronym>SSH</acronym> connection.</para> |
| 1683 |
|
| 1684 |
<example> |
| 1685 |
<title>Using <command>dump</command> over |
| 1686 |
<application>ssh</application></title> |
| 1687 |
|
| 1688 |
<screen>&prompt.root; <userinput>/sbin/dump -0uan -f - /usr | gzip -2 | ssh -c blowfish \ |
| 1689 |
targetuser@targetmachine.example.com dd of=/mybigfiles/dump-usr-l0.gz</userinput></screen> |
| 1690 |
</example> |
| 1691 |
|
| 1692 |
<para>This example sets <envar>RSH</envar> in order to write the |
| 1693 |
backup to a tape drive on a remote system over a |
| 1694 |
<acronym>SSH</acronym> connection:</para> |
| 1695 |
|
| 1696 |
<example> |
| 1697 |
<title>Using <command>dump</command> over |
| 1698 |
<application>ssh</application> with <envar>RSH</envar> |
| 1699 |
Set</title> |
| 1700 |
|
| 1701 |
<screen>&prompt.root; <userinput>env RSH=/usr/bin/ssh /sbin/dump -0uan -f targetuser@targetmachine.example.com:/dev/sa0 /usr</userinput></screen> |
| 1702 |
</example> |
| 1703 |
</sect2> |
| 1704 |
|
| 1705 |
<sect2> |
| 1706 |
<title>Directory Backups</title> |
| 1707 |
|
| 1708 |
<indexterm> |
| 1709 |
<primary>backup software</primary> |
| 1710 |
<secondary><command>tar</command></secondary> |
| 1711 |
</indexterm> |
| 1712 |
|
| 1713 |
<para>Several built-in utilities are available for backing up |
| 1714 |
and restoring specified files and directories as |
| 1715 |
needed.</para> |
| 1716 |
|
| 1717 |
<para>A good choice for making a backup of all of the files in a |
| 1718 |
directory is &man.tar.1;. This utility dates back to Version |
| 1719 |
6 of AT&T &unix; and by default assumes a recursive backup |
| 1720 |
to a local tape device. Switches can be used to instead |
| 1721 |
specify the name of a backup file.</para> |
| 1722 |
|
| 1723 |
<indexterm><primary><command>tar</command></primary></indexterm> |
| 1724 |
|
| 1725 |
<para>This example creates a compressed backup of the current |
| 1726 |
directory and saves it to |
| 1727 |
<filename>/tmp/mybackup.tgz</filename>. When creating a |
| 1728 |
backup file, make sure that the backup is not saved to the |
| 1729 |
same directory that is being backed up.</para> |
| 1730 |
|
| 1731 |
<example> |
| 1732 |
<title>Backing Up the Current Directory with |
| 1733 |
<command>tar</command></title> |
| 1734 |
|
| 1735 |
<screen>&prompt.root; <userinput>tar czvf <replaceable>/tmp/mybackup.tgz</replaceable> . </userinput></screen> |
| 1736 |
</example> |
| 1737 |
|
| 1738 |
<para>To restore the entire backup, <command>cd</command> into |
| 1739 |
the directory to restore into and specify the name of the |
| 1740 |
backup. Note that this will overwrite any newer versions of |
| 1741 |
files in the restore directory. When in doubt, restore to a |
| 1742 |
temporary directory or specify the name of the file within the |
| 1743 |
backup to restore.</para> |
| 1744 |
|
| 1745 |
<example> |
| 1746 |
<title>Restoring Up the Current Directory with |
| 1747 |
<command>tar</command></title> |
| 1748 |
|
| 1749 |
<screen>&prompt.root; <userinput>tar xzvf <replaceable>/tmp/mybackup.tgz</replaceable></userinput></screen> |
| 1750 |
</example> |
| 1751 |
|
| 1752 |
<para>There are dozens of available switches which are described |
| 1753 |
in &man.tar.1;. This utility also supports the use of exclude |
| 1754 |
patterns to specify which files should not be included when |
| 1755 |
backing up the specified directory or restoring files from a |
| 1756 |
backup.</para> |
| 1757 |
|
| 1758 |
<indexterm> |
| 1759 |
<primary>backup software</primary> |
| 1760 |
<secondary><command>cpio</command></secondary> |
| 1761 |
</indexterm> |
| 1762 |
|
| 1763 |
<para>To create a backup using a specified list of files and |
| 1764 |
directories, &man.cpio.1; is a good choice. Unlike |
| 1765 |
<command>tar</command>, <command>cpio</command> does not know |
| 1766 |
how to walk the directory tree and it must be provided the |
| 1767 |
list of files to backup.</para> |
| 1768 |
|
| 1769 |
<para>For example, a list of files can be created using |
| 1770 |
<command>ls</command> or <command>find</command>. This |
| 1771 |
example creates a recursive listing of the current directory |
| 1772 |
which is then piped to <command>cpio</command> in order to |
| 1773 |
create an output backup file named |
| 1774 |
<filename>/tmp/mybackup.cpio</filename>.</para> |
| 1775 |
|
| 1776 |
<example> |
| 1777 |
<title>Using <command>ls</command> and <command>cpio</command> |
| 1778 |
to Make a Recursive Backup of the Current Directory</title> |
| 1779 |
|
| 1780 |
<screen>&prompt.root; <userinput>ls -R | cpio -ovF <replaceable>/tmp/mybackup.cpio</replaceable></userinput></screen> |
| 1781 |
</example> |
| 1782 |
|
| 1783 |
<indexterm> |
| 1784 |
<primary>backup software</primary> |
| 1785 |
<secondary><command>pax</command></secondary> |
| 1786 |
</indexterm> |
| 1787 |
<indexterm><primary><command>pax</command></primary></indexterm> |
| 1788 |
<indexterm><primary>POSIX</primary></indexterm> |
| 1789 |
<indexterm><primary>IEEE</primary></indexterm> |
| 1790 |
|
| 1791 |
<para>A backup utility which tries to bridge the features |
| 1792 |
provided by <command>tar</command> and <command>cpio</command> |
| 1793 |
is &man.pax.1;. Over the years, the various versions of |
| 1794 |
<command>tar</command> and <command>cpio</command> became |
| 1795 |
slightly incompatible. &posix; created <command>pax</command> |
| 1796 |
which attempts to read and write many of the various |
| 1797 |
<command>cpio</command> and <command>tar</command> formats, |
| 1798 |
plus new formats of its own.</para> |
| 1799 |
|
| 1800 |
<para>The <command>pax</command> equivalent to the previous |
| 1801 |
examples would be:</para> |
| 1802 |
|
| 1803 |
<example> |
| 1804 |
<title>Backing Up the Current Directory with |
| 1805 |
<command>pax</command></title> |
| 1806 |
|
| 1807 |
<screen>&prompt.root; <userinput>pax -wf <replaceable>/tmp/mybackup.pax</replaceable> .</userinput></screen> |
| 1808 |
</example> |
| 1809 |
</sect2> |
| 1810 |
|
| 1811 |
<sect2 xml:id="backups-tapebackups"> |
| 1812 |
<title>Using Data Tapes for Backups</title> |
| 1813 |
|
| 1814 |
<indexterm><primary>tape media</primary></indexterm> |
| 1815 |
|
| 1816 |
<para>While tape technology has continued to evolve, modern |
| 1817 |
backup systems tend to combine off-site backups with local |
| 1818 |
removable media. &os; supports any tape drive that uses |
| 1819 |
<acronym>SCSI</acronym>, such as <acronym>LTO</acronym> or |
| 1820 |
<acronym>DAT</acronym>. There is limited support for |
| 1821 |
<acronym>SATA</acronym> and <acronym>USB</acronym> tape |
| 1822 |
drives.</para> |
| 1823 |
|
| 1824 |
<para>For <acronym>SCSI</acronym> tape devices, &os; uses the |
| 1825 |
&man.sa.4; driver and the <filename>/dev/sa0</filename>, |
| 1826 |
<filename>/dev/nsa0</filename>, and |
| 1827 |
<filename>/dev/esa0</filename> devices. The physical device |
| 1828 |
name is <filename>/dev/sa0</filename>. When |
| 1829 |
<filename>/dev/nsa0</filename> is used, the backup application |
| 1830 |
will not rewind the tape after writing a file, which allows |
| 1831 |
writing more than one file to a tape. Using |
| 1832 |
<filename>/dev/esa0</filename> ejects the tape after the |
| 1833 |
device is closed.</para> |
| 1834 |
|
| 1835 |
<para>In &os;, <command>mt</command> is used to control |
| 1836 |
operations of the tape drive, such as seeking through files on |
| 1837 |
a tape or writing tape control marks to the tape. For |
| 1838 |
example, the first three files on a tape can be preserved by |
| 1839 |
skipping past them before writing a new file:</para> |
| 1840 |
|
| 1841 |
<screen>&prompt.root; <userinput>mt -f /dev/nsa0 fsf 3</userinput></screen> |
| 1842 |
|
| 1843 |
<para>This utility supports many operations. Refer to |
| 1844 |
&man.mt.1; for details.</para> |
| 1845 |
|
| 1846 |
<para>To write a single file to tape using |
| 1847 |
<command>tar</command>, specify the name of the tape device |
| 1848 |
and the file to backup:</para> |
| 1849 |
|
| 1850 |
<screen>&prompt.root; <userinput>tar cvf /dev/sa0 <replaceable>file</replaceable></userinput></screen> |
| 1851 |
|
| 1852 |
<para>To recover files from a <command>tar</command> archive |
| 1853 |
on tape into the current directory:</para> |
| 1854 |
|
| 1855 |
<screen>&prompt.root; <userinput>tar xvf /dev/sa0</userinput></screen> |
| 1856 |
|
| 1857 |
<para>To backup a <acronym>UFS</acronym> file system, use |
| 1858 |
<command>dump</command>. This examples backs up |
| 1859 |
<filename>/usr</filename> without rewinding the tape when |
| 1860 |
finished:</para> |
| 1861 |
|
| 1862 |
<screen>&prompt.root; <userinput>dump -0aL -b64 -f /dev/nsa0 /usr</userinput></screen> |
| 1863 |
|
| 1864 |
<para>To interactively restore files from a |
| 1865 |
<command>dump</command> file on tape into the current |
| 1866 |
directory:</para> |
| 1867 |
|
| 1868 |
<screen>&prompt.root; <userinput>restore -i -f /dev/nsa0</userinput></screen> |
| 1869 |
</sect2> |
| 1870 |
|
| 1871 |
<sect2 xml:id="backups-programs-amanda"> |
| 1872 |
<title>Third-Party Backup Utilities</title> |
| 1873 |
|
| 1874 |
<indexterm> |
| 1875 |
<primary>backup software</primary> |
| 1876 |
</indexterm> |
| 1877 |
|
| 1878 |
<para>The &os; Ports Collection provides many third-party |
| 1879 |
utilities which can be used to schedule the creation of |
| 1880 |
backups, simplify tape backup, and make backups easier and |
| 1881 |
more convenient. Many of these applications are client/server |
| 1882 |
based and can be used to automate the backups of a single |
| 1883 |
system or all of the computers in a network.</para> |
| 1884 |
|
| 1885 |
<para>Popular utilities include |
| 1886 |
<application>Amanda</application>, |
| 1887 |
<application>Bacula</application>, |
| 1888 |
<application>rsync</application>, and |
| 1889 |
<application>duplicity</application>.</para> |
| 1890 |
</sect2> |
| 1891 |
|
| 1892 |
<sect2> |
| 1893 |
<title>Emergency Recovery</title> |
| 1894 |
|
| 1895 |
<para>In addition to regular backups, it is recommended to |
| 1896 |
perform the following steps as part of an emergency |
| 1897 |
preparedness plan.</para> |
| 1898 |
|
| 1899 |
<indexterm> |
| 1900 |
<primary><command>bsdlabel</command></primary></indexterm> |
| 1901 |
|
| 1902 |
<para>Create a print copy of the output of the following |
| 1903 |
commands:</para> |
| 1904 |
|
| 1905 |
<itemizedlist> |
| 1906 |
<listitem> |
| 1907 |
<para><command>gpart show</command></para> |
| 1908 |
</listitem> |
| 1909 |
|
| 1910 |
<listitem> |
| 1911 |
<para><command>more /etc/fstab</command></para> |
| 1912 |
</listitem> |
| 1913 |
|
| 1914 |
<listitem> |
| 1915 |
<para><command>dmesg</command></para> |
| 1916 |
</listitem> |
| 1917 |
</itemizedlist> |
| 1918 |
|
| 1919 |
<indexterm><primary>livefs |
| 1920 |
<acronym>CD</acronym></primary></indexterm> |
| 1921 |
|
| 1922 |
<para>Store this printout and a copy of the installation media |
| 1923 |
in a secure location. Should an emergency restore be |
| 1924 |
needed, boot into the installation media and select |
| 1925 |
<literal>Live CD</literal> to access a rescue shell. This |
| 1926 |
rescue mode can be used to view the current state of the |
| 1927 |
system, and if needed, to reformat disks and restore data |
| 1928 |
from backups.</para> |
| 1929 |
|
| 1930 |
<note> |
| 1931 |
<para>The installation media for |
| 1932 |
&os;/&arch.i386; &rel2.current;-RELEASE does not |
| 1933 |
include a rescue shell. For this version, instead |
| 1934 |
download and burn a Livefs <acronym>CD</acronym> image from |
| 1935 |
<uri |
| 1936 |
xlink:href="ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/&arch.i386;/ISO-IMAGES/&rel2.current;/&os;-&rel2.current;-RELEASE-&arch.i386;-livefs.iso">ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/&arch.i386;/ISO-IMAGES/&rel2.current;/&os;-&rel2.current;-RELEASE-&arch.i386;-livefs.iso</uri>.</para> |
| 1937 |
</note> |
| 1938 |
|
| 1939 |
<para>Next, test the rescue shell and the backups. Make notes |
| 1940 |
of the procedure. Store these notes with the media, the |
| 1941 |
printouts, and the backups. These notes may prevent the |
| 1942 |
inadvertent destruction of the backups while under the stress |
| 1943 |
of performing an emergency recovery.</para> |
| 1944 |
|
| 1945 |
<para>For an added measure of security, store the latest backup |
| 1946 |
at a remote location which is physically separated from the |
| 1947 |
computers and disk drives by a significant distance.</para> |
| 1948 |
</sect2> |
| 1949 |
</sect1> |
| 1950 |
|
| 1951 |
<sect1 xml:id="disks-virtual"> |
| 1952 |
<info> |
| 1953 |
<title>Memory Disks</title> |
| 1954 |
|
| 1955 |
<authorgroup> |
| 1956 |
<author> |
| 1957 |
<personname> |
| 1958 |
<firstname>Marc</firstname> |
| 1959 |
<surname>Fonvieille</surname> |
| 1960 |
</personname> |
| 1961 |
<contrib>Reorganized and enhanced by </contrib> |
| 1962 |
</author> |
| 1963 |
</authorgroup> |
| 1964 |
</info> |
| 1965 |
|
| 1966 |
<para>In addition to physical disks, &os; also supports the |
| 1967 |
creation and use of memory disks. One possible use for a |
| 1968 |
memory disk is to access the contents of an |
| 1969 |
<acronym>ISO</acronym> file system without the overhead of first |
| 1970 |
burning it to a <acronym>CD</acronym> or <acronym>DVD</acronym>, |
| 1971 |
then mounting the <acronym>CD/DVD</acronym> media.</para> |
| 1972 |
|
| 1973 |
<para>In &os;, the &man.md.4; driver is used to provide support |
| 1974 |
for memory disks. The <filename>GENERIC</filename> kernel |
| 1975 |
includes this driver. When using a custom kernel configuration |
| 1976 |
file, ensure it includes this line:</para> |
| 1977 |
|
| 1978 |
<programlisting>device md</programlisting> |
| 1979 |
|
| 1980 |
<sect2 xml:id="disks-mdconfig"> |
| 1981 |
<title>Attaching and Detaching Existing Images</title> |
| 1982 |
|
| 1983 |
<indexterm> |
| 1984 |
<primary>disks</primary> |
| 1985 |
<secondary>memory</secondary> |
| 1986 |
</indexterm> |
| 1987 |
|
| 1988 |
<para>To mount an existing file system image, use |
| 1989 |
<command>mdconfig</command> to specify the name of the |
| 1990 |
<acronym>ISO</acronym> file and a free unit number. Then, |
| 1991 |
refer to that unit number to mount it on an existing mount |
| 1992 |
point. Once mounted, the files in the <acronym>ISO</acronym> |
| 1993 |
will appear in the mount point. This example attaches |
| 1994 |
<replaceable>diskimage.iso</replaceable> to the memory device |
| 1995 |
<filename>/dev/md0</filename> then mounts that memory device |
| 1996 |
on <filename>/mnt</filename>:</para> |
| 1997 |
|
| 1998 |
<screen>&prompt.root; <userinput>mdconfig -f <replaceable>diskimage.iso</replaceable> -u <replaceable>0</replaceable></userinput> |
| 1999 |
&prompt.root; <userinput>mount -t cd9660 /dev/md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput></screen> |
| 2000 |
|
| 2001 |
<para>Notice that <option>-t cd9660</option> was used to mount |
| 2002 |
an ISO format. If a unit number is not specified with |
| 2003 |
<option>-u</option>, <command>mdconfig</command> will |
| 2004 |
automatically allocate an unused memory device and output |
| 2005 |
the name of the allocated unit, such as |
| 2006 |
<filename>md4</filename>. Refer to &man.mdconfig.8; for more |
| 2007 |
details about this command and its options.</para> |
| 2008 |
|
| 2009 |
<indexterm> |
| 2010 |
<primary>disks</primary> |
| 2011 |
<secondary>detaching a memory disk</secondary> |
| 2012 |
</indexterm> |
| 2013 |
|
| 2014 |
<para>When a memory disk is no longer in use, its resources |
| 2015 |
should be released back to the system. First, unmount the |
| 2016 |
file system, then use <command>mdconfig</command> to detach |
| 2017 |
the disk from the system and release its resources. To |
| 2018 |
continue this example:</para> |
| 2019 |
|
| 2020 |
<screen>&prompt.root; <userinput>umount /mnt</userinput> |
| 2021 |
&prompt.root; <userinput>mdconfig -d -u <replaceable>0</replaceable></userinput></screen> |
| 2022 |
|
| 2023 |
<para>To determine if any memory disks are still attached to the |
| 2024 |
system, type <command>mdconfig -l</command>.</para> |
| 2025 |
</sect2> |
| 2026 |
|
| 2027 |
<sect2 xml:id="disks-md-freebsd5"> |
| 2028 |
<title>Creating a File- or Memory-Backed Memory Disk</title> |
| 2029 |
|
| 2030 |
<indexterm> |
| 2031 |
<primary>disks</primary> |
| 2032 |
<secondary>memory file system</secondary> |
| 2033 |
</indexterm> |
| 2034 |
<para>&os; also supports memory disks where the storage to use |
| 2035 |
is allocated from either a hard disk or an area of memory. |
| 2036 |
The first method is commonly referred to as a file-backed file |
| 2037 |
system and the second method as a memory-backed file system. |
| 2038 |
Both types can be created using |
| 2039 |
<command>mdconfig</command>.</para> |
| 2040 |
|
| 2041 |
<para>To create a new memory-backed file system, specify a type |
| 2042 |
of <literal>swap</literal> and the size of the memory disk to |
| 2043 |
create. Then, format the memory disk with a file system and |
| 2044 |
mount as usual. This example creates a 5M memory disk on unit |
| 2045 |
<literal>1</literal>. That memory disk is then formatted with |
| 2046 |
the <acronym>UFS</acronym> file system before it is |
| 2047 |
mounted:</para> |
| 2048 |
|
| 2049 |
<screen>&prompt.root; <userinput>mdconfig -a -t swap -s <replaceable>5</replaceable>m -u <replaceable>1</replaceable></userinput> |
| 2050 |
&prompt.root; <userinput>newfs -U md<replaceable>1</replaceable></userinput> |
| 2051 |
/dev/md1: 5.0MB (10240 sectors) block size 16384, fragment size 2048 |
| 2052 |
using 4 cylinder groups of 1.27MB, 81 blks, 192 inodes. |
| 2053 |
with soft updates |
| 2054 |
super-block backups (for fsck -b #) at: |
| 2055 |
160, 2752, 5344, 7936 |
| 2056 |
&prompt.root; <userinput>mount /dev/md<replaceable>1</replaceable> <replaceable>/mnt</replaceable></userinput> |
| 2057 |
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput> |
| 2058 |
Filesystem 1K-blocks Used Avail Capacity Mounted on |
| 2059 |
/dev/md1 4718 4 4338 0% /mnt</screen> |
| 2060 |
|
| 2061 |
<para>To create a new file-backed memory disk, first allocate an |
| 2062 |
area of disk to use. This example creates an empty 5MB file |
| 2063 |
named <filename>newimage</filename>:</para> |
| 2064 |
|
| 2065 |
<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>newimage</replaceable> bs=1k count=<replaceable>5</replaceable>k</userinput> |
| 2066 |
5120+0 records in |
| 2067 |
5120+0 records out</screen> |
| 2068 |
|
| 2069 |
<para>Next, attach that file to a memory disk, label the memory |
| 2070 |
disk and format it with the <acronym>UFS</acronym> file |
| 2071 |
system, mount the memory disk, and verify the size of the |
| 2072 |
file-backed disk:</para> |
| 2073 |
|
| 2074 |
<screen>&prompt.root; <userinput>mdconfig -f <replaceable>newimage</replaceable> -u <replaceable>0</replaceable></userinput> |
| 2075 |
&prompt.root; <userinput>bsdlabel -w md<replaceable>0</replaceable> auto</userinput> |
| 2076 |
&prompt.root; <userinput>newfs -U md<replaceable>0</replaceable>a</userinput> |
| 2077 |
/dev/md0a: 5.0MB (10224 sectors) block size 16384, fragment size 2048 |
| 2078 |
using 4 cylinder groups of 1.25MB, 80 blks, 192 inodes. |
| 2079 |
super-block backups (for fsck -b #) at: |
| 2080 |
160, 2720, 5280, 7840 |
| 2081 |
&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable>a <replaceable>/mnt</replaceable></userinput> |
| 2082 |
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput> |
| 2083 |
Filesystem 1K-blocks Used Avail Capacity Mounted on |
| 2084 |
/dev/md0a 4710 4 4330 0% /mnt</screen> |
| 2085 |
|
| 2086 |
<para>It takes several commands to create a file- or |
| 2087 |
memory-backed file system using <command>mdconfig</command>. |
| 2088 |
&os; also comes with <command>mdmfs</command> which |
| 2089 |
automatically configures a memory disk, formats it with the |
| 2090 |
<acronym>UFS</acronym> file system, and mounts it. For |
| 2091 |
example, after creating <replaceable>newimage</replaceable> |
| 2092 |
with <command>dd</command>, this one command is equivalent to |
| 2093 |
running the <command>bsdlabel</command>, |
| 2094 |
<command>newfs</command>, and <command>mount</command> |
| 2095 |
commands shown above:</para> |
| 2096 |
|
| 2097 |
<screen>&prompt.root; <userinput>mdmfs -F <replaceable>newimage</replaceable> -s <replaceable>5</replaceable>m md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput></screen> |
| 2098 |
|
| 2099 |
<para>To instead create a new memory-based memory disk with |
| 2100 |
<command>mdmfs</command>, use this one command:</para> |
| 2101 |
|
| 2102 |
<screen>&prompt.root; <userinput>mdmfs -s <replaceable>5</replaceable>m md<replaceable>1</replaceable> <replaceable>/mnt</replaceable></userinput></screen> |
| 2103 |
|
| 2104 |
<para>If the unit number is not specified, |
| 2105 |
<command>mdmfs</command> will automatically select an unused |
| 2106 |
memory device. For more details about |
| 2107 |
<command>mdmfs</command>, refer to &man.mdmfs.8;.</para> |
| 2108 |
</sect2> |
| 2109 |
</sect1> |
| 2110 |
|
| 2111 |
<sect1 xml:id="snapshots"> |
| 2112 |
<info> |
| 2113 |
<title>File System Snapshots</title> |
| 2114 |
|
| 2115 |
<authorgroup> |
| 2116 |
<author> |
| 2117 |
<personname> |
| 2118 |
<firstname>Tom</firstname> |
| 2119 |
<surname>Rhodes</surname> |
| 2120 |
</personname> |
| 2121 |
<contrib>Contributed by </contrib> |
| 2122 |
</author> |
| 2123 |
</authorgroup> |
| 2124 |
</info> |
| 2125 |
|
| 2126 |
<indexterm> |
| 2127 |
<primary>file systems</primary> |
| 2128 |
<secondary>snapshots</secondary> |
| 2129 |
</indexterm> |
| 2130 |
|
| 2131 |
<para>&os; offers a feature in conjunction with |
| 2132 |
<link linkend="soft-updates">Soft Updates</link>: file system |
| 2133 |
snapshots.</para> |
| 2134 |
|
| 2135 |
<para>UFS snapshots allow a user to create images of specified |
| 2136 |
file systems, and treat them as a file. Snapshot files must be |
| 2137 |
created in the file system that the action is performed on, and |
| 2138 |
a user may create no more than 20 snapshots per file system. |
| 2139 |
Active snapshots are recorded in the superblock so they are |
| 2140 |
persistent across unmount and remount operations along with |
| 2141 |
system reboots. When a snapshot is no longer required, it can |
| 2142 |
be removed using &man.rm.1;. While snapshots may be removed in |
| 2143 |
any order, all the used space may not be acquired because |
| 2144 |
another snapshot will possibly claim some of the released |
| 2145 |
blocks.</para> |
| 2146 |
|
| 2147 |
<para>The un-alterable <option>snapshot</option> file flag is set |
| 2148 |
by &man.mksnap.ffs.8; after initial creation of a snapshot file. |
| 2149 |
&man.unlink.1; makes an exception for snapshot files since it |
| 2150 |
allows them to be removed.</para> |
| 2151 |
|
| 2152 |
<para>Snapshots are created using &man.mount.8;. To place a |
| 2153 |
snapshot of <filename>/var</filename> in the |
| 2154 |
file <filename>/var/snapshot/snap</filename>, use the following |
| 2155 |
command:</para> |
| 2156 |
|
| 2157 |
<screen>&prompt.root; <userinput>mount -u -o snapshot /var/snapshot/snap /var</userinput></screen> |
| 2158 |
|
| 2159 |
<para>Alternatively, use &man.mksnap.ffs.8; to create the |
| 2160 |
snapshot:</para> |
| 2161 |
|
| 2162 |
<screen>&prompt.root; <userinput>mksnap_ffs /var /var/snapshot/snap</userinput></screen> |
| 2163 |
|
| 2164 |
<para>One can find snapshot files on a file system, such as |
| 2165 |
<filename>/var</filename>, using |
| 2166 |
&man.find.1;:</para> |
| 2167 |
|
| 2168 |
<screen>&prompt.root; <userinput>find /var -flags snapshot</userinput></screen> |
| 2169 |
|
| 2170 |
<para>Once a snapshot has been created, it has several |
| 2171 |
uses:</para> |
| 2172 |
|
| 2173 |
<itemizedlist> |
| 2174 |
<listitem> |
| 2175 |
<para>Some administrators will use a snapshot file for backup |
| 2176 |
purposes, because the snapshot can be transferred to |
| 2177 |
<acronym>CD</acronym>s or tape.</para> |
| 2178 |
</listitem> |
| 2179 |
|
| 2180 |
<listitem> |
| 2181 |
<para>The file system integrity checker, &man.fsck.8;, may be |
| 2182 |
run on the snapshot. Assuming that the file system was |
| 2183 |
clean when it was mounted, this should always provide a |
| 2184 |
clean and unchanging result.</para> |
| 2185 |
</listitem> |
| 2186 |
|
| 2187 |
<listitem> |
| 2188 |
<para>Running &man.dump.8; on the snapshot will produce a dump |
| 2189 |
file that is consistent with the file system and the |
| 2190 |
timestamp of the snapshot. &man.dump.8; can also take a |
| 2191 |
snapshot, create a dump image, and then remove the snapshot |
| 2192 |
in one command by using <option>-L</option>.</para> |
| 2193 |
</listitem> |
| 2194 |
|
| 2195 |
<listitem> |
| 2196 |
<para>The snapshot can be mounted as a frozen image of the |
| 2197 |
file system. To &man.mount.8; the snapshot |
| 2198 |
<filename>/var/snapshot/snap</filename> run:</para> |
| 2199 |
|
| 2200 |
<screen>&prompt.root; <userinput>mdconfig -a -t vnode -o readonly -f /var/snapshot/snap -u 4</userinput> |
| 2201 |
&prompt.root; <userinput>mount -r /dev/md4 /mnt</userinput></screen> |
| 2202 |
</listitem> |
| 2203 |
</itemizedlist> |
| 2204 |
|
| 2205 |
<para>The frozen <filename>/var</filename> is now available |
| 2206 |
through <filename>/mnt</filename>. Everything will initially be |
| 2207 |
in the same state it was during the snapshot creation time. The |
| 2208 |
only exception is that any earlier snapshots will appear as zero |
| 2209 |
length files. To unmount the snapshot, use:</para> |
| 2210 |
|
| 2211 |
<screen>&prompt.root; <userinput>umount /mnt</userinput> |
| 2212 |
&prompt.root; <userinput>mdconfig -d -u 4</userinput></screen> |
| 2213 |
|
| 2214 |
<para>For more information about <option>softupdates</option> and |
| 2215 |
file system snapshots, including technical papers, visit |
| 2216 |
Marshall Kirk McKusick's website at <uri |
| 2217 |
xlink:href="http://www.mckusick.com/">http://www.mckusick.com/</uri>.</para> |
| 2218 |
</sect1> |
| 2219 |
|
| 2220 |
<sect1 xml:id="quotas"> |
| 2221 |
<title>Disk Quotas</title> |
| 2222 |
|
| 2223 |
<indexterm> |
| 2224 |
<primary>accounting</primary> |
| 2225 |
<secondary>disk space</secondary> |
| 2226 |
</indexterm> |
| 2227 |
<indexterm><primary>disk quotas</primary></indexterm> |
| 2228 |
|
| 2229 |
<para>Disk quotas can be used to limit the amount of disk space or |
| 2230 |
the number of files a user or members of a group may allocate on |
| 2231 |
a per-file system basis. This prevents one user or group of |
| 2232 |
users from consuming all of the available disk space.</para> |
| 2233 |
|
| 2234 |
<para>This section describes how to configure disk quotas for the |
| 2235 |
<acronym>UFS</acronym> file system. To configure quotas on the |
| 2236 |
<acronym>ZFS</acronym> file system, refer to <xref |
| 2237 |
linkend="zfs-zfs-quota"/></para> |
| 2238 |
|
| 2239 |
<sect2> |
| 2240 |
<title>Enabling Disk Quotas</title> |
| 2241 |
|
| 2242 |
<para>To determine if the &os; kernel provides support for disk |
| 2243 |
quotas:</para> |
| 2244 |
|
| 2245 |
<screen>&prompt.user; <userinput>sysctl kern.features.ufs_quota</userinput> |
| 2246 |
kern.features.ufs_quota: 1</screen> |
| 2247 |
|
| 2248 |
<para>In this example, the <literal>1</literal> indicates quota |
| 2249 |
support. If the value is instead <literal>0</literal>, add |
| 2250 |
the following line to a custom kernel configuration file and |
| 2251 |
rebuild the kernel using the instructions in <xref |
| 2252 |
linkend="kernelconfig"/>:</para> |
| 2253 |
|
| 2254 |
<programlisting>options QUOTA</programlisting> |
| 2255 |
|
| 2256 |
<para>Next, enable disk quotas in |
| 2257 |
<filename>/etc/rc.conf</filename>:</para> |
| 2258 |
|
| 2259 |
<programlisting>quota_enable="YES"</programlisting> |
| 2260 |
|
| 2261 |
<indexterm> |
| 2262 |
<primary>disk quotas</primary> |
| 2263 |
<secondary>checking</secondary> |
| 2264 |
</indexterm> |
| 2265 |
<para>Normally on bootup, the quota integrity of each file |
| 2266 |
system is checked by &man.quotacheck.8;. This program insures |
| 2267 |
that the data in the quota database properly reflects the data |
| 2268 |
on the file system. This is a time consuming process that |
| 2269 |
will significantly affect the time the system takes to boot. |
| 2270 |
To skip this step, add this variable to |
| 2271 |
<filename>/etc/rc.conf</filename>:</para> |
| 2272 |
|
| 2273 |
<programlisting>check_quotas="NO"</programlisting> |
| 2274 |
|
| 2275 |
<para>Finally, edit <filename>/etc/fstab</filename> to enable |
| 2276 |
disk quotas on a per-file system basis. To enable per-user |
| 2277 |
quotas on a file system, add <option>userquota</option> to the |
| 2278 |
options field in the <filename>/etc/fstab</filename> entry for |
| 2279 |
the file system to enable quotas on. For example:</para> |
| 2280 |
|
| 2281 |
<programlisting>/dev/da1s2g /home ufs rw,userquota 1 2</programlisting> |
| 2282 |
|
| 2283 |
<para>To enable group quotas, use <option>groupquota</option> |
| 2284 |
instead. To enable both user and group quotas, separate the |
| 2285 |
options with a comma:</para> |
| 2286 |
|
| 2287 |
<programlisting>/dev/da1s2g /home ufs rw,userquota,groupquota 1 2</programlisting> |
| 2288 |
|
| 2289 |
<para>By default, quota files are stored in the root directory |
| 2290 |
of the file system as <filename>quota.user</filename> and |
| 2291 |
<filename>quota.group</filename>. Refer to &man.fstab.5; for |
| 2292 |
more information. Specifying an alternate location for the |
| 2293 |
quota files is not recommended.</para> |
| 2294 |
|
| 2295 |
<para>Once the configuration is complete, reboot the system and |
| 2296 |
<filename>/etc/rc</filename> will automatically run the |
| 2297 |
appropriate commands to create the initial quota files for all |
| 2298 |
of the quotas enabled in |
| 2299 |
<filename>/etc/fstab</filename>.</para> |
| 2300 |
|
| 2301 |
<para>In the normal course of operations, there should be no |
| 2302 |
need to manually run &man.quotacheck.8;, &man.quotaon.8;, or |
| 2303 |
&man.quotaoff.8;. However, one should read these manual pages |
| 2304 |
to be familiar with their operation.</para> |
| 2305 |
</sect2> |
| 2306 |
|
| 2307 |
<sect2> |
| 2308 |
<title>Setting Quota Limits</title> |
| 2309 |
|
| 2310 |
<indexterm> |
| 2311 |
<primary>disk quotas</primary> |
| 2312 |
<secondary>limits</secondary> |
| 2313 |
</indexterm> |
| 2314 |
|
| 2315 |
<para>To |
| 2316 |
verify that quotas are enabled, run:</para> |
| 2317 |
|
| 2318 |
<screen>&prompt.root; <userinput>quota -v</userinput></screen> |
| 2319 |
|
| 2320 |
<para>There should be a one line summary of disk usage and |
| 2321 |
current quota limits for each file system that quotas are |
| 2322 |
enabled on.</para> |
| 2323 |
|
| 2324 |
<para>The system is now ready to be assigned quota limits with |
| 2325 |
<command>edquota</command>.</para> |
| 2326 |
|
| 2327 |
<para>Several options are available to enforce limits on the |
| 2328 |
amount of disk space a user or group may allocate, and how |
| 2329 |
many files they may create. Allocations can be limited based |
| 2330 |
on disk space (block quotas), number of files (inode quotas), |
| 2331 |
or a combination of both. Each limit is further broken down |
| 2332 |
into two categories: hard and soft limits.</para> |
| 2333 |
|
| 2334 |
<indexterm><primary>hard limit</primary></indexterm> |
| 2335 |
<para>A hard limit may not be exceeded. Once a user reaches a |
| 2336 |
hard limit, no further allocations can be made on that file |
| 2337 |
system by that user. For example, if the user has a hard |
| 2338 |
limit of 500 kbytes on a file system and is currently using |
| 2339 |
490 kbytes, the user can only allocate an additional 10 |
| 2340 |
kbytes. Attempting to allocate an additional 11 kbytes will |
| 2341 |
fail.</para> |
| 2342 |
|
| 2343 |
<indexterm><primary>soft limit</primary></indexterm> |
| 2344 |
<para>Soft limits can be exceeded for a limited amount of time, |
| 2345 |
known as the grace period, which is one week by default. If a |
| 2346 |
user stays over their limit longer than the grace period, the |
| 2347 |
soft limit turns into a hard limit and no further allocations |
| 2348 |
are allowed. When the user drops back below the soft limit, |
| 2349 |
the grace period is reset.</para> |
| 2350 |
|
| 2351 |
<para>In the following example, the quota for the <systemitem |
| 2352 |
class="username">test</systemitem> account is being edited. |
| 2353 |
When <command>edquota</command> is invoked, the editor |
| 2354 |
specified by <envar>EDITOR</envar> is opened in order to edit |
| 2355 |
the quota limits. The default editor is set to |
| 2356 |
<application>vi</application>.</para> |
| 2357 |
|
| 2358 |
<screen>&prompt.root; <userinput>edquota -u test</userinput> |
| 2359 |
Quotas for user test: |
| 2360 |
/usr: kbytes in use: 65, limits (soft = 50, hard = 75) |
| 2361 |
inodes in use: 7, limits (soft = 50, hard = 60) |
| 2362 |
/usr/var: kbytes in use: 0, limits (soft = 50, hard = 75) |
| 2363 |
inodes in use: 0, limits (soft = 50, hard = 60)</screen> |
| 2364 |
|
| 2365 |
<para>There are normally two lines for each file system that has |
| 2366 |
quotas enabled. One line represents the block limits and the |
| 2367 |
other represents the inode limits. Change the value to modify |
| 2368 |
the quota limit. For example, to raise the block limit on |
| 2369 |
<filename>/usr</filename> to a soft limit of |
| 2370 |
<literal>500</literal> and a hard limit of |
| 2371 |
<literal>600</literal>, change the values in that line as |
| 2372 |
follows:</para> |
| 2373 |
|
| 2374 |
<programlisting>/usr: kbytes in use: 65, limits (soft = 500, hard = 600)</programlisting> |
| 2375 |
|
| 2376 |
<para>The new quota limits take effect upon exiting the |
| 2377 |
editor.</para> |
| 2378 |
|
| 2379 |
<para>Sometimes it is desirable to set quota limits on a range |
| 2380 |
of users. This can be done by first assigning the desired |
| 2381 |
quota limit to a user. Then, use <option>-p</option> to |
| 2382 |
duplicate that quota to a specified range of user IDs |
| 2383 |
(<acronym>UID</acronym>s). The following command will |
| 2384 |
duplicate those quota limits for <acronym>UID</acronym>s |
| 2385 |
<literal>10,000</literal> through |
| 2386 |
<literal>19,999</literal>:</para> |
| 2387 |
|
| 2388 |
<screen>&prompt.root; <userinput>edquota -p test 10000-19999</userinput></screen> |
| 2389 |
|
| 2390 |
<para>For more information, refer to &man.edquota.8;.</para> |
| 2391 |
</sect2> |
| 2392 |
|
| 2393 |
<sect2> |
| 2394 |
<title>Checking Quota Limits and Disk Usage</title> |
| 2395 |
|
| 2396 |
<indexterm> |
| 2397 |
<primary>disk quotas</primary> |
| 2398 |
<secondary>checking</secondary> |
| 2399 |
</indexterm> |
| 2400 |
|
| 2401 |
<para>To check individual user or group quotas and disk usage, |
| 2402 |
use &man.quota.1;. A user may only examine their own quota |
| 2403 |
and the quota of a group they are a member of. Only the |
| 2404 |
superuser may view all user and group quotas. To get a |
| 2405 |
summary of all quotas and disk usage for file systems with |
| 2406 |
quotas enabled, use &man.repquota.8;.</para> |
| 2407 |
|
| 2408 |
<para>Normally, file systems that the user is not using any disk |
| 2409 |
space on will not show in the output of |
| 2410 |
<command>quota</command>, even if the user has a quota limit |
| 2411 |
assigned for that file system. Use <option>-v</option> to |
| 2412 |
display those file systems. The following is sample output |
| 2413 |
from <command>quota -v</command> for a user that has quota |
| 2414 |
limits on two file systems.</para> |
| 2415 |
|
| 2416 |
<programlisting>Disk quotas for user test (uid 1002): |
| 2417 |
Filesystem usage quota limit grace files quota limit grace |
| 2418 |
/usr 65* 50 75 5days 7 50 60 |
| 2419 |
/usr/var 0 50 75 0 50 60</programlisting> |
| 2420 |
|
| 2421 |
<indexterm><primary>grace period</primary></indexterm> |
| 2422 |
|
| 2423 |
<para>In this example, the user is currently 15 kbytes over the |
| 2424 |
soft limit of 50 kbytes on <filename>/usr</filename> and has 5 |
| 2425 |
days of grace period left. The asterisk <literal>*</literal> |
| 2426 |
indicates that the user is currently over the quota |
| 2427 |
limit.</para> |
| 2428 |
</sect2> |
| 2429 |
|
| 2430 |
<sect2> |
| 2431 |
<title>Quotas over NFS</title> |
| 2432 |
|
| 2433 |
<indexterm><primary>NFS</primary></indexterm> |
| 2434 |
|
| 2435 |
<para>Quotas are enforced by the quota subsystem on the |
| 2436 |
<acronym>NFS</acronym> server. The &man.rpc.rquotad.8; daemon |
| 2437 |
makes quota information available to <command>quota</command> |
| 2438 |
on <acronym>NFS</acronym> clients, allowing users on those |
| 2439 |
machines to see their quota statistics.</para> |
| 2440 |
|
| 2441 |
<para>On the <acronym>NFS</acronym> server, enable |
| 2442 |
<command>rpc.rquotad</command> by removing the |
| 2443 |
<literal>#</literal> from this line in |
| 2444 |
<filename>/etc/inetd.conf</filename>:</para> |
| 2445 |
|
| 2446 |
<programlisting>rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad</programlisting> |
| 2447 |
|
| 2448 |
<para>Then, restart <command>inetd</command>:</para> |
| 2449 |
|
| 2450 |
<screen>&prompt.root; <userinput>service inetd restart</userinput></screen> |
| 2451 |
</sect2> |
| 2452 |
</sect1> |
| 2453 |
|
| 2454 |
<sect1 xml:id="disks-encrypting"> |
| 2455 |
<info> |
| 2456 |
<title>Encrypting Disk Partitions</title> |
| 2457 |
|
| 2458 |
<authorgroup> |
| 2459 |
<author> |
| 2460 |
<personname> |
| 2461 |
<firstname>Lucky</firstname> |
| 2462 |
<surname>Green</surname> |
| 2463 |
</personname> |
| 2464 |
<contrib>Contributed by </contrib> |
| 2465 |
<affiliation> |
| 2466 |
<address> |
| 2467 |
<email>shamrock@cypherpunks.to</email> |
| 2468 |
</address> |
| 2469 |
</affiliation> |
| 2470 |
</author> |
| 2471 |
</authorgroup> |
| 2472 |
</info> |
| 2473 |
|
| 2474 |
<indexterm> |
| 2475 |
<primary>disks</primary> |
| 2476 |
<secondary>encrypting</secondary> |
| 2477 |
</indexterm> |
| 2478 |
|
| 2479 |
<para>&os; offers excellent online protections against |
| 2480 |
unauthorized data access. File permissions and <link |
| 2481 |
linkend="mac">Mandatory Access Control</link> (MAC) help |
| 2482 |
prevent unauthorized users from accessing data while the |
| 2483 |
operating system is active and the computer is powered up. |
| 2484 |
However, the permissions enforced by the operating system are |
| 2485 |
irrelevant if an attacker has physical access to a computer and |
| 2486 |
can move the computer's hard drive to another system to copy and |
| 2487 |
analyze the data.</para> |
| 2488 |
|
| 2489 |
<para>Regardless of how an attacker may have come into possession |
| 2490 |
of a hard drive or powered-down computer, the |
| 2491 |
<acronym>GEOM</acronym>-based cryptographic subsystems built |
| 2492 |
into &os; are able to protect the data on the computer's file |
| 2493 |
systems against even highly-motivated attackers with significant |
| 2494 |
resources. Unlike encryption methods that encrypt individual |
| 2495 |
files, the built-in <command>gbde</command> and |
| 2496 |
<command>geli</command> utilities can be used to transparently |
| 2497 |
encrypt entire file systems. No cleartext ever touches the hard |
| 2498 |
drive's platter.</para> |
| 2499 |
|
| 2500 |
<para>This chapter demonstrates how to create an encrypted file |
| 2501 |
system on &os;. It first demonstrates the process using |
| 2502 |
<command>gbde</command> and then demonstrates the same example |
| 2503 |
using <command>geli</command>.</para> |
| 2504 |
|
| 2505 |
<sect2> |
| 2506 |
<title>Disk Encryption with |
| 2507 |
<application>gbde</application></title> |
| 2508 |
|
| 2509 |
<para>The objective of the &man.gbde.4; facility is to provide a |
| 2510 |
formidable challenge for an attacker to gain access to the |
| 2511 |
contents of a <emphasis>cold</emphasis> storage device. |
| 2512 |
However, if the computer is compromised while up and running |
| 2513 |
and the storage device is actively attached, or the attacker |
| 2514 |
has access to a valid passphrase, it offers no protection to |
| 2515 |
the contents of the storage device. Thus, it is important to |
| 2516 |
provide physical security while the system is running and to |
| 2517 |
protect the passphrase used by the encryption |
| 2518 |
mechanism.</para> |
| 2519 |
|
| 2520 |
<para>This facility provides several barriers to protect the |
| 2521 |
data stored in each disk sector. It encrypts the contents of |
| 2522 |
a disk sector using 128-bit <acronym>AES</acronym> in |
| 2523 |
<acronym>CBC</acronym> mode. Each sector on the disk is |
| 2524 |
encrypted with a different <acronym>AES</acronym> key. For |
| 2525 |
more information on the cryptographic design, including how |
| 2526 |
the sector keys are derived from the user-supplied passphrase, |
| 2527 |
refer to &man.gbde.4;.</para> |
| 2528 |
|
| 2529 |
<para>&os; provides a kernel module for |
| 2530 |
<application>gbde</application> which can be loaded with this |
| 2531 |
command:</para> |
| 2532 |
|
| 2533 |
<screen>&prompt.root; <userinput>kldload geom_bde</userinput></screen> |
| 2534 |
|
| 2535 |
<para>If using a custom kernel configuration file, ensure it |
| 2536 |
contains this line:</para> |
| 2537 |
|
| 2538 |
<para><literal>options GEOM_BDE</literal></para> |
| 2539 |
|
| 2540 |
<para>The following example demonstrates adding a new hard drive |
| 2541 |
to a system that will hold a single encrypted partition that |
| 2542 |
will be mounted as <filename>/private</filename>.</para> |
| 2543 |
|
| 2544 |
<procedure> |
| 2545 |
<title>Encrypting a Partition with |
| 2546 |
<application>gbde</application></title> |
| 2547 |
|
| 2548 |
<step> |
| 2549 |
<title>Add the New Hard Drive</title> |
| 2550 |
|
| 2551 |
<para>Install the new drive to the system as explained in |
| 2552 |
<xref linkend="disks-adding"/>. For the purposes of this |
| 2553 |
example, a new hard drive partition has been added as |
| 2554 |
<filename>/dev/ad4s1c</filename> and |
| 2555 |
<filename>/dev/ad0s1<replaceable>*</replaceable></filename> |
| 2556 |
represents the existing standard &os; partitions.</para> |
| 2557 |
|
| 2558 |
<screen>&prompt.root; <userinput>ls /dev/ad*</userinput> |
| 2559 |
/dev/ad0 /dev/ad0s1b /dev/ad0s1e /dev/ad4s1 |
| 2560 |
/dev/ad0s1 /dev/ad0s1c /dev/ad0s1f /dev/ad4s1c |
| 2561 |
/dev/ad0s1a /dev/ad0s1d /dev/ad4</screen> |
| 2562 |
</step> |
| 2563 |
|
| 2564 |
<step> |
| 2565 |
<title>Create a Directory to Hold <command>gbde</command> |
| 2566 |
Lock Files</title> |
| 2567 |
|
| 2568 |
<screen>&prompt.root; <userinput>mkdir /etc/gbde</userinput></screen> |
| 2569 |
|
| 2570 |
<para>The <application>gbde</application> lock file |
| 2571 |
contains information that <application>gbde</application> |
| 2572 |
requires to access encrypted partitions. Without access |
| 2573 |
to the lock file, <application>gbde</application> will not |
| 2574 |
be able to decrypt the data contained in the encrypted |
| 2575 |
partition without significant manual intervention which is |
| 2576 |
not supported by the software. Each encrypted partition |
| 2577 |
uses a separate lock file.</para> |
| 2578 |
</step> |
| 2579 |
|
| 2580 |
<step> |
| 2581 |
<title>Initialize the <command>gbde</command> |
| 2582 |
Partition</title> |
| 2583 |
|
| 2584 |
<para>A <application>gbde</application> partition must be |
| 2585 |
initialized before it can be used. This initialization |
| 2586 |
needs to be performed only once. This command will open |
| 2587 |
the default editor, in order to set various configuration |
| 2588 |
options in a template. For use with the |
| 2589 |
<acronym>UFS</acronym> file system, set the sector_size to |
| 2590 |
2048:</para> |
| 2591 |
|
| 2592 |
<screen>&prompt.root; <userinput>gbde init /dev/ad4s1c -i -L /etc/gbde/ad4s1c.lock</userinput> |
| 2593 |
# <phrase its:translate="no">$FreeBSD: src/sbin/gbde/template.txt,v 1.1.36.1 2009/08/03 08:13:06 kensmith Exp $</phrase> |
| 2594 |
# |
| 2595 |
# Sector size is the smallest unit of data which can be read or written. |
| 2596 |
# Making it too small decreases performance and decreases available space. |
| 2597 |
# Making it too large may prevent filesystems from working. 512 is the |
| 2598 |
# minimum and always safe. For UFS, use the fragment size |
| 2599 |
# |
| 2600 |
sector_size = 2048 |
| 2601 |
[...]</screen> |
| 2602 |
|
| 2603 |
<para>Once the edit is saved, the user will be asked twice |
| 2604 |
to type the passphrase used to secure the data. The |
| 2605 |
passphrase must be the same both times. The ability of |
| 2606 |
<application>gbde</application> to protect data depends |
| 2607 |
entirely on the quality of the passphrase. For tips on |
| 2608 |
how to select a secure passphrase that is easy to |
| 2609 |
remember, see <link |
| 2610 |
xlink:href="http://world.std.com/~reinhold/diceware.html">http://world.std.com/~reinhold/diceware.htm</link>.</para> |
| 2611 |
|
| 2612 |
<para>This initialization creates a lock file for the |
| 2613 |
<application>gbde</application> partition. In this |
| 2614 |
example, it is stored as |
| 2615 |
<filename>/etc/gbde/ad4s1c.lock</filename>. Lock files |
| 2616 |
must end in <quote>.lock</quote> in order to be correctly |
| 2617 |
detected by the <filename>/etc/rc.d/gbde</filename> start |
| 2618 |
up script.</para> |
| 2619 |
|
| 2620 |
<caution> |
| 2621 |
<para>Lock files <emphasis>must</emphasis> be backed up |
| 2622 |
together with the contents of any encrypted partitions. |
| 2623 |
Without the lock file, the legitimate owner will be |
| 2624 |
unable to access the data on the encrypted |
| 2625 |
partition.</para> |
| 2626 |
</caution> |
| 2627 |
</step> |
| 2628 |
|
| 2629 |
<step> |
| 2630 |
<title>Attach the Encrypted Partition to the |
| 2631 |
Kernel</title> |
| 2632 |
|
| 2633 |
<screen>&prompt.root; <userinput>gbde attach /dev/ad4s1c -l /etc/gbde/ad4s1c.lock</userinput></screen> |
| 2634 |
|
| 2635 |
<para>This command will prompt to input the passphrase that |
| 2636 |
was selected during the initialization of the encrypted |
| 2637 |
partition. The new encrypted device will appear in |
| 2638 |
<filename>/dev</filename> as |
| 2639 |
<filename>/dev/device_name.bde</filename>:</para> |
| 2640 |
|
| 2641 |
<screen>&prompt.root; <userinput>ls /dev/ad*</userinput> |
| 2642 |
/dev/ad0 /dev/ad0s1b /dev/ad0s1e /dev/ad4s1 |
| 2643 |
/dev/ad0s1 /dev/ad0s1c /dev/ad0s1f /dev/ad4s1c |
| 2644 |
/dev/ad0s1a /dev/ad0s1d /dev/ad4 /dev/ad4s1c.bde</screen> |
| 2645 |
</step> |
| 2646 |
|
| 2647 |
<step> |
| 2648 |
<title>Create a File System on the Encrypted |
| 2649 |
Device</title> |
| 2650 |
|
| 2651 |
<para>Once the encrypted device has been attached to the |
| 2652 |
kernel, a file system can be created on the device. This |
| 2653 |
example creates a <acronym>UFS</acronym> file system with |
| 2654 |
soft updates enabled. Be sure to specify the partition |
| 2655 |
which has a |
| 2656 |
<filename><replaceable>*</replaceable>.bde</filename> |
| 2657 |
extension:</para> |
| 2658 |
|
| 2659 |
<screen>&prompt.root; <userinput>newfs -U /dev/ad4s1c.bde</userinput></screen> |
| 2660 |
</step> |
| 2661 |
|
| 2662 |
<step> |
| 2663 |
<title>Mount the Encrypted Partition</title> |
| 2664 |
|
| 2665 |
<para>Create a mount point and mount the encrypted file |
| 2666 |
system:</para> |
| 2667 |
|
| 2668 |
<screen>&prompt.root; <userinput>mkdir /private</userinput> |
| 2669 |
&prompt.root; <userinput>mount /dev/ad4s1c.bde /private</userinput></screen> |
| 2670 |
</step> |
| 2671 |
|
| 2672 |
<step> |
| 2673 |
<title>Verify That the Encrypted File System is |
| 2674 |
Available</title> |
| 2675 |
|
| 2676 |
<para>The encrypted file system should now be visible and |
| 2677 |
available for use:</para> |
| 2678 |
|
| 2679 |
<screen>&prompt.user; <userinput>df -H</userinput> |
| 2680 |
Filesystem Size Used Avail Capacity Mounted on |
| 2681 |
/dev/ad0s1a 1037M 72M 883M 8% / |
| 2682 |
/devfs 1.0K 1.0K 0B 100% /dev |
| 2683 |
/dev/ad0s1f 8.1G 55K 7.5G 0% /home |
| 2684 |
/dev/ad0s1e 1037M 1.1M 953M 0% /tmp |
| 2685 |
/dev/ad0s1d 6.1G 1.9G 3.7G 35% /usr |
| 2686 |
/dev/ad4s1c.bde 150G 4.1K 138G 0% /private</screen> |
| 2687 |
</step> |
| 2688 |
</procedure> |
| 2689 |
|
| 2690 |
<para>After each boot, any encrypted file systems must be |
| 2691 |
manually re-attached to the kernel, checked for errors, and |
| 2692 |
mounted, before the file systems can be used. To configure |
| 2693 |
these steps, add the following lines to |
| 2694 |
<filename>/etc/rc.conf</filename>:</para> |
| 2695 |
|
| 2696 |
<programlisting>gbde_autoattach_all="YES" |
| 2697 |
gbde_devices="<replaceable>ad4s1c</replaceable>" |
| 2698 |
gbde_lockdir="/etc/gbde"</programlisting> |
| 2699 |
|
| 2700 |
<para>This requires that the passphrase be entered at the |
| 2701 |
console at boot time. After typing the correct passphrase, |
| 2702 |
the encrypted partition will be mounted automatically. |
| 2703 |
Additional <application>gbde</application> boot options are |
| 2704 |
available and listed in &man.rc.conf.5;.</para> |
| 2705 |
|
| 2706 |
<!-- |
| 2707 |
What about bsdinstall? |
| 2708 |
--> |
| 2709 |
<note> |
| 2710 |
<para><application>sysinstall</application> is incompatible |
| 2711 |
with <application>gbde</application>-encrypted devices. All |
| 2712 |
<filename>*.bde</filename> devices must be detached from the |
| 2713 |
kernel before starting <application>sysinstall</application> |
| 2714 |
or it will crash during its initial probing for devices. To |
| 2715 |
detach the encrypted device used in the example, use the |
| 2716 |
following command:</para> |
| 2717 |
|
| 2718 |
<screen>&prompt.root; <userinput>gbde detach /dev/<replaceable>ad4s1c</replaceable></userinput></screen> |
| 2719 |
</note> |
| 2720 |
</sect2> |
| 2721 |
|
| 2722 |
<sect2 xml:id="disks-encrypting-geli"> |
| 2723 |
<info> |
| 2724 |
<title>Disk Encryption with <command>geli</command></title> |
| 2725 |
|
| 2726 |
<authorgroup> |
| 2727 |
<author> |
| 2728 |
<personname> |
| 2729 |
<firstname>Daniel</firstname> |
| 2730 |
<surname>Gerzo</surname> |
| 2731 |
</personname> |
| 2732 |
<contrib>Contributed by </contrib> |
| 2733 |
</author> |
| 2734 |
</authorgroup> |
| 2735 |
</info> |
| 2736 |
|
| 2737 |
<para>An alternative cryptographic <acronym>GEOM</acronym> class |
| 2738 |
is available using <command>geli</command>. This control |
| 2739 |
utility adds some features and uses a different scheme for |
| 2740 |
doing cryptographic work. It provides the following |
| 2741 |
features:</para> |
| 2742 |
|
| 2743 |
<itemizedlist> |
| 2744 |
<listitem> |
| 2745 |
<para>Utilizes the &man.crypto.9; framework and |
| 2746 |
automatically uses cryptographic hardware when it is |
| 2747 |
available.</para> |
| 2748 |
</listitem> |
| 2749 |
|
| 2750 |
<listitem> |
| 2751 |
<para>Supports multiple cryptographic algorithms such as |
| 2752 |
<acronym>AES</acronym>, Blowfish, and |
| 2753 |
<acronym>3DES</acronym>.</para> |
| 2754 |
</listitem> |
| 2755 |
|
| 2756 |
<listitem> |
| 2757 |
<para>Allows the root partition to be encrypted. The |
| 2758 |
passphrase used to access the encrypted root partition |
| 2759 |
will be requested during system boot.</para> |
| 2760 |
</listitem> |
| 2761 |
|
| 2762 |
<listitem> |
| 2763 |
<para>Allows the use of two independent keys.</para> |
| 2764 |
</listitem> |
| 2765 |
|
| 2766 |
<listitem> |
| 2767 |
<para>It is fast as it performs simple sector-to-sector |
| 2768 |
encryption.</para> |
| 2769 |
</listitem> |
| 2770 |
|
| 2771 |
<listitem> |
| 2772 |
<para>Allows backup and restore of master keys. If a user |
| 2773 |
destroys their keys, it is still possible to get access to |
| 2774 |
the data by restoring keys from the backup.</para> |
| 2775 |
</listitem> |
| 2776 |
|
| 2777 |
<listitem> |
| 2778 |
<para>Allows a disk to attach with a random, one-time key |
| 2779 |
which is useful for swap partitions and temporary file |
| 2780 |
systems.</para> |
| 2781 |
</listitem> |
| 2782 |
</itemizedlist> |
| 2783 |
|
| 2784 |
<para>More features and usage examples can be found in |
| 2785 |
&man.geli.8;.</para> |
| 2786 |
|
| 2787 |
<para>The following example describes how to generate a key file |
| 2788 |
which will be used as part of the master key for the encrypted |
| 2789 |
provider mounted under <filename>/private</filename>. The key |
| 2790 |
file will provide some random data used to encrypt the master |
| 2791 |
key. The master key will also be protected by a passphrase. |
| 2792 |
The provider's sector size will be 4kB. The example describes |
| 2793 |
how to attach to the <command>geli</command> provider, create |
| 2794 |
a file system on it, mount it, work with it, and finally, how |
| 2795 |
to detach it.</para> |
| 2796 |
|
| 2797 |
<procedure> |
| 2798 |
<title>Encrypting a Partition with |
| 2799 |
<command>geli</command></title> |
| 2800 |
|
| 2801 |
<step> |
| 2802 |
<title>Load <command>geli</command> Support</title> |
| 2803 |
|
| 2804 |
<para>Support for <command>geli</command> is available as a |
| 2805 |
loadable kernel module. To configure the system to |
| 2806 |
automatically load the module at boot time, add the |
| 2807 |
following line to |
| 2808 |
<filename>/boot/loader.conf</filename>:</para> |
| 2809 |
|
| 2810 |
<programlisting>geom_eli_load="YES"</programlisting> |
| 2811 |
|
| 2812 |
<para>To load the kernel module now:</para> |
| 2813 |
|
| 2814 |
<screen>&prompt.root; <userinput>kldload geom_eli</userinput></screen> |
| 2815 |
|
| 2816 |
<para>For a custom kernel, ensure the kernel configuration |
| 2817 |
file contains these lines:</para> |
| 2818 |
|
| 2819 |
<programlisting>options GEOM_ELI |
| 2820 |
device crypto</programlisting> |
| 2821 |
</step> |
| 2822 |
|
| 2823 |
<step> |
| 2824 |
<title>Generate the Master Key</title> |
| 2825 |
|
| 2826 |
<para>The following commands generate a master key that all |
| 2827 |
data will be encrypted with. This key can never be changed. |
| 2828 |
Rather than using it directly, it is encrypted with one |
| 2829 |
or more user keys. The user keys are made up of an |
| 2830 |
optional combination of random bytes from a file, |
| 2831 |
<filename>/root/da2.key</filename>, and/or a passphrase. |
| 2832 |
In this case, the data source for the key file is |
| 2833 |
<filename>/dev/random</filename>. This command also |
| 2834 |
configures the sector size of the provider |
| 2835 |
(<filename>/dev/da2.eli</filename>) as 4kB, for better |
| 2836 |
performance:</para> |
| 2837 |
|
| 2838 |
<screen>&prompt.root; <userinput>dd if=/dev/random of=/root/da2.key bs=64 count=1</userinput> |
| 2839 |
&prompt.root; <userinput>geli init -K /root/da2.key -s 4096 /dev/da2</userinput> |
| 2840 |
Enter new passphrase: |
| 2841 |
Reenter new passphrase:</screen> |
| 2842 |
|
| 2843 |
<para>It is not mandatory to use both a passphrase and a key |
| 2844 |
file as either method of securing the master key can be |
| 2845 |
used in isolation.</para> |
| 2846 |
|
| 2847 |
<para>If the key file is given as <quote>-</quote>, standard |
| 2848 |
input will be used. For example, this command generates |
| 2849 |
three key files:</para> |
| 2850 |
|
| 2851 |
<screen>&prompt.root; <userinput>cat keyfile1 keyfile2 keyfile3 | geli init -K - /dev/da2</userinput></screen> |
| 2852 |
</step> |
| 2853 |
|
| 2854 |
<step> |
| 2855 |
<title>Attach the Provider with the Generated Key</title> |
| 2856 |
|
| 2857 |
<para>To attach the provider, specify the key file, the name |
| 2858 |
of the disk, and the passphrase:</para> |
| 2859 |
|
| 2860 |
<screen>&prompt.root; <userinput>geli attach -k /root/da2.key /dev/da2</userinput> |
| 2861 |
Enter passphrase:</screen> |
| 2862 |
|
| 2863 |
<para>This creates a new device with an |
| 2864 |
<filename>.eli</filename> extension:</para> |
| 2865 |
|
| 2866 |
<screen>&prompt.root; <userinput>ls /dev/da2*</userinput> |
| 2867 |
/dev/da2 /dev/da2.eli</screen> |
| 2868 |
</step> |
| 2869 |
|
| 2870 |
<step> |
| 2871 |
<title>Create the New File System</title> |
| 2872 |
|
| 2873 |
<para>Next, format the device with the |
| 2874 |
<acronym>UFS</acronym> file system and mount it on an |
| 2875 |
existing mount point:</para> |
| 2876 |
|
| 2877 |
<screen>&prompt.root; <userinput>dd if=/dev/random of=/dev/da2.eli bs=1m</userinput> |
| 2878 |
&prompt.root; <userinput>newfs /dev/da2.eli</userinput> |
| 2879 |
&prompt.root; <userinput>mount /dev/da2.eli <replaceable>/private</replaceable></userinput></screen> |
| 2880 |
|
| 2881 |
<para>The encrypted file system should now be available for |
| 2882 |
use:</para> |
| 2883 |
|
| 2884 |
<screen>&prompt.root; <userinput>df -H</userinput> |
| 2885 |
Filesystem Size Used Avail Capacity Mounted on |
| 2886 |
/dev/ad0s1a 248M 89M 139M 38% / |
| 2887 |
/devfs 1.0K 1.0K 0B 100% /dev |
| 2888 |
/dev/ad0s1f 7.7G 2.3G 4.9G 32% /usr |
| 2889 |
/dev/ad0s1d 989M 1.5M 909M 0% /tmp |
| 2890 |
/dev/ad0s1e 3.9G 1.3G 2.3G 35% /var |
| 2891 |
/dev/da2.eli 150G 4.1K 138G 0% /private</screen> |
| 2892 |
</step> |
| 2893 |
</procedure> |
| 2894 |
|
| 2895 |
<para>Once the work on the encrypted partition is done, and the |
| 2896 |
<filename>/private</filename> partition is no longer needed, |
| 2897 |
it is prudent to put the device into cold storage by |
| 2898 |
unmounting and detaching the <command>geli</command> encrypted |
| 2899 |
partition from the kernel:</para> |
| 2900 |
|
| 2901 |
<screen>&prompt.root; <userinput>umount /private</userinput> |
| 2902 |
&prompt.root; <userinput>geli detach da2.eli</userinput></screen> |
| 2903 |
|
| 2904 |
<para>A <filename>rc.d</filename> script is provided to |
| 2905 |
simplify the mounting of <command>geli</command>-encrypted |
| 2906 |
devices at boot time. For this example, add these lines to |
| 2907 |
<filename>/etc/rc.conf</filename>:</para> |
| 2908 |
|
| 2909 |
<programlisting>geli_devices="<replaceable>da2</replaceable>" |
| 2910 |
geli_da2_flags="-k /root/<replaceable>da2.key</replaceable>"</programlisting> |
| 2911 |
|
| 2912 |
<para>This configures <filename>/dev/da2</filename> as a |
| 2913 |
<command>geli</command> provider with a master key of |
| 2914 |
<filename>/root/da2.key</filename>. The system will |
| 2915 |
automatically detach the provider from the kernel before the |
| 2916 |
system shuts down. During the startup process, the script |
| 2917 |
will prompt for the passphrase before attaching the provider. |
| 2918 |
Other kernel messages might be shown before and after the |
| 2919 |
password prompt. If the boot process seems to stall, look |
| 2920 |
carefully for the password prompt among the other messages. |
| 2921 |
Once the correct passphrase is entered, the provider is |
| 2922 |
attached. The file system is then mounted, typically by an |
| 2923 |
entry in <filename>/etc/fstab</filename>. Refer to <xref |
| 2924 |
linkend="mount-unmount"/> for instructions on how to |
| 2925 |
configure a file system to mount at boot time.</para> |
| 2926 |
</sect2> |
| 2927 |
</sect1> |
| 2928 |
|
| 2929 |
<sect1 xml:id="swap-encrypting"> |
| 2930 |
<info> |
| 2931 |
<title>Encrypting Swap</title> |
| 2932 |
|
| 2933 |
<authorgroup> |
| 2934 |
<author> |
| 2935 |
<personname> |
| 2936 |
<firstname>Christian</firstname> |
| 2937 |
<surname>Brueffer</surname> |
| 2938 |
</personname> |
| 2939 |
<contrib>Written by </contrib> |
| 2940 |
</author> |
| 2941 |
</authorgroup> |
| 2942 |
</info> |
| 2943 |
|
| 2944 |
<indexterm> |
| 2945 |
<primary>swap</primary> |
| 2946 |
<secondary>encrypting</secondary> |
| 2947 |
</indexterm> |
| 2948 |
|
| 2949 |
<para>Like the encryption of disk partitions, encryption of swap |
| 2950 |
space is used to protect sensitive information. Consider an |
| 2951 |
application that deals with passwords. As long as these |
| 2952 |
passwords stay in physical memory, they are not written to disk |
| 2953 |
and will be cleared after a reboot. However, if &os; starts |
| 2954 |
swapping out memory pages to free space, the passwords may be |
| 2955 |
written to the disk unencrypted. Encrypting swap space can be a |
| 2956 |
solution for this scenario.</para> |
| 2957 |
|
| 2958 |
<para>This section demonstrates how to configure an encrypted |
| 2959 |
swap partition using &man.gbde.8; or &man.geli.8; encryption. |
| 2960 |
It assumes that |
| 2961 |
<filename>/dev/ada0s1b</filename> is the swap partition.</para> |
| 2962 |
|
| 2963 |
<sect2> |
| 2964 |
<title>Configuring Encrypted Swap</title> |
| 2965 |
|
| 2966 |
<para>Swap partitions are not encrypted by default and should be |
| 2967 |
cleared of any sensitive data before continuing. To overwrite |
| 2968 |
the current swap partition with random garbage, execute the |
| 2969 |
following command:</para> |
| 2970 |
|
| 2971 |
<screen>&prompt.root; <userinput>dd if=/dev/random of=/dev/<replaceable>ada0s1b</replaceable> bs=1m</userinput></screen> |
| 2972 |
|
| 2973 |
<para>To encrypt the swap partition using &man.gbde.8;, add the |
| 2974 |
<literal>.bde</literal> suffix to the swap line in |
| 2975 |
<filename>/etc/fstab</filename>:</para> |
| 2976 |
|
| 2977 |
<programlisting># Device Mountpoint FStype Options Dump Pass# |
| 2978 |
/dev/ada0s1b.bde none swap sw 0 0</programlisting> |
| 2979 |
|
| 2980 |
<para>To instead encrypt the swap partition using &man.geli.8;, |
| 2981 |
use the |
| 2982 |
<literal>.eli</literal> suffix:</para> |
| 2983 |
|
| 2984 |
<programlisting># Device Mountpoint FStype Options Dump Pass# |
| 2985 |
/dev/ada0s1b.eli none swap sw 0 0</programlisting> |
| 2986 |
|
| 2987 |
<para>By default, &man.geli.8; uses the <acronym>AES</acronym> |
| 2988 |
algorithm with a key length of 128 bits. Normally the default |
| 2989 |
settings will suffice. If desired, these defaults can be |
| 2990 |
altered in the options field in |
| 2991 |
<filename>/etc/fstab</filename>. The possible flags |
| 2992 |
are:</para> |
| 2993 |
|
| 2994 |
<variablelist> |
| 2995 |
<varlistentry> |
| 2996 |
<term>aalgo</term> |
| 2997 |
<listitem> |
| 2998 |
<para>Data integrity verification algorithm used to ensure |
| 2999 |
that the encrypted data has not been tampered with. See |
| 3000 |
&man.geli.8; for a list of supported algorithms.</para> |
| 3001 |
</listitem> |
| 3002 |
</varlistentry> |
| 3003 |
|
| 3004 |
<varlistentry> |
| 3005 |
<term>ealgo</term> |
| 3006 |
<listitem> |
| 3007 |
<para>Encryption algorithm used to protect the data. See |
| 3008 |
&man.geli.8; for a list of supported algorithms.</para> |
| 3009 |
</listitem> |
| 3010 |
</varlistentry> |
| 3011 |
|
| 3012 |
<varlistentry> |
| 3013 |
<term>keylen</term> |
| 3014 |
<listitem> |
| 3015 |
<para>The length of the key used for the encryption |
| 3016 |
algorithm. See &man.geli.8; for the key lengths that |
| 3017 |
are supported by each encryption algorithm.</para> |
| 3018 |
</listitem> |
| 3019 |
</varlistentry> |
| 3020 |
|
| 3021 |
<varlistentry> |
| 3022 |
<term>sectorsize</term> |
| 3023 |
<listitem> |
| 3024 |
<para>The size of the blocks data is broken into before |
| 3025 |
it is encrypted. Larger sector sizes increase |
| 3026 |
performance at the cost of higher storage |
| 3027 |
overhead. The recommended size is 4096 bytes.</para> |
| 3028 |
</listitem> |
| 3029 |
</varlistentry> |
| 3030 |
</variablelist> |
| 3031 |
|
| 3032 |
<para>This example configures an encrypted swap partition using |
| 3033 |
the Blowfish algorithm with a key length of 128 bits and a |
| 3034 |
sectorsize of 4 kilobytes:</para> |
| 3035 |
|
| 3036 |
<programlisting># Device Mountpoint FStype Options Dump Pass# |
| 3037 |
/dev/ada0s1b.eli none swap sw,ealgo=blowfish,keylen=128,sectorsize=4096 0 0</programlisting> |
| 3038 |
|
| 3039 |
</sect2> |
| 3040 |
|
| 3041 |
<sect2> |
| 3042 |
<title>Encrypted Swap Verification</title> |
| 3043 |
|
| 3044 |
<para>Once the system has rebooted, proper operation of the |
| 3045 |
encrypted swap can be verified using |
| 3046 |
<command>swapinfo</command>.</para> |
| 3047 |
|
| 3048 |
<para>If &man.gbde.8; is being used:</para> |
| 3049 |
|
| 3050 |
<screen>&prompt.user; <userinput>swapinfo</userinput> |
| 3051 |
Device 1K-blocks Used Avail Capacity |
| 3052 |
/dev/ada0s1b.bde 542720 0 542720 0%</screen> |
| 3053 |
|
| 3054 |
<para>If &man.geli.8; is being used:</para> |
| 3055 |
|
| 3056 |
<screen>&prompt.user; <userinput>swapinfo</userinput> |
| 3057 |
Device 1K-blocks Used Avail Capacity |
| 3058 |
/dev/ada0s1b.eli 542720 0 542720 0%</screen> |
| 3059 |
</sect2> |
| 3060 |
</sect1> |
| 3061 |
|
| 3062 |
<sect1 xml:id="disks-hast"> |
| 3063 |
<info> |
| 3064 |
<title>Highly Available Storage |
| 3065 |
(<acronym>HAST</acronym>)</title> |
| 3066 |
|
| 3067 |
<authorgroup> |
| 3068 |
<author> |
| 3069 |
<personname> |
| 3070 |
<firstname>Daniel</firstname> |
| 3071 |
<surname>Gerzo</surname> |
| 3072 |
</personname> |
| 3073 |
<contrib>Contributed by </contrib> |
| 3074 |
</author> |
| 3075 |
</authorgroup> |
| 3076 |
|
| 3077 |
<authorgroup> |
| 3078 |
<author> |
| 3079 |
<personname> |
| 3080 |
<firstname>Freddie</firstname> |
| 3081 |
<surname>Cash</surname> |
| 3082 |
</personname> |
| 3083 |
<contrib>With inputs from </contrib> |
| 3084 |
</author> |
| 3085 |
|
| 3086 |
<author> |
| 3087 |
<personname> |
| 3088 |
<firstname>Pawel Jakub</firstname> |
| 3089 |
<surname>Dawidek</surname> |
| 3090 |
</personname> |
| 3091 |
</author> |
| 3092 |
|
| 3093 |
<author> |
| 3094 |
<personname> |
| 3095 |
<firstname>Michael W.</firstname> |
| 3096 |
<surname>Lucas</surname> |
| 3097 |
</personname> |
| 3098 |
</author> |
| 3099 |
|
| 3100 |
<author> |
| 3101 |
<personname> |
| 3102 |
<firstname>Viktor</firstname> |
| 3103 |
<surname>Petersson</surname> |
| 3104 |
</personname> |
| 3105 |
</author> |
| 3106 |
</authorgroup> |
| 3107 |
</info> |
| 3108 |
|
| 3109 |
<indexterm> |
| 3110 |
<primary>HAST</primary> |
| 3111 |
<secondary>high availability</secondary> |
| 3112 |
</indexterm> |
| 3113 |
|
| 3114 |
<para>High availability is one of the main requirements in |
| 3115 |
serious business applications and highly-available storage is a |
| 3116 |
key component in such environments. In &os;, the Highly |
| 3117 |
Available STorage (<acronym>HAST</acronym>) framework allows |
| 3118 |
transparent storage of the same data across several physically |
| 3119 |
separated machines connected by a <acronym>TCP/IP</acronym> |
| 3120 |
network. <acronym>HAST</acronym> can be understood as a |
| 3121 |
network-based RAID1 (mirror), and is similar to the DRBD® |
| 3122 |
storage system used in the GNU/&linux; platform. In combination |
| 3123 |
with other high-availability features of &os; like |
| 3124 |
<acronym>CARP</acronym>, <acronym>HAST</acronym> makes it |
| 3125 |
possible to build a highly-available storage cluster that is |
| 3126 |
resistant to hardware failures.</para> |
| 3127 |
|
| 3128 |
<para>The following are the main features of |
| 3129 |
<acronym>HAST</acronym>:</para> |
| 3130 |
|
| 3131 |
<itemizedlist> |
| 3132 |
<listitem> |
| 3133 |
<para>Can be used to mask <acronym>I/O</acronym> errors on |
| 3134 |
local hard drives.</para> |
| 3135 |
</listitem> |
| 3136 |
|
| 3137 |
<listitem> |
| 3138 |
<para>File system agnostic as it works with any file system |
| 3139 |
supported by &os;.</para> |
| 3140 |
</listitem> |
| 3141 |
|
| 3142 |
<listitem> |
| 3143 |
<para>Efficient and quick resynchronization as only the blocks |
| 3144 |
that were modified during the downtime of a node are |
| 3145 |
synchronized.</para> |
| 3146 |
</listitem> |
| 3147 |
|
| 3148 |
<!-- |
| 3149 |
<listitem> |
| 3150 |
<para>Has several synchronization modes to allow for fast |
| 3151 |
failover.</para> |
| 3152 |
</listitem> |
| 3153 |
--> |
| 3154 |
|
| 3155 |
<listitem> |
| 3156 |
<para>Can be used in an already deployed environment to add |
| 3157 |
additional redundancy.</para> |
| 3158 |
</listitem> |
| 3159 |
|
| 3160 |
<listitem> |
| 3161 |
<para>Together with <acronym>CARP</acronym>, |
| 3162 |
<application>Heartbeat</application>, or other tools, it can |
| 3163 |
be used to build a robust and durable storage system.</para> |
| 3164 |
</listitem> |
| 3165 |
</itemizedlist> |
| 3166 |
|
| 3167 |
<para>After reading this section, you will know:</para> |
| 3168 |
|
| 3169 |
<itemizedlist> |
| 3170 |
<listitem> |
| 3171 |
<para>What <acronym>HAST</acronym> is, how it works, and |
| 3172 |
which features it provides.</para> |
| 3173 |
</listitem> |
| 3174 |
|
| 3175 |
<listitem> |
| 3176 |
<para>How to set up and use <acronym>HAST</acronym> on |
| 3177 |
&os;.</para> |
| 3178 |
</listitem> |
| 3179 |
|
| 3180 |
<listitem> |
| 3181 |
<para>How to integrate <acronym>CARP</acronym> and |
| 3182 |
&man.devd.8; to build a robust storage system.</para> |
| 3183 |
</listitem> |
| 3184 |
</itemizedlist> |
| 3185 |
|
| 3186 |
<para>Before reading this section, you should:</para> |
| 3187 |
|
| 3188 |
<itemizedlist> |
| 3189 |
<listitem> |
| 3190 |
<para>Understand &unix; and &os; basics (<xref |
| 3191 |
linkend="basics"/>).</para> |
| 3192 |
</listitem> |
| 3193 |
|
| 3194 |
<listitem> |
| 3195 |
<para>Know how to configure network |
| 3196 |
interfaces and other core &os; subsystems (<xref |
| 3197 |
linkend="config-tuning"/>).</para> |
| 3198 |
</listitem> |
| 3199 |
|
| 3200 |
<listitem> |
| 3201 |
<para>Have a good understanding of &os; |
| 3202 |
networking (<xref |
| 3203 |
linkend="network-communication"/>).</para> |
| 3204 |
</listitem> |
| 3205 |
</itemizedlist> |
| 3206 |
|
| 3207 |
<para>The <acronym>HAST</acronym> project was sponsored by The |
| 3208 |
&os; Foundation with support from <link |
| 3209 |
xlink:href="http://www.omc.net/">http://www.omc.net/</link> |
| 3210 |
and <link |
| 3211 |
xlink:href="http://www.transip.nl/">http://www.transip.nl/</link>.</para> |
| 3212 |
|
| 3213 |
<sect2> |
| 3214 |
<title>HAST Operation</title> |
| 3215 |
|
| 3216 |
<para><acronym>HAST</acronym> provides synchronous block-level |
| 3217 |
replication between two physical machines: the |
| 3218 |
<emphasis>primary</emphasis>, also known as the |
| 3219 |
<emphasis>master</emphasis> node, and the |
| 3220 |
<emphasis>secondary</emphasis>, or <emphasis>slave</emphasis> |
| 3221 |
node. These two machines together are referred to as a |
| 3222 |
cluster.</para> |
| 3223 |
|
| 3224 |
<para>Since <acronym>HAST</acronym> works in a primary-secondary |
| 3225 |
configuration, it allows only one of the cluster nodes to be |
| 3226 |
active at any given time. The primary node, also called |
| 3227 |
<emphasis>active</emphasis>, is the one which will handle all |
| 3228 |
the <acronym>I/O</acronym> requests to |
| 3229 |
<acronym>HAST</acronym>-managed devices. The secondary node |
| 3230 |
is automatically synchronized from the primary node.</para> |
| 3231 |
|
| 3232 |
<para>The physical components of the <acronym>HAST</acronym> |
| 3233 |
system are the local disk on primary node, and the disk on the |
| 3234 |
remote, secondary node.</para> |
| 3235 |
|
| 3236 |
<para><acronym>HAST</acronym> operates synchronously on a block |
| 3237 |
level, making it transparent to file systems and applications. |
| 3238 |
<acronym>HAST</acronym> provides regular GEOM providers in |
| 3239 |
<filename>/dev/hast/</filename> for use by other tools or |
| 3240 |
applications. There is no difference between using |
| 3241 |
<acronym>HAST</acronym>-provided devices and raw disks or |
| 3242 |
partitions.</para> |
| 3243 |
|
| 3244 |
<para>Each write, delete, or flush operation is sent to both the |
| 3245 |
local disk and to the remote disk over |
| 3246 |
<acronym>TCP/IP</acronym>. Each read operation is served from |
| 3247 |
the local disk, unless the local disk is not up-to-date or an |
| 3248 |
<acronym>I/O</acronym> error occurs. In such cases, the read |
| 3249 |
operation is sent to the secondary node.</para> |
| 3250 |
|
| 3251 |
<para><acronym>HAST</acronym> tries to provide fast failure |
| 3252 |
recovery. For this reason, it is important to reduce |
| 3253 |
synchronization time after a node's outage. To provide fast |
| 3254 |
synchronization, <acronym>HAST</acronym> manages an on-disk |
| 3255 |
bitmap of dirty extents and only synchronizes those during a |
| 3256 |
regular synchronization, with an exception of the initial |
| 3257 |
sync.</para> |
| 3258 |
|
| 3259 |
<para>There are many ways to handle synchronization. |
| 3260 |
<acronym>HAST</acronym> implements several replication modes |
| 3261 |
to handle different synchronization methods:</para> |
| 3262 |
|
| 3263 |
<itemizedlist> |
| 3264 |
<listitem> |
| 3265 |
<para><emphasis>memsync</emphasis>: This mode reports a |
| 3266 |
write operation as completed when the local write |
| 3267 |
operation is finished and when the remote node |
| 3268 |
acknowledges data arrival, but before actually storing the |
| 3269 |
data. The data on the remote node will be stored directly |
| 3270 |
after sending the acknowledgement. This mode is intended |
| 3271 |
to reduce latency, but still provides good reliability. |
| 3272 |
This mode is the default.</para> |
| 3273 |
</listitem> |
| 3274 |
|
| 3275 |
<listitem> |
| 3276 |
<para><emphasis>fullsync</emphasis>: This mode reports a |
| 3277 |
write operation as completed when both the local write and |
| 3278 |
the remote write complete. This is the safest and the |
| 3279 |
slowest replication mode.</para> |
| 3280 |
</listitem> |
| 3281 |
|
| 3282 |
<listitem> |
| 3283 |
<para><emphasis>async</emphasis>: This mode reports a write |
| 3284 |
operation as completed when the local write completes. |
| 3285 |
This is the fastest and the most dangerous replication |
| 3286 |
mode. It should only be used when replicating to a |
| 3287 |
distant node where latency is too high for other |
| 3288 |
modes.</para> |
| 3289 |
</listitem> |
| 3290 |
</itemizedlist> |
| 3291 |
</sect2> |
| 3292 |
|
| 3293 |
<sect2> |
| 3294 |
<title>HAST Configuration</title> |
| 3295 |
|
| 3296 |
<para>The <acronym>HAST</acronym> framework consists of several |
| 3297 |
components:</para> |
| 3298 |
|
| 3299 |
<itemizedlist> |
| 3300 |
<listitem> |
| 3301 |
<para>The &man.hastd.8; daemon which provides data |
| 3302 |
synchronization. When this daemon is started, it will |
| 3303 |
automatically load <varname>geom_gate.ko</varname>.</para> |
| 3304 |
</listitem> |
| 3305 |
|
| 3306 |
<listitem> |
| 3307 |
<para>The userland management utility, |
| 3308 |
&man.hastctl.8;.</para> |
| 3309 |
</listitem> |
| 3310 |
|
| 3311 |
<listitem> |
| 3312 |
<para>The &man.hast.conf.5; configuration file. This file |
| 3313 |
must exist before starting |
| 3314 |
<application>hastd</application>.</para> |
| 3315 |
</listitem> |
| 3316 |
</itemizedlist> |
| 3317 |
|
| 3318 |
<para>Users who prefer to statically build |
| 3319 |
<literal>GEOM_GATE</literal> support into the kernel should |
| 3320 |
add this line to the custom kernel configuration file, then |
| 3321 |
rebuild the kernel using the instructions in <xref |
| 3322 |
linkend="kernelconfig"/>:</para> |
| 3323 |
|
| 3324 |
<programlisting>options GEOM_GATE</programlisting> |
| 3325 |
|
| 3326 |
<para>The following example describes how to configure two nodes |
| 3327 |
in master-slave/primary-secondary operation using |
| 3328 |
<acronym>HAST</acronym> to replicate the data between the two. |
| 3329 |
The nodes will be called <literal>hasta</literal>, with an |
| 3330 |
<acronym>IP</acronym> address of |
| 3331 |
<literal>172.16.0.1</literal>, and <literal>hastb</literal>, |
| 3332 |
with an <acronym>IP</acronym> address of |
| 3333 |
<literal>172.16.0.2</literal>. Both nodes will have a |
| 3334 |
dedicated hard drive <filename>/dev/ad6</filename> of the same |
| 3335 |
size for <acronym>HAST</acronym> operation. The |
| 3336 |
<acronym>HAST</acronym> pool, sometimes referred to as a |
| 3337 |
resource or the <acronym>GEOM</acronym> provider in <filename |
| 3338 |
>/dev/hast/</filename>, will be called |
| 3339 |
<literal>test</literal>.</para> |
| 3340 |
|
| 3341 |
<para>Configuration of <acronym>HAST</acronym> is done using |
| 3342 |
<filename>/etc/hast.conf</filename>. This file should be |
| 3343 |
identical on both nodes. The simplest configuration |
| 3344 |
is:</para> |
| 3345 |
|
| 3346 |
<programlisting>resource <replaceable>test</replaceable> { |
| 3347 |
on <replaceable>hasta</replaceable> { |
| 3348 |
local <replaceable>/dev/ad6</replaceable> |
| 3349 |
remote <replaceable>172.16.0.2</replaceable> |
| 3350 |
} |
| 3351 |
on <replaceable>hastb</replaceable> { |
| 3352 |
local <replaceable>/dev/ad6</replaceable> |
| 3353 |
remote <replaceable>172.16.0.1</replaceable> |
| 3354 |
} |
| 3355 |
}</programlisting> |
| 3356 |
|
| 3357 |
<para>For more advanced configuration, refer to |
| 3358 |
&man.hast.conf.5;.</para> |
| 3359 |
|
| 3360 |
<tip> |
| 3361 |
<para>It is also possible to use host names in the |
| 3362 |
<literal>remote</literal> statements if the hosts are |
| 3363 |
resolvable and defined either in |
| 3364 |
<filename>/etc/hosts</filename> or in the local |
| 3365 |
<acronym>DNS</acronym>.</para> |
| 3366 |
</tip> |
| 3367 |
|
| 3368 |
<para>Once the configuration exists on both nodes, the |
| 3369 |
<acronym>HAST</acronym> pool can be created. Run these |
| 3370 |
commands on both nodes to place the initial metadata onto the |
| 3371 |
local disk and to start &man.hastd.8;:</para> |
| 3372 |
|
| 3373 |
<screen>&prompt.root; <userinput>hastctl create <replaceable>test</replaceable></userinput> |
| 3374 |
&prompt.root; <userinput>service hastd onestart</userinput></screen> |
| 3375 |
|
| 3376 |
<note> |
| 3377 |
<para>It is <emphasis>not</emphasis> possible to use |
| 3378 |
<acronym>GEOM</acronym> |
| 3379 |
providers with an existing file system or to convert an |
| 3380 |
existing storage to a <acronym>HAST</acronym>-managed pool. |
| 3381 |
This procedure needs to store some metadata on the provider |
| 3382 |
and there will not be enough required space available on an |
| 3383 |
existing provider.</para> |
| 3384 |
</note> |
| 3385 |
|
| 3386 |
<para>A HAST node's <literal>primary</literal> or |
| 3387 |
<literal>secondary</literal> role is selected by an |
| 3388 |
administrator, or software like |
| 3389 |
<application>Heartbeat</application>, using &man.hastctl.8;. |
| 3390 |
On the primary node, <literal>hasta</literal>, issue this |
| 3391 |
command:</para> |
| 3392 |
|
| 3393 |
<screen>&prompt.root; <userinput>hastctl role primary <replaceable>test</replaceable></userinput></screen> |
| 3394 |
|
| 3395 |
<para>Run this command on the secondary node, |
| 3396 |
<literal>hastb</literal>:</para> |
| 3397 |
|
| 3398 |
<screen>&prompt.root; <userinput>hastctl role secondary <replaceable>test</replaceable></userinput></screen> |
| 3399 |
|
| 3400 |
<para>Verify the result by running <command>hastctl</command> on |
| 3401 |
each node:</para> |
| 3402 |
|
| 3403 |
<screen>&prompt.root; <userinput>hastctl status <replaceable>test</replaceable></userinput></screen> |
| 3404 |
|
| 3405 |
<para>Check the <literal>status</literal> line in the output. |
| 3406 |
If it says <literal>degraded</literal>, something is wrong |
| 3407 |
with the configuration file. It should say |
| 3408 |
<literal>complete</literal> on each node, meaning that the |
| 3409 |
synchronization between the nodes has started. The |
| 3410 |
synchronization completes when <command>hastctl |
| 3411 |
status</command> reports 0 bytes of <literal>dirty</literal> |
| 3412 |
extents.</para> |
| 3413 |
|
| 3414 |
<para>The next step is to create a file system on the |
| 3415 |
<acronym>GEOM</acronym> provider and mount it. This must be |
| 3416 |
done on the <literal>primary</literal> node. Creating the |
| 3417 |
file system can take a few minutes, depending on the size of |
| 3418 |
the hard drive. This example creates a <acronym>UFS</acronym> |
| 3419 |
file system on <filename>/dev/hast/test</filename>:</para> |
| 3420 |
|
| 3421 |
<screen>&prompt.root; <userinput>newfs -U /dev/hast/<replaceable>test</replaceable></userinput> |
| 3422 |
&prompt.root; <userinput>mkdir /hast/<replaceable>test</replaceable></userinput> |
| 3423 |
&prompt.root; <userinput>mount /dev/hast/<replaceable>test</replaceable> <replaceable>/hast/test</replaceable></userinput></screen> |
| 3424 |
|
| 3425 |
<para>Once the <acronym>HAST</acronym> framework is configured |
| 3426 |
properly, the final step is to make sure that |
| 3427 |
<acronym>HAST</acronym> is started automatically during |
| 3428 |
system boot. Add this line to |
| 3429 |
<filename>/etc/rc.conf</filename>:</para> |
| 3430 |
|
| 3431 |
<programlisting>hastd_enable="YES"</programlisting> |
| 3432 |
|
| 3433 |
<sect3> |
| 3434 |
<title>Failover Configuration</title> |
| 3435 |
|
| 3436 |
<para>The goal of this example is to build a robust storage |
| 3437 |
system which is resistant to the failure of any given node. |
| 3438 |
If the primary node fails, the secondary node is there to |
| 3439 |
take over seamlessly, check and mount the file system, and |
| 3440 |
continue to work without missing a single bit of |
| 3441 |
data.</para> |
| 3442 |
|
| 3443 |
<para>To accomplish this task, the Common Address Redundancy |
| 3444 |
Protocol (<acronym>CARP</acronym>) is used to provide for |
| 3445 |
automatic failover at the <acronym>IP</acronym> layer. |
| 3446 |
<acronym>CARP</acronym> allows multiple hosts on the same |
| 3447 |
network segment to share an <acronym>IP</acronym> address. |
| 3448 |
Set up <acronym>CARP</acronym> on both nodes of the cluster |
| 3449 |
according to the documentation available in <xref |
| 3450 |
linkend="carp"/>. In this example, each node will have |
| 3451 |
its own management <acronym>IP</acronym> address and a |
| 3452 |
shared <acronym>IP</acronym> address of |
| 3453 |
<replaceable>172.16.0.254</replaceable>. The primary |
| 3454 |
<acronym>HAST</acronym> node of the cluster must be the |
| 3455 |
master <acronym>CARP</acronym> node.</para> |
| 3456 |
|
| 3457 |
<para>The <acronym>HAST</acronym> pool created in the previous |
| 3458 |
section is now ready to be exported to the other hosts on |
| 3459 |
the network. This can be accomplished by exporting it |
| 3460 |
through <acronym>NFS</acronym> or |
| 3461 |
<application>Samba</application>, using the shared |
| 3462 |
<acronym>IP</acronym> address |
| 3463 |
<replaceable>172.16.0.254</replaceable>. The only problem |
| 3464 |
which remains unresolved is an automatic failover should the |
| 3465 |
primary node fail.</para> |
| 3466 |
|
| 3467 |
<para>In the event of <acronym>CARP</acronym> interfaces going |
| 3468 |
up or down, the &os; operating system generates a |
| 3469 |
&man.devd.8; event, making it possible to watch for state |
| 3470 |
changes on the <acronym>CARP</acronym> interfaces. A state |
| 3471 |
change on the <acronym>CARP</acronym> interface is an |
| 3472 |
indication that one of the nodes failed or came back online. |
| 3473 |
These state change events make it possible to run a script |
| 3474 |
which will automatically handle the HAST failover.</para> |
| 3475 |
|
| 3476 |
<para>To catch state changes on the |
| 3477 |
<acronym>CARP</acronym> interfaces, add this configuration |
| 3478 |
to <filename>/etc/devd.conf</filename> on each node:</para> |
| 3479 |
|
| 3480 |
<programlisting>notify 30 { |
| 3481 |
match "system" "IFNET"; |
| 3482 |
match "subsystem" "carp0"; |
| 3483 |
match "type" "LINK_UP"; |
| 3484 |
action "/usr/local/sbin/carp-hast-switch master"; |
| 3485 |
}; |
| 3486 |
|
| 3487 |
notify 30 { |
| 3488 |
match "system" "IFNET"; |
| 3489 |
match "subsystem" "carp0"; |
| 3490 |
match "type" "LINK_DOWN"; |
| 3491 |
action "/usr/local/sbin/carp-hast-switch slave"; |
| 3492 |
};</programlisting> |
| 3493 |
|
| 3494 |
<note> |
| 3495 |
<para>If the systems are running &os; 10 or higher, |
| 3496 |
replace <filename>carp0</filename> with the name of the |
| 3497 |
<acronym>CARP</acronym>-configured interface.</para> |
| 3498 |
</note> |
| 3499 |
|
| 3500 |
<para>Restart &man.devd.8; on both nodes to put the new |
| 3501 |
configuration into effect:</para> |
| 3502 |
|
| 3503 |
<screen>&prompt.root; <userinput>service devd restart</userinput></screen> |
| 3504 |
|
| 3505 |
<para>When the specified interface state changes by going up |
| 3506 |
or down , the system generates a notification, allowing the |
| 3507 |
&man.devd.8; subsystem to run the specified automatic |
| 3508 |
failover script, |
| 3509 |
<filename>/usr/local/sbin/carp-hast-switch</filename>. |
| 3510 |
For further clarification about this configuration, refer to |
| 3511 |
&man.devd.conf.5;.</para> |
| 3512 |
|
| 3513 |
<para>Here is an example of an automated failover |
| 3514 |
script:</para> |
| 3515 |
|
| 3516 |
<programlisting>#!/bin/sh |
| 3517 |
|
| 3518 |
# Original script by Freddie Cash <fjwcash@gmail.com> |
| 3519 |
# Modified by Michael W. Lucas <mwlucas@BlackHelicopters.org> |
| 3520 |
# and Viktor Petersson <vpetersson@wireload.net> |
| 3521 |
|
| 3522 |
# The names of the HAST resources, as listed in /etc/hast.conf |
| 3523 |
resources="<replaceable>test</replaceable>" |
| 3524 |
|
| 3525 |
# delay in mounting HAST resource after becoming master |
| 3526 |
# make your best guess |
| 3527 |
delay=3 |
| 3528 |
|
| 3529 |
# logging |
| 3530 |
log="local0.debug" |
| 3531 |
name="carp-hast" |
| 3532 |
|
| 3533 |
# end of user configurable stuff |
| 3534 |
|
| 3535 |
case "$1" in |
| 3536 |
master) |
| 3537 |
logger -p $log -t $name "Switching to primary provider for ${resources}." |
| 3538 |
sleep ${delay} |
| 3539 |
|
| 3540 |
# Wait for any "hastd secondary" processes to stop |
| 3541 |
for disk in ${resources}; do |
| 3542 |
while $( pgrep -lf "hastd: ${disk} \(secondary\)" > /dev/null 2>&1 ); do |
| 3543 |
sleep 1 |
| 3544 |
done |
| 3545 |
|
| 3546 |
# Switch role for each disk |
| 3547 |
hastctl role primary ${disk} |
| 3548 |
if [ $? -ne 0 ]; then |
| 3549 |
logger -p $log -t $name "Unable to change role to primary for resource ${disk}." |
| 3550 |
exit 1 |
| 3551 |
fi |
| 3552 |
done |
| 3553 |
|
| 3554 |
# Wait for the /dev/hast/* devices to appear |
| 3555 |
for disk in ${resources}; do |
| 3556 |
for I in $( jot 60 ); do |
| 3557 |
[ -c "/dev/hast/${disk}" ] && break |
| 3558 |
sleep 0.5 |
| 3559 |
done |
| 3560 |
|
| 3561 |
if [ ! -c "/dev/hast/${disk}" ]; then |
| 3562 |
logger -p $log -t $name "GEOM provider /dev/hast/${disk} did not appear." |
| 3563 |
exit 1 |
| 3564 |
fi |
| 3565 |
done |
| 3566 |
|
| 3567 |
logger -p $log -t $name "Role for HAST resources ${resources} switched to primary." |
| 3568 |
|
| 3569 |
|
| 3570 |
logger -p $log -t $name "Mounting disks." |
| 3571 |
for disk in ${resources}; do |
| 3572 |
mkdir -p /hast/${disk} |
| 3573 |
fsck -p -y -t ufs /dev/hast/${disk} |
| 3574 |
mount /dev/hast/${disk} /hast/${disk} |
| 3575 |
done |
| 3576 |
|
| 3577 |
;; |
| 3578 |
|
| 3579 |
slave) |
| 3580 |
logger -p $log -t $name "Switching to secondary provider for ${resources}." |
| 3581 |
|
| 3582 |
# Switch roles for the HAST resources |
| 3583 |
for disk in ${resources}; do |
| 3584 |
if ! mount | grep -q "^/dev/hast/${disk} on " |
| 3585 |
then |
| 3586 |
else |
| 3587 |
umount -f /hast/${disk} |
| 3588 |
fi |
| 3589 |
sleep $delay |
| 3590 |
hastctl role secondary ${disk} 2>&1 |
| 3591 |
if [ $? -ne 0 ]; then |
| 3592 |
logger -p $log -t $name "Unable to switch role to secondary for resource ${disk}." |
| 3593 |
exit 1 |
| 3594 |
fi |
| 3595 |
logger -p $log -t $name "Role switched to secondary for resource ${disk}." |
| 3596 |
done |
| 3597 |
;; |
| 3598 |
esac</programlisting> |
| 3599 |
|
| 3600 |
<para>In a nutshell, the script takes these actions when a |
| 3601 |
node becomes master:</para> |
| 3602 |
|
| 3603 |
<itemizedlist> |
| 3604 |
<listitem> |
| 3605 |
<para>Promotes the <acronym>HAST</acronym> pool to |
| 3606 |
primary on the other node.</para> |
| 3607 |
</listitem> |
| 3608 |
|
| 3609 |
<listitem> |
| 3610 |
<para>Checks the file system under the |
| 3611 |
<acronym>HAST</acronym> pool.</para> |
| 3612 |
</listitem> |
| 3613 |
|
| 3614 |
<listitem> |
| 3615 |
<para>Mounts the pool.</para> |
| 3616 |
</listitem> |
| 3617 |
</itemizedlist> |
| 3618 |
|
| 3619 |
<para>When a node becomes secondary:</para> |
| 3620 |
|
| 3621 |
<itemizedlist> |
| 3622 |
<listitem> |
| 3623 |
<para>Unmounts the <acronym>HAST</acronym> pool.</para> |
| 3624 |
</listitem> |
| 3625 |
|
| 3626 |
<listitem> |
| 3627 |
<para>Degrades the <acronym>HAST</acronym> pool to |
| 3628 |
secondary.</para> |
| 3629 |
</listitem> |
| 3630 |
</itemizedlist> |
| 3631 |
|
| 3632 |
<caution> |
| 3633 |
<para>This is just an example script which serves as a proof |
| 3634 |
of concept. It does not handle all the possible scenarios |
| 3635 |
and can be extended or altered in any way, for example, to |
| 3636 |
start or stop required services.</para> |
| 3637 |
</caution> |
| 3638 |
|
| 3639 |
<tip> |
| 3640 |
<para>For this example, a standard <acronym>UFS</acronym> |
| 3641 |
file system was used. To reduce the time needed for |
| 3642 |
recovery, a journal-enabled <acronym>UFS</acronym> or |
| 3643 |
<acronym>ZFS</acronym> file system can be used |
| 3644 |
instead.</para> |
| 3645 |
</tip> |
| 3646 |
|
| 3647 |
<para>More detailed information with additional examples can |
| 3648 |
be found at <link |
| 3649 |
xlink:href="http://wiki.FreeBSD.org/HAST">http://wiki.FreeBSD.org/HAST</link>.</para> |
| 3650 |
</sect3> |
| 3651 |
</sect2> |
| 3652 |
|
| 3653 |
<sect2> |
| 3654 |
<title>Troubleshooting</title> |
| 3655 |
|
| 3656 |
<para><acronym>HAST</acronym> should generally work without |
| 3657 |
issues. However, as with any other software product, there |
| 3658 |
may be times when it does not work as supposed. The sources |
| 3659 |
of the problems may be different, but the rule of thumb is to |
| 3660 |
ensure that the time is synchronized between the nodes of the |
| 3661 |
cluster.</para> |
| 3662 |
|
| 3663 |
<para>When troubleshooting <acronym>HAST</acronym>, the |
| 3664 |
debugging level of &man.hastd.8; should be increased by |
| 3665 |
starting <command>hastd</command> with <literal>-d</literal>. |
| 3666 |
This argument may be specified multiple times to further |
| 3667 |
increase the debugging level. Consider also using |
| 3668 |
<literal>-F</literal>, which starts <command>hastd</command> |
| 3669 |
in the foreground.</para> |
| 3670 |
|
| 3671 |
<sect3 xml:id="disks-hast-sb"> |
| 3672 |
<title>Recovering from the Split-brain Condition</title> |
| 3673 |
|
| 3674 |
<para><firstterm>Split-brain</firstterm> occurs when the nodes |
| 3675 |
of the cluster are unable to communicate with each other, |
| 3676 |
and both are configured as primary. This is a dangerous |
| 3677 |
condition because it allows both nodes to make incompatible |
| 3678 |
changes to the data. This problem must be corrected |
| 3679 |
manually by the system administrator.</para> |
| 3680 |
|
| 3681 |
<para>The administrator must either decide which node has more |
| 3682 |
important changes, or perform the merge manually. Then, let |
| 3683 |
<acronym>HAST</acronym> perform full synchronization of the |
| 3684 |
node which has the broken data. To do this, issue these |
| 3685 |
commands on the node which needs to be |
| 3686 |
resynchronized:</para> |
| 3687 |
|
| 3688 |
<screen>&prompt.root; <userinput>hastctl role init <replaceable>test</replaceable></userinput> |
| 3689 |
&prompt.root; <userinput>hastctl create <replaceable>test</replaceable></userinput> |
| 3690 |
&prompt.root; <userinput>hastctl role secondary <replaceable>test</replaceable></userinput></screen> |
| 3691 |
</sect3> |
| 3692 |
</sect2> |
| 3693 |
</sect1> |
| 3694 |
</chapter> |