Use correct syntax markup for shell

Approved by:	carlavilla
This commit is contained in:
Li-Wen Hsu 2021-03-14 20:08:55 +08:00
parent 55c95407aa
commit a9a9e66105
No known key found for this signature in database
GPG key ID: 8D7BCC7D012FD37E
666 changed files with 17924 additions and 17924 deletions

View file

@ -79,7 +79,7 @@ If the disk to be added is not blank, old partition information can be removed w
The partition scheme is created, and then a single partition is added. To improve performance on newer disks with larger hardware block sizes, the partition is aligned to one megabyte boundaries:
[source,bash]
[source,shell]
....
# gpart create -s GPT ada1
# gpart add -t freebsd-ufs -a 1M ada1
@ -89,7 +89,7 @@ Depending on use, several smaller partitions may be desired. See man:gpart[8] fo
The disk partition information can be viewed with `gpart show`:
[source,bash]
[source,shell]
....
% gpart show ada1
=> 34 1465146988 ada1 GPT (699G)
@ -100,14 +100,14 @@ The disk partition information can be viewed with `gpart show`:
A file system is created in the new partition on the new disk:
[source,bash]
[source,shell]
....
# newfs -U /dev/ada1p1
....
An empty directory is created as a _mountpoint_, a location for mounting the new disk in the original disk's file system:
[source,bash]
[source,shell]
....
# mkdir /newdisk
....
@ -121,7 +121,7 @@ Finally, an entry is added to [.filename]#/etc/fstab# so the new disk will be mo
The new disk can be mounted manually, without restarting the system:
[source,bash]
[source,shell]
....
# mount /newdisk
....
@ -135,7 +135,7 @@ Determine the device name of the disk to be resized by inspecting [.filename]#/v
List the partitions on the disk to see the current configuration:
[source,bash]
[source,shell]
....
# gpart show ada0
=> 34 83886013 ada0 GPT (48G) [CORRUPT]
@ -149,7 +149,7 @@ List the partitions on the disk to see the current configuration:
====
If the disk was formatted with the http://en.wikipedia.org/wiki/GUID_Partition_Table[GPT] partitioning scheme, it may show as "corrupted" because the GPT backup partition table is no longer at the end of the drive. Fix the backup partition table with `gpart`:
[source,bash]
[source,shell]
....
# gpart recover ada0
ada0 recovered
@ -159,7 +159,7 @@ ada0 recovered
Now the additional space on the disk is available for use by a new partition, or an existing partition can be expanded:
[source,bash]
[source,shell]
....
# gpart show ada0
=> 34 102399933 ada0 GPT (48G)
@ -173,14 +173,14 @@ Partitions can only be resized into contiguous free space. Here, the last partit
Disable the swap partition:
[source,bash]
[source,shell]
....
# swapoff /dev/ada0p3
....
Delete the third partition, specified by the `-i` flag, from the disk _ada0_.
[source,bash]
[source,shell]
....
# gpart delete -i 3 ada0
ada0p3 deleted
@ -196,7 +196,7 @@ ada0p3 deleted
There is risk of data loss when modifying the partition table of a mounted file system. It is best to perform the following steps on an unmounted file system while running from a live CD-ROM or USB device. However, if absolutely necessary, a mounted file system can be resized after disabling GEOM safety features:
[source,bash]
[source,shell]
....
# sysctl kern.geom.debugflags=16
....
@ -205,7 +205,7 @@ There is risk of data loss when modifying the partition table of a mounted file
Resize the partition, leaving room to recreate a swap partition of the desired size. The partition to resize is specified with `-i`, and the new desired size with `-s`. Optionally, alignment of the partition is controlled with `-a`. This only modifies the size of the partition. The file system in the partition will be expanded in a separate step.
[source,bash]
[source,shell]
....
# gpart resize -i 2 -s 47G -a 4k ada0
ada0p2 resized
@ -218,7 +218,7 @@ ada0p2 resized
Recreate the swap partition and activate it. If no size is specified with `-s`, all remaining space is used:
[source,bash]
[source,shell]
....
# gpart add -t freebsd-swap -a 4k ada0
ada0p3 added
@ -232,7 +232,7 @@ ada0p3 added
Grow the UFS file system to use the new capacity of the resized partition:
[source,bash]
[source,shell]
....
# growfs /dev/ada0p2
Device is mounted read-write; resizing will result in temporary write suspension for /.
@ -245,7 +245,7 @@ super-block backups (for fsck -b #) at:
If the file system is ZFS, the resize is triggered by running the `online` subcommand with `-e`:
[source,bash]
[source,shell]
....
# zpool online -e zroot /dev/ada0p2
....
@ -286,7 +286,7 @@ The rest of this section demonstrates how to verify that a USB storage device is
To test the USB configuration, plug in the USB device. Use `dmesg` to confirm that the drive appears in the system message buffer. It should look something like this:
[source,bash]
[source,shell]
....
umass0: <STECH Simple Drive, class 0/0, rev 2.00/1.04, addr 3> on usbus0
umass0: SCSI over Bulk-Only; quirks = 0x0100
@ -303,7 +303,7 @@ The brand, device node ([.filename]#da0#), speed, and size will differ according
Since the USB device is seen as a SCSI one, `camcontrol` can be used to list the USB storage devices attached to the system:
[source,bash]
[source,shell]
....
# camcontrol devlist
<STECH Simple Drive 1.04> at scbus4 target 0 lun 0 (pass3,da0)
@ -311,7 +311,7 @@ Since the USB device is seen as a SCSI one, `camcontrol` can be used to list the
Alternately, `usbconfig` can be used to list the device. Refer to man:usbconfig[8] for more information about this command.
[source,bash]
[source,shell]
....
# usbconfig
ugen0.3: <Simple Drive STECH> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)
@ -361,7 +361,7 @@ vfs.usermount=1
Since this only takes effect after the next reboot, use `sysctl` to set this variable now:
[source,bash]
[source,shell]
....
# sysctl vfs.usermount=1
vfs.usermount: 0 -> 1
@ -369,7 +369,7 @@ vfs.usermount: 0 -> 1
The final step is to create a directory where the file system is to be mounted. This directory needs to be owned by the user that is to mount the file system. One way to do that is for `root` to create a subdirectory owned by that user as [.filename]#/mnt/username#. In the following example, replace _username_ with the login name of the user and _usergroup_ with the user's primary group:
[source,bash]
[source,shell]
....
# mkdir /mnt/username
# chown username:usergroup /mnt/username
@ -377,21 +377,21 @@ The final step is to create a directory where the file system is to be mounted.
Suppose a USB thumbdrive is plugged in, and a device [.filename]#/dev/da0s1# appears. If the device is formatted with a FAT file system, the user can mount it using:
[source,bash]
[source,shell]
....
% mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/username
....
Before the device can be unplugged, it _must_ be unmounted first:
[source,bash]
[source,shell]
....
% umount /mnt/username
....
After device removal, the system message buffer will show messages similar to the following:
[source,bash]
[source,shell]
....
umass0: at uhub3, port 2, addr 3 (disconnected)
da0 at umass-sim0 bus 0 scbus4 target 0 lun 0
@ -403,14 +403,14 @@ da0: <STECH Simple Drive 1.04> s/n WD-WXE508CAN263 detached
USB devices can be automatically mounted by uncommenting this line in [.filename]#/etc/auto_master#:
[source,bash]
[source,shell]
....
/media -media -nosuid
....
Then add these lines to [.filename]#/etc/devd.conf#:
[source,bash]
[source,shell]
....
notify 100 {
match "system" "GEOM";
@ -421,7 +421,7 @@ notify 100 {
Reload the configuration if man:autofs[5] and man:devd[8] are already running:
[source,bash]
[source,shell]
....
# service automount restart
# service devd restart
@ -438,7 +438,7 @@ man:autofs[5] requires man:devd[8] to be enabled, as it is by default.
Start the services immediately with:
[source,bash]
[source,shell]
....
# service automount start
# service automountd start
@ -450,7 +450,7 @@ Each file system that can be automatically mounted appears as a directory in [.f
The file system is transparently mounted on the first access, and unmounted after a period of inactivity. Automounted drives can also be unmounted manually:
[source,bash]
[source,shell]
....
# automount -fu
....
@ -526,7 +526,7 @@ This will require a reboot of the system as this driver can only be loaded at bo
To verify that FreeBSD recognizes the device, run `dmesg` and look for an entry for the device. On systems prior to 10.x, the device name in the first line of the output will be [.filename]#acd0# instead of [.filename]#cd0#.
[source,bash]
[source,shell]
....
% dmesg | grep cd
cd0 at ahcich1 bus 0 scbus1 target 0 lun 0
@ -543,14 +543,14 @@ In FreeBSD, `cdrecord` can be used to burn CDs. This command is installed with t
While `cdrecord` has many options, basic usage is simple. Specify the name of the ISO file to burn and, if the system has multiple burner devices, specify the name of the device to use:
[source,bash]
[source,shell]
....
# cdrecord dev=device imagefile.iso
....
To determine the device name of the burner, use `-scanbus` which might produce results like this:
[source,bash]
[source,shell]
....
# cdrecord -scanbus
ProDVD-ProBD-Clone 3.00 (amd64-unknown-freebsd10.0) Copyright (C) 1995-2010 Jörg Schilling
@ -579,7 +579,7 @@ Locate the entry for the CD burner and use the three numbers separated by commas
Alternately, run the following command to get the device address of the burner:
[source,bash]
[source,shell]
....
# camcontrol devlist
<MATSHITA CDRW/DVD UJDA740 1.00> at scbus1 target 0 lun 0 (cd0,pass0)
@ -592,7 +592,7 @@ Use the numeric values for `scbus`, `target`, and `lun`. For this example, `1,0,
In order to produce a data CD, the data files that are going to make up the tracks on the CD must be prepared before they can be burned to the CD. In FreeBSD, package:sysutils/cdrtools[] installs `mkisofs`, which can be used to produce an ISO 9660 file system that is an image of a directory tree within a UNIX(R) file system. The simplest usage is to specify the name of the ISO file to create and the path to the files to place into the ISO 9660 file system:
[source,bash]
[source,shell]
....
# mkisofs -o imagefile.iso /path/to/tree
....
@ -605,14 +605,14 @@ For CDs that are going to be used only on FreeBSD systems, `-U` can be used to d
The last option of general use is `-b`. This is used to specify the location of a boot image for use in producing an "El Torito" bootable CD. This option takes an argument which is the path to a boot image from the top of the tree being written to the CD. By default, `mkisofs` creates an ISO image in "floppy disk emulation" mode, and thus expects the boot image to be exactly 1200, 1440 or 2880 KB in size. Some boot loaders, like the one used by the FreeBSD distribution media, do not use emulation mode. In this case, `-no-emul-boot` should be used. So, if [.filename]#/tmp/myboot# holds a bootable FreeBSD system with the boot image in [.filename]#/tmp/myboot/boot/cdboot#, this command would produce [.filename]#/tmp/bootable.iso#:
[source,bash]
[source,shell]
....
# mkisofs -R -no-emul-boot -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot
....
The resulting ISO image can be mounted as a memory disk with:
[source,bash]
[source,shell]
....
# mdconfig -a -t vnode -f /tmp/bootable.iso -u 0
# mount -t cd9660 /dev/md0 /mnt
@ -626,7 +626,7 @@ There are many other options available for `mkisofs` to fine-tune its behavior.
====
It is possible to copy a data CD to an image file that is functionally equivalent to the image file created with `mkisofs`. To do so, use [.filename]#dd# with the device name as the input file and the name of the ISO to create as the output file:
[source,bash]
[source,shell]
....
# dd if=/dev/cd0 of=file.iso bs=2048
....
@ -639,7 +639,7 @@ The resulting image file can be burned to CD as described in <<cdrecord>>.
Once an ISO has been burned to a CD, it can be mounted by specifying the file system type, the name of the device containing the CD, and an existing mount point:
[source,bash]
[source,shell]
....
# mount -t cd9660 /dev/cd0 /mnt
....
@ -677,7 +677,7 @@ It is possible to burn a file directly to CD, without creating an ISO 9660 file
This type of disk can not be mounted as a normal data CD. In order to retrieve the data burned to such a CD, the data must be read from the raw device node. For example, this command will extract a compressed tar file located on the second CD device into the current working directory:
[source,bash]
[source,shell]
....
# tar xzvf /dev/cd1
....
@ -697,7 +697,7 @@ To duplicate an audio CD, extract the audio data from the CD to a series of file
. The package:sysutils/cdrtools[] package or port installs `cdda2wav`. This command can be used to extract all of the audio tracks, with each track written to a separate WAV file in the current working directory:
+
[source,bash]
[source,shell]
....
% cdda2wav -vall -B -Owav
....
@ -707,7 +707,7 @@ A device name does not need to be specified if there is only one CD device on th
. Use `cdrecord` to write the [.filename]#.wav# files:
+
[source,bash]
[source,shell]
....
% cdrecord -v dev=2,0 -dao -useinfo *.wav
....
@ -761,7 +761,7 @@ Since man:growisofs[1] is a front-end to <<mkisofs,mkisofs>>, it will invoke man
To burn to a DVD+R or a DVD-R the data in [.filename]#/path/to/data#, use the following command:
[source,bash]
[source,shell]
....
# growisofs -dvd-compat -Z /dev/cd0 -J -R /path/to/data
....
@ -772,7 +772,7 @@ For the initial session recording, `-Z` is used for both single and multiple ses
To burn a pre-mastered image, such as _imagefile.iso_, use:
[source,bash]
[source,shell]
....
# growisofs -dvd-compat -Z /dev/cd0=imagefile.iso
....
@ -785,14 +785,14 @@ In order to support working files larger than 4.38GB, an UDF/ISO-9660 hybrid fil
To create this type of ISO file:
[source,bash]
[source,shell]
....
% mkisofs -R -J -udf -iso-level 3 -o imagefile.iso /path/to/data
....
To burn files directly to a disk:
[source,bash]
[source,shell]
....
# growisofs -dvd-compat -udf -iso-level 3 -Z /dev/cd0 -J -R /path/to/data
....
@ -808,7 +808,7 @@ A DVD-Video is a specific file layout based on the ISO 9660 and micro-UDF (M-UDF
If an image of the DVD-Video file system already exists, it can be burned in the same way as any other image. If `dvdauthor` was used to make the DVD and the result is in [.filename]#/path/to/video#, the following command should be used to burn the DVD-Video:
[source,bash]
[source,shell]
....
# growisofs -Z /dev/cd0 -dvd-video /path/to/video
....
@ -819,7 +819,7 @@ If an image of the DVD-Video file system already exists, it can be burned in the
Unlike CD-RW, a virgin DVD+RW needs to be formatted before first use. It is _recommended_ to let man:growisofs[1] take care of this automatically whenever appropriate. However, it is possible to use `dvd+rw-format` to format the DVD+RW:
[source,bash]
[source,shell]
....
# dvd+rw-format /dev/cd0
....
@ -828,7 +828,7 @@ Only perform this operation once and keep in mind that only virgin DVD+RW medias
To burn a totally new file system and not just append some data onto a DVD+RW, the media does not need to be blanked first. Instead, write over the previous recording like this:
[source,bash]
[source,shell]
....
# growisofs -Z /dev/cd0 -J -R /path/to/newdata
....
@ -837,7 +837,7 @@ The DVD+RW format supports appending data to a previous recording. This operatio
For example, to append data to a DVD+RW, use the following:
[source,bash]
[source,shell]
....
# growisofs -M /dev/cd0 -J -R /path/to/nextdata
....
@ -851,7 +851,7 @@ Use `-dvd-compat` for better media compatibility with DVD-ROM drives. When using
To blank the media, use:
[source,bash]
[source,shell]
....
# growisofs -Z /dev/cd0=/dev/zero
....
@ -864,7 +864,7 @@ A virgin DVD-RW can be directly written without being formatted. However, a non-
To blank a DVD-RW in sequential mode:
[source,bash]
[source,shell]
....
# dvd+rw-format -blank=full /dev/cd0
....
@ -873,7 +873,7 @@ To blank a DVD-RW in sequential mode:
====
A full blanking using `-blank=full` will take about one hour on a 1x media. A fast blanking can be performed using `-blank`, if the DVD-RW will be recorded in Disk-At-Once (DAO) mode. To burn the DVD-RW in DAO mode, use the command:
[source,bash]
[source,shell]
....
# growisofs -use-the-force-luke=dao -Z /dev/cd0=imagefile.iso
....
@ -885,7 +885,7 @@ One should instead use restricted overwrite mode with any DVD-RW as this format
To write data on a sequential DVD-RW, use the same instructions as for the other DVD formats:
[source,bash]
[source,shell]
....
# growisofs -Z /dev/cd0 -J -R /path/to/data
....
@ -896,14 +896,14 @@ A DVD-RW in restricted overwrite format does not need to be blanked before a new
To put a DVD-RW in restricted overwrite format, the following command must be used:
[source,bash]
[source,shell]
....
# dvd+rw-format /dev/cd0
....
To change back to sequential format, use:
[source,bash]
[source,shell]
....
# dvd+rw-format -blank=full /dev/cd0
....
@ -914,7 +914,7 @@ Few DVD-ROM drives support multi-session DVDs and most of the time only read the
Using the following command after an initial non-closed session on a DVD+R, DVD-R, or DVD-RW in sequential format, will add a new session to the disc:
[source,bash]
[source,shell]
....
# growisofs -M /dev/cd0 -J -R /path/to/nextdata
....
@ -949,7 +949,7 @@ hw.ata.atapi_dma="1"
A DVD-RAM can be seen as a removable hard drive. Like any other hard drive, the DVD-RAM must be formatted before it can be used. In this example, the whole disk space will be formatted with a standard UFS2 file system:
[source,bash]
[source,shell]
....
# dd if=/dev/zero of=/dev/acd0 bs=2k count=1
# bsdlabel -Bw acd0
@ -960,7 +960,7 @@ The DVD device, [.filename]#acd0#, must be changed according to the configuratio
Once the DVD-RAM has been formatted, it can be mounted as a normal hard drive:
[source,bash]
[source,shell]
....
# mount /dev/acd0 /mnt
....
@ -980,7 +980,7 @@ A floppy disk needs to be low-level formatted before it can be used. This is usu
. To format the floppy, insert a new 3.5 inch floppy disk into the first floppy drive and issue:
+
[source,bash]
[source,shell]
....
# /usr/sbin/fdformat -f 1440 /dev/fd0
....
@ -989,7 +989,7 @@ A floppy disk needs to be low-level formatted before it can be used. This is usu
+
To write the disk label, use man:bsdlabel[8]:
+
[source,bash]
[source,shell]
....
# /sbin/bsdlabel -B -w /dev/fd0 fd1440
....
@ -998,7 +998,7 @@ To write the disk label, use man:bsdlabel[8]:
+
To format the floppy with FAT, issue:
+
[source,bash]
[source,shell]
....
# /sbin/newfs_msdos /dev/fd0
....
@ -1024,14 +1024,14 @@ interact with the man:fusefs[5] kernel module via a well defined interface.
. Before using a FUSE file system we need to load the man:fusefs[5] kernel
module:
+
[source,bash]
[source,shell]
....
# kldload fusefs
....
+
Use man:sysrc[8] to load the module at startup:
+
[source,bash]
[source,shell]
....
# sysrc kld_list+=fusefs
....
@ -1040,14 +1040,14 @@ Use man:sysrc[8] to load the module at startup:
crossref:ports[pkgng-intro,Using pkg for Binary Package Management]) or from
ports (see crossref:ports[ports-using,Using the Ports Collection]):
+
[source,bash]
[source,shell]
....
# pkg install fusefs-ntfs
....
. Last we need to create a directory where the file system will be mounted:
+
[source,bash]
[source,shell]
....
# mkdir /mnt/usb
....
@ -1055,7 +1055,7 @@ ports (see crossref:ports[ports-using,Using the Ports Collection]):
. Suppose a USB disk is plugged in. The disk partition information can be
viewed with man:gpart[8]:
+
[source,bash]
[source,shell]
....
# gpart show da0
=> 63 1953525105 da0 MBR (932G)
@ -1064,7 +1064,7 @@ viewed with man:gpart[8]:
. We can mount the disk using the following command:
+
[source,bash]
[source,shell]
....
# ntfs-3g /dev/da0s1 /mnt/usb/
....
@ -1079,14 +1079,14 @@ The disk is now ready to use.
+
Now the disk can be now mounted with:
+
[source,bash]
[source,shell]
....
# mount /mnt/usb
....
. The disk can be unmounted with:
+
[source,bash]
[source,shell]
....
# umount /mnt/usb/
....
@ -1128,7 +1128,7 @@ Instead, one can use `dump` and `restore` in a more secure fashion over an SSH c
.Using `dump` over ssh
[example]
====
[source,bash]
[source,shell]
....
# /sbin/dump -0uan -f - /usr | gzip -2 | ssh -c blowfish \
targetuser@targetmachine.example.com dd of=/mybigfiles/dump-usr-l0.gz
@ -1140,7 +1140,7 @@ This example sets `RSH` in order to write the backup to a tape drive on a remote
.Using `dump` over ssh with `RSH` Set
[example]
====
[source,bash]
[source,shell]
....
# env RSH=/usr/bin/ssh /sbin/dump -0uan -f targetuser@targetmachine.example.com:/dev/sa0 /usr
....
@ -1157,7 +1157,7 @@ This example creates a compressed backup of the current directory and saves it t
.Backing Up the Current Directory with `tar`
[example]
====
[source,bash]
[source,shell]
....
# tar czvf /tmp/mybackup.tgz .
....
@ -1168,7 +1168,7 @@ To restore the entire backup, `cd` into the directory to restore into and specif
.Restoring Up the Current Directory with `tar`
[example]
====
[source,bash]
[source,shell]
....
# tar xzvf /tmp/mybackup.tgz
....
@ -1183,7 +1183,7 @@ For example, a list of files can be created using `ls` or `find`. This example c
.Using `ls` and `cpio` to Make a Recursive Backup of the Current Directory
[example]
====
[source,bash]
[source,shell]
....
# ls -R | cpio -ovF /tmp/mybackup.cpio
....
@ -1196,7 +1196,7 @@ The `pax` equivalent to the previous examples would be:
.Backing Up the Current Directory with `pax`
[example]
====
[source,bash]
[source,shell]
....
# pax -wf /tmp/mybackup.pax .
....
@ -1211,7 +1211,7 @@ For SCSI tape devices, FreeBSD uses the man:sa[4] driver and the [.filename]#/de
In FreeBSD, `mt` is used to control operations of the tape drive, such as seeking through files on a tape or writing tape control marks to the tape. For example, the first three files on a tape can be preserved by skipping past them before writing a new file:
[source,bash]
[source,shell]
....
# mt -f /dev/nsa0 fsf 3
....
@ -1220,28 +1220,28 @@ This utility supports many operations. Refer to man:mt[1] for details.
To write a single file to tape using `tar`, specify the name of the tape device and the file to backup:
[source,bash]
[source,shell]
....
# tar cvf /dev/sa0 file
....
To recover files from a `tar` archive on tape into the current directory:
[source,bash]
[source,shell]
....
# tar xvf /dev/sa0
....
To backup a UFS file system, use `dump`. This examples backs up [.filename]#/usr# without rewinding the tape when finished:
[source,bash]
[source,shell]
....
# dump -0aL -b64 -f /dev/nsa0 /usr
....
To interactively restore files from a `dump` file on tape into the current directory:
[source,bash]
[source,shell]
....
# restore -i -f /dev/nsa0
....
@ -1291,7 +1291,7 @@ device md
To mount an existing file system image, use `mdconfig` to specify the name of the ISO file and a free unit number. Then, refer to that unit number to mount it on an existing mount point. Once mounted, the files in the ISO will appear in the mount point. This example attaches _diskimage.iso_ to the memory device [.filename]#/dev/md0# then mounts that memory device on [.filename]#/mnt#:
[source,bash]
[source,shell]
....
# mdconfig -f diskimage.iso -u 0
# mount -t cd9660 /dev/md0 /mnt
@ -1301,7 +1301,7 @@ Notice that `-t cd9660` was used to mount an ISO format. If a unit number is not
When a memory disk is no longer in use, its resources should be released back to the system. First, unmount the file system, then use `mdconfig` to detach the disk from the system and release its resources. To continue this example:
[source,bash]
[source,shell]
....
# umount /mnt
# mdconfig -d -u 0
@ -1316,7 +1316,7 @@ FreeBSD also supports memory disks where the storage to use is allocated from ei
To create a new memory-backed file system, specify a type of `swap` and the size of the memory disk to create. Then, format the memory disk with a file system and mount as usual. This example creates a 5M memory disk on unit `1`. That memory disk is then formatted with the UFS file system before it is mounted:
[source,bash]
[source,shell]
....
# mdconfig -a -t swap -s 5m -u 1
# newfs -U md1
@ -1333,7 +1333,7 @@ Filesystem 1K-blocks Used Avail Capacity Mounted on
To create a new file-backed memory disk, first allocate an area of disk to use. This example creates an empty 5MB file named [.filename]#newimage#:
[source,bash]
[source,shell]
....
# dd if=/dev/zero of=newimage bs=1k count=5k
5120+0 records in
@ -1342,7 +1342,7 @@ To create a new file-backed memory disk, first allocate an area of disk to use.
Next, attach that file to a memory disk, label the memory disk and format it with the UFS file system, mount the memory disk, and verify the size of the file-backed disk:
[source,bash]
[source,shell]
....
# mdconfig -f newimage -u 0
# bsdlabel -w md0 auto
@ -1359,14 +1359,14 @@ Filesystem 1K-blocks Used Avail Capacity Mounted on
It takes several commands to create a file- or memory-backed file system using `mdconfig`. FreeBSD also comes with `mdmfs` which automatically configures a memory disk, formats it with the UFS file system, and mounts it. For example, after creating _newimage_ with `dd`, this one command is equivalent to running the `bsdlabel`, `newfs`, and `mount` commands shown above:
[source,bash]
[source,shell]
....
# mdmfs -F newimage -s 5m md0 /mnt
....
To instead create a new memory-based memory disk with `mdmfs`, use this one command:
[source,bash]
[source,shell]
....
# mdmfs -s 5m md1 /mnt
....
@ -1384,21 +1384,21 @@ The un-alterable `snapshot` file flag is set by man:mksnap_ffs[8] after initial
Snapshots are created using man:mount[8]. To place a snapshot of [.filename]#/var# in the file [.filename]#/var/snapshot/snap#, use the following command:
[source,bash]
[source,shell]
....
# mount -u -o snapshot /var/snapshot/snap /var
....
Alternatively, use man:mksnap_ffs[8] to create the snapshot:
[source,bash]
[source,shell]
....
# mksnap_ffs /var /var/snapshot/snap
....
One can find snapshot files on a file system, such as [.filename]#/var#, using man:find[1]:
[source,bash]
[source,shell]
....
# find /var -flags snapshot
....
@ -1411,7 +1411,7 @@ Once a snapshot has been created, it has several uses:
* The snapshot can be mounted as a frozen image of the file system. To man:mount[8] the snapshot [.filename]#/var/snapshot/snap# run:
+
[source,bash]
[source,shell]
....
# mdconfig -a -t vnode -o readonly -f /var/snapshot/snap -u 4
# mount -r /dev/md4 /mnt
@ -1419,7 +1419,7 @@ Once a snapshot has been created, it has several uses:
The frozen [.filename]#/var# is now available through [.filename]#/mnt#. Everything will initially be in the same state it was during the snapshot creation time. The only exception is that any earlier snapshots will appear as zero length files. To unmount the snapshot, use:
[source,bash]
[source,shell]
....
# umount /mnt
# mdconfig -d -u 4
@ -1438,7 +1438,7 @@ This section describes how to configure disk quotas for the UFS file system. To
To determine if the FreeBSD kernel provides support for disk quotas:
[source,bash]
[source,shell]
....
% sysctl kern.features.ufs_quota
kern.features.ufs_quota: 1
@ -1489,7 +1489,7 @@ In the normal course of operations, there should be no need to manually run man:
To verify that quotas are enabled, run:
[source,bash]
[source,shell]
....
# quota -v
....
@ -1506,7 +1506,7 @@ Soft limits can be exceeded for a limited amount of time, known as the grace per
In the following example, the quota for the `test` account is being edited. When `edquota` is invoked, the editor specified by `EDITOR` is opened in order to edit the quota limits. The default editor is set to vi.
[source,bash]
[source,shell]
....
# edquota -u test
Quotas for user test:
@ -1527,7 +1527,7 @@ The new quota limits take effect upon exiting the editor.
Sometimes it is desirable to set quota limits on a range of users. This can be done by first assigning the desired quota limit to a user. Then, use `-p` to duplicate that quota to a specified range of user IDs (UIDs). The following command will duplicate those quota limits for UIDs `10,000` through `19,999`:
[source,bash]
[source,shell]
....
# edquota -p test 10000-19999
....
@ -1563,7 +1563,7 @@ rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad
Then, restart `inetd`:
[source,bash]
[source,shell]
....
# service inetd restart
....
@ -1585,7 +1585,7 @@ This facility provides several barriers to protect the data stored in each disk
FreeBSD provides a kernel module for gbde which can be loaded with this command:
[source,bash]
[source,shell]
....
# kldload geom_bde
....
@ -1602,7 +1602,7 @@ The following example demonstrates adding a new hard drive to a system that will
+
Install the new drive to the system as explained in <<disks-adding>>. For the purposes of this example, a new hard drive partition has been added as [.filename]#/dev/ad4s1c# and [.filename]#/dev/ad0s1*# represents the existing standard FreeBSD partitions.
+
[source,bash]
[source,shell]
....
# ls /dev/ad*
/dev/ad0 /dev/ad0s1b /dev/ad0s1e /dev/ad4s1
@ -1612,7 +1612,7 @@ Install the new drive to the system as explained in <<disks-adding>>. For the pu
. Create a Directory to Hold `gbde` Lock Files
+
[source,bash]
[source,shell]
....
# mkdir /etc/gbde
....
@ -1622,7 +1622,7 @@ The gbde lock file contains information that gbde requires to access encrypted p
+
A gbde partition must be initialized before it can be used. This initialization needs to be performed only once. This command will open the default editor, in order to set various configuration options in a template. For use with the UFS file system, set the sector_size to 2048:
+
[source,bash]
[source,shell]
....
# gbde init /dev/ad4s1c -i -L /etc/gbde/ad4s1c.lock
# $FreeBSD: src/sbin/gbde/template.txt,v 1.1.36.1 2009/08/03 08:13:06 kensmith Exp $
@ -1648,14 +1648,14 @@ Lock files _must_ be backed up together with the contents of any encrypted parti
. Attach the Encrypted Partition to the Kernel
+
[source,bash]
[source,shell]
....
# gbde attach /dev/ad4s1c -l /etc/gbde/ad4s1c.lock
....
+
This command will prompt to input the passphrase that was selected during the initialization of the encrypted partition. The new encrypted device will appear in [.filename]#/dev# as [.filename]#/dev/device_name.bde#:
+
[source,bash]
[source,shell]
....
# ls /dev/ad*
/dev/ad0 /dev/ad0s1b /dev/ad0s1e /dev/ad4s1
@ -1667,7 +1667,7 @@ This command will prompt to input the passphrase that was selected during the in
+
Once the encrypted device has been attached to the kernel, a file system can be created on the device. This example creates a UFS file system with soft updates enabled. Be sure to specify the partition which has a [.filename]#*.bde# extension:
+
[source,bash]
[source,shell]
....
# newfs -U /dev/ad4s1c.bde
....
@ -1676,7 +1676,7 @@ Once the encrypted device has been attached to the kernel, a file system can be
+
Create a mount point and mount the encrypted file system:
+
[source,bash]
[source,shell]
....
# mkdir /private
# mount /dev/ad4s1c.bde /private
@ -1686,7 +1686,7 @@ Create a mount point and mount the encrypted file system:
+
The encrypted file system should now be visible and available for use:
+
[source,bash]
[source,shell]
....
% df -H
Filesystem Size Used Avail Capacity Mounted on
@ -1713,7 +1713,7 @@ This requires that the passphrase be entered at the console at boot time. After
====
sysinstall is incompatible with gbde-encrypted devices. All [.filename]#*.bde# devices must be detached from the kernel before starting sysinstall or it will crash during its initial probing for devices. To detach the encrypted device used in the example, use the following command:
[source,bash]
[source,shell]
....
# gbde detach /dev/ad4s1c
....
@ -1749,7 +1749,7 @@ geom_eli_load="YES"
+
To load the kernel module now:
+
[source,bash]
[source,shell]
....
# kldload geom_eli
....
@ -1766,7 +1766,7 @@ device crypto
+
The following commands generate a master key that all data will be encrypted with. This key can never be changed. Rather than using it directly, it is encrypted with one or more user keys. The user keys are made up of an optional combination of random bytes from a file, [.filename]#/root/da2.key#, and/or a passphrase. In this case, the data source for the key file is [.filename]#/dev/random#. This command also configures the sector size of the provider ([.filename]#/dev/da2.eli#) as 4kB, for better performance:
+
[source,bash]
[source,shell]
....
# dd if=/dev/random of=/root/da2.key bs=64 count=1
# geli init -K /root/da2.key -s 4096 /dev/da2
@ -1778,7 +1778,7 @@ It is not mandatory to use both a passphrase and a key file as either method of
+
If the key file is given as "-", standard input will be used. For example, this command generates three key files:
+
[source,bash]
[source,shell]
....
# cat keyfile1 keyfile2 keyfile3 | geli init -K - /dev/da2
....
@ -1787,7 +1787,7 @@ If the key file is given as "-", standard input will be used. For example, this
+
To attach the provider, specify the key file, the name of the disk, and the passphrase:
+
[source,bash]
[source,shell]
....
# geli attach -k /root/da2.key /dev/da2
Enter passphrase:
@ -1795,7 +1795,7 @@ Enter passphrase:
+
This creates a new device with an [.filename]#.eli# extension:
+
[source,bash]
[source,shell]
....
# ls /dev/da2*
/dev/da2 /dev/da2.eli
@ -1805,7 +1805,7 @@ This creates a new device with an [.filename]#.eli# extension:
+
Next, format the device with the UFS file system and mount it on an existing mount point:
+
[source,bash]
[source,shell]
....
# dd if=/dev/random of=/dev/da2.eli bs=1m
# newfs /dev/da2.eli
@ -1814,7 +1814,7 @@ Next, format the device with the UFS file system and mount it on an existing mou
+
The encrypted file system should now be available for use:
+
[source,bash]
[source,shell]
....
# df -H
Filesystem Size Used Avail Capacity Mounted on
@ -1828,7 +1828,7 @@ Filesystem Size Used Avail Capacity Mounted on
Once the work on the encrypted partition is done, and the [.filename]#/private# partition is no longer needed, it is prudent to put the device into cold storage by unmounting and detaching the `geli` encrypted partition from the kernel:
[source,bash]
[source,shell]
....
# umount /private
# geli detach da2.eli
@ -1855,7 +1855,7 @@ This section demonstrates how to configure an encrypted swap partition using man
Swap partitions are not encrypted by default and should be cleared of any sensitive data before continuing. To overwrite the current swap partition with random garbage, execute the following command:
[source,bash]
[source,shell]
....
# dd if=/dev/random of=/dev/ada0s1b bs=1m
....
@ -1904,7 +1904,7 @@ Once the system has rebooted, proper operation of the encrypted swap can be veri
If man:gbde[8] is being used:
[source,bash]
[source,shell]
....
% swapinfo
Device 1K-blocks Used Avail Capacity
@ -1913,7 +1913,7 @@ Device 1K-blocks Used Avail Capacity
If man:geli[8] is being used:
[source,bash]
[source,shell]
....
% swapinfo
Device 1K-blocks Used Avail Capacity
@ -2010,7 +2010,7 @@ It is also possible to use host names in the `remote` statements if the hosts ar
Once the configuration exists on both nodes, the HAST pool can be created. Run these commands on both nodes to place the initial metadata onto the local disk and to start man:hastd[8]:
[source,bash]
[source,shell]
....
# hastctl create test
# service hastd onestart
@ -2023,21 +2023,21 @@ It is _not_ possible to use GEOM providers with an existing file system or to co
A HAST node's `primary` or `secondary` role is selected by an administrator, or software like Heartbeat, using man:hastctl[8]. On the primary node, `hasta`, issue this command:
[source,bash]
[source,shell]
....
# hastctl role primary test
....
Run this command on the secondary node, `hastb`:
[source,bash]
[source,shell]
....
# hastctl role secondary test
....
Verify the result by running `hastctl` on each node:
[source,bash]
[source,shell]
....
# hastctl status test
....
@ -2046,7 +2046,7 @@ Check the `status` line in the output. If it says `degraded`, something is wrong
The next step is to create a file system on the GEOM provider and mount it. This must be done on the `primary` node. Creating the file system can take a few minutes, depending on the size of the hard drive. This example creates a UFS file system on [.filename]#/dev/hast/test#:
[source,bash]
[source,shell]
....
# newfs -U /dev/hast/test
# mkdir /hast/test
@ -2096,7 +2096,7 @@ If the systems are running FreeBSD 10 or higher, replace [.filename]#carp0# with
Restart man:devd[8] on both nodes to put the new configuration into effect:
[source,bash]
[source,shell]
....
# service devd restart
....
@ -2229,7 +2229,7 @@ _Split-brain_ occurs when the nodes of the cluster are unable to communicate wit
The administrator must either decide which node has more important changes, or perform the merge manually. Then, let HAST perform full synchronization of the node which has the broken data. To do this, issue these commands on the node which needs to be resynchronized:
[source,bash]
[source,shell]
....
# hastctl role init test
# hastctl create test