Index: head/en_US.ISO8859-1/books/handbook/geom/chapter.xml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/geom/chapter.xml (revision 52152)
+++ head/en_US.ISO8859-1/books/handbook/geom/chapter.xml (revision 52153)
@@ -1,1693 +1,1693 @@
GEOM: Modular Disk Transformation FrameworkTomRhodesWritten by SynopsisGEOMGEOM Disk FrameworkGEOMIn &os;, the GEOM framework permits
access and control to classes, such as Master Boot Records and
BSD labels, through the use of providers, or
the disk devices in /dev. By supporting
various software RAID configurations,
GEOM transparently provides access to the
operating system and operating system utilities.This chapter covers the use of disks under the
GEOM framework in &os;. This includes the
major RAID control utilities which use the
framework for configuration. This chapter is not a definitive
guide to RAID configurations and only
GEOM-supported RAID
classifications are discussed.After reading this chapter, you will know:What type of RAID support is
available through GEOM.How to use the base utilities to configure, maintain,
and manipulate the various RAID
levels.How to mirror, stripe, encrypt, and remotely connect
disk devices through GEOM.How to troubleshoot disks attached to the
GEOM framework.Before reading this chapter, you should:Understand how &os; treats disk devices ().Know how to configure and install a new kernel ().RAID0 - StripingTomRhodesWritten by MurrayStokelyGEOMStripingStriping combines several disk drives into a single volume.
Striping can be performed through the use of hardware
RAID controllers. The
GEOM disk subsystem provides software support
for disk striping, also known as RAID0,
without the need for a RAID disk
controller.In RAID0, data is split into blocks that
are written across all the drives in the array. As seen in the
following illustration, instead of having to wait on the system
to write 256k to one disk, RAID0 can
simultaneously write 64k to each of the four disks in the array,
offering superior I/O performance. This
performance can be enhanced further by using multiple disk
controllers.Disk Striping IllustrationEach disk in a RAID0 stripe must be of
the same size, since I/O requests are
interleaved to read or write to multiple disks in
parallel.RAID0 does not
provide any redundancy. This means that if one disk in the
array fails, all of the data on the disks is lost. If the
data is important, implement a backup strategy that regularly
saves backups to a remote system or device.The process for creating a software,
GEOM-based RAID0 on a &os;
system using commodity disks is as follows. Once the stripe is
created, refer to &man.gstripe.8; for more information on how
to control an existing stripe.Creating a Stripe of Unformatted ATA
DisksLoad the geom_stripe.ko
module:&prompt.root; kldload geom_stripeEnsure that a suitable mount point exists. If this
volume will become a root partition, then temporarily use
another mount point such as
/mnt.Determine the device names for the disks which will
be striped, and create the new stripe device. For example,
to stripe two unused and unpartitioned
ATA disks with device names of
/dev/ad2 and
/dev/ad3:&prompt.root; gstripe label -v st0 /dev/ad2 /dev/ad3
Metadata value stored on /dev/ad2.
Metadata value stored on /dev/ad3.
Done.Write a standard label, also known as a partition table,
on the new volume and install the default bootstrap
code:&prompt.root; bsdlabel -wB /dev/stripe/st0This process should create two other devices in
/dev/stripe in addition to
st0. Those include
st0a and st0c. At
this point, a UFS file system can be
created on st0a using
newfs:&prompt.root; newfs -U /dev/stripe/st0aMany numbers will glide across the screen, and after a
few seconds, the process will be complete. The volume has
been created and is ready to be mounted.To manually mount the created disk stripe:&prompt.root; mount /dev/stripe/st0a /mntTo mount this striped file system automatically during
the boot process, place the volume information in
/etc/fstab. In this example, a
permanent mount point, named stripe, is
created:&prompt.root; mkdir /stripe
&prompt.root; echo "/dev/stripe/st0a /stripe ufs rw 2 2" \>> /etc/fstabThe geom_stripe.ko module must also
be automatically loaded during system initialization, by
adding a line to
/boot/loader.conf:
- &prompt.root; echo 'geom_stripe_load="YES"' >> /boot/loader.conf
+ &prompt.root; sysrc -f /boot/loader.conf geom_stripe_load=YESRAID1 - MirroringGEOMDisk MirroringRAID1RAID1, or
mirroring, is the technique of writing
the same data to more than one disk drive. Mirrors are usually
used to guard against data loss due to drive failure. Each
drive in a mirror contains an identical copy of the data. When
an individual drive fails, the mirror continues to work,
providing data from the drives that are still functioning. The
computer keeps running, and the administrator has time to
replace the failed drive without user interruption.Two common situations are illustrated in these examples.
The first creates a mirror out of two new drives and uses it as
a replacement for an existing single drive. The second example
creates a mirror on a single new drive, copies the old drive's
data to it, then inserts the old drive into the mirror. While
this procedure is slightly more complicated, it only requires
one new drive.Traditionally, the two drives in a mirror are identical in
model and capacity, but &man.gmirror.8; does not require that.
Mirrors created with dissimilar drives will have a capacity
equal to that of the smallest drive in the mirror. Extra space
on larger drives will be unused. Drives inserted into the
mirror later must have at least as much capacity as the smallest
drive already in the mirror.The mirroring procedures shown here are non-destructive,
but as with any major disk operation, make a full backup
first.While &man.dump.8; is used in these procedures
to copy file systems, it does not work on file systems with
soft updates journaling. See &man.tunefs.8; for information
on detecting and disabling soft updates journaling.Metadata IssuesMany disk systems store metadata at the end of each disk.
Old metadata should be erased before reusing the disk for a
mirror. Most problems are caused by two particular types of
leftover metadata: GPT partition tables and
old metadata from a previous mirror.GPT metadata can be erased with
&man.gpart.8;. This example erases both primary and backup
GPT partition tables from disk
ada8:&prompt.root; gpart destroy -F ada8A disk can be removed from an active mirror and the
metadata erased in one step using &man.gmirror.8;. Here, the
example disk ada8 is removed from the
active mirror gm4:&prompt.root; gmirror remove gm4 ada8If the mirror is not running, but old mirror metadata is
still on the disk, use gmirror clear to
remove it:&prompt.root; gmirror clear ada8&man.gmirror.8; stores one block of metadata at the end of
the disk. Because GPT partition schemes
also store metadata at the end of the disk, mirroring entire
GPT disks with &man.gmirror.8; is not
recommended. MBR partitioning is used here
because it only stores a partition table at the start of the
disk and does not conflict with the mirror metadata.Creating a Mirror with Two New DisksIn this example, &os; has already been installed on a
single disk, ada0. Two new disks,
ada1 and ada2, have
been connected to the system. A new mirror will be created on
these two disks and used to replace the old single
disk.The geom_mirror.ko kernel module must
either be built into the kernel or loaded at boot- or
run-time. Manually load the kernel module now:&prompt.root; gmirror loadCreate the mirror with the two new drives:&prompt.root; gmirror label -v gm0 /dev/ada1 /dev/ada2gm0 is a user-chosen device name
assigned to the new mirror. After the mirror has been
started, this device name appears in
/dev/mirror/.MBR and
bsdlabel partition tables can now
be created on the mirror with &man.gpart.8;. This example
uses a traditional file system layout, with partitions for
/, swap, /var,
/tmp, and /usr. A
single / and a swap partition
will also work.Partitions on the mirror do not have to be the same size
as those on the existing disk, but they must be large enough
to hold all the data already present on
ada0.&prompt.root; gpart create -s MBR mirror/gm0
&prompt.root; gpart add -t freebsd -a 4k mirror/gm0
&prompt.root; gpart show mirror/gm0
=> 63 156301423 mirror/gm0 MBR (74G)
63 63 - free - (31k)
126 156301299 1 freebsd (74G)
156301425 61 - free - (30k)&prompt.root; gpart create -s BSD mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k -s 2g mirror/gm0s1
&prompt.root; gpart add -t freebsd-swap -a 4k -s 4g mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k -s 2g mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k -s 1g mirror/gm0s1
&prompt.root; gpart add -t freebsd-ufs -a 4k mirror/gm0s1
&prompt.root; gpart show mirror/gm0s1
=> 0 156301299 mirror/gm0s1 BSD (74G)
0 2 - free - (1.0k)
2 4194304 1 freebsd-ufs (2.0G)
4194306 8388608 2 freebsd-swap (4.0G)
12582914 4194304 4 freebsd-ufs (2.0G)
16777218 2097152 5 freebsd-ufs (1.0G)
18874370 137426928 6 freebsd-ufs (65G)
156301298 1 - free - (512B)Make the mirror bootable by installing bootcode in the
MBR and bsdlabel and setting the active
slice:&prompt.root; gpart bootcode -b /boot/mbr mirror/gm0
&prompt.root; gpart set -a active -i 1 mirror/gm0
&prompt.root; gpart bootcode -b /boot/boot mirror/gm0s1Format the file systems on the new mirror, enabling
soft-updates.&prompt.root; newfs -U /dev/mirror/gm0s1a
&prompt.root; newfs -U /dev/mirror/gm0s1d
&prompt.root; newfs -U /dev/mirror/gm0s1e
&prompt.root; newfs -U /dev/mirror/gm0s1fFile systems from the original ada0
disk can now be copied onto the mirror with &man.dump.8; and
&man.restore.8;.&prompt.root; mount /dev/mirror/gm0s1a /mnt
&prompt.root; dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
&prompt.root; mount /dev/mirror/gm0s1d /mnt/var
&prompt.root; mount /dev/mirror/gm0s1e /mnt/tmp
&prompt.root; mount /dev/mirror/gm0s1f /mnt/usr
&prompt.root; dump -C16 -b64 -0aL -f - /var | (cd /mnt/var && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /tmp | (cd /mnt/tmp && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /usr | (cd /mnt/usr && restore -rf -)Edit /mnt/etc/fstab to point to
the new mirror file systems:# Device Mountpoint FStype Options Dump Pass#
/dev/mirror/gm0s1a / ufs rw 1 1
/dev/mirror/gm0s1b none swap sw 0 0
/dev/mirror/gm0s1d /var ufs rw 2 2
/dev/mirror/gm0s1e /tmp ufs rw 2 2
/dev/mirror/gm0s1f /usr ufs rw 2 2If the geom_mirror.ko kernel module
has not been built into the kernel,
/mnt/boot/loader.conf is edited to load
the module at boot:geom_mirror_load="YES"Reboot the system to test the new mirror and verify that
all data has been copied. The BIOS will
see the mirror as two individual drives rather than a mirror.
Because the drives are identical, it does not matter which is
selected to boot.See if there are
problems booting. Powering down and disconnecting the
original ada0 disk will allow it to be
kept as an offline backup.In use, the mirror will behave just like the original
single drive.Creating a Mirror with an Existing DriveIn this example, &os; has already been installed on a
single disk, ada0. A new disk,
ada1, has been connected to the system.
A one-disk mirror will be created on the new disk, the
existing system copied onto it, and then the old disk will be
inserted into the mirror. This slightly complex procedure is
required because gmirror needs to put a
512-byte block of metadata at the end of each disk, and the
existing ada0 has usually had all of its
space already allocated.Load the geom_mirror.ko kernel
module:&prompt.root; gmirror loadCheck the media size of the original disk with
diskinfo:&prompt.root; diskinfo -v ada0 | head -n3
/dev/ada0
512 # sectorsize
1000204821504 # mediasize in bytes (931G)Create a mirror on the new disk. To make certain that the
mirror capacity is not any larger than the original
ada0 drive, &man.gnop.8; is used to
create a fake drive of the exact same size. This drive does
not store any data, but is used only to limit the size of the
mirror. When &man.gmirror.8; creates the mirror, it will
restrict the capacity to the size of
gzero.nop, even if the new
ada1 drive has more space. Note that the
1000204821504 in the second line is
equal to ada0's media size as shown by
diskinfo above.&prompt.root; geom zero load
&prompt.root; gnop create -s 1000204821504 gzero
&prompt.root; gmirror label -v gm0 gzero.nop ada1
&prompt.root; gmirror forget gm0Since gzero.nop does not store any
data, the mirror does not see it as connected. The mirror is
told to forget unconnected components, removing
references to gzero.nop. The result is a
mirror device containing only a single disk,
ada1.After creating gm0, view the
partition table on ada0. This output is
from a 1 TB drive. If there is some unallocated space at
the end of the drive, the contents may be copied directly from
ada0 to the new mirror.However, if the output shows that all of the space on the
disk is allocated, as in the following listing, there is no
space available for the 512-byte mirror metadata at the end of
the disk.&prompt.root; gpart show ada0
=> 63 1953525105 ada0 MBR (931G)
63 1953525105 1 freebsd [active] (931G)In this case, the partition table must be edited to reduce
the capacity by one sector on mirror/gm0.
The procedure will be explained later.In either case, partition tables on the primary disk
should be first copied using gpart backup
and gpart restore.&prompt.root; gpart backup ada0 > table.ada0
&prompt.root; gpart backup ada0s1 > table.ada0s1These commands create two files,
table.ada0 and
table.ada0s1. This example is from a
1 TB drive:&prompt.root; cat table.ada0
MBR 4
1 freebsd 63 1953525105 [active]&prompt.root; cat table.ada0s1
BSD 8
1 freebsd-ufs 0 4194304
2 freebsd-swap 4194304 33554432
4 freebsd-ufs 37748736 50331648
5 freebsd-ufs 88080384 41943040
6 freebsd-ufs 130023424 838860800
7 freebsd-ufs 968884224 984640881If no free space is shown at the end of the disk, the size
of both the slice and the last partition must be reduced by
one sector. Edit the two files, reducing the size of both the
slice and last partition by one. These are the last numbers
in each listing.&prompt.root; cat table.ada0
MBR 4
1 freebsd 63 1953525104 [active]&prompt.root; cat table.ada0s1
BSD 8
1 freebsd-ufs 0 4194304
2 freebsd-swap 4194304 33554432
4 freebsd-ufs 37748736 50331648
5 freebsd-ufs 88080384 41943040
6 freebsd-ufs 130023424 838860800
7 freebsd-ufs 968884224 984640880If at least one sector was unallocated at the end of the
disk, these two files can be used without modification.Now restore the partition table into
mirror/gm0:&prompt.root; gpart restore mirror/gm0 < table.ada0
&prompt.root; gpart restore mirror/gm0s1 < table.ada0s1Check the partition table with
gpart show. This example has
gm0s1a for /,
gm0s1d for /var,
gm0s1e for /usr,
gm0s1f for /data1,
and gm0s1g for
/data2.&prompt.root; gpart show mirror/gm0
=> 63 1953525104 mirror/gm0 MBR (931G)
63 1953525042 1 freebsd [active] (931G)
1953525105 62 - free - (31k)
&prompt.root; gpart show mirror/gm0s1
=> 0 1953525042 mirror/gm0s1 BSD (931G)
0 2097152 1 freebsd-ufs (1.0G)
2097152 16777216 2 freebsd-swap (8.0G)
18874368 41943040 4 freebsd-ufs (20G)
60817408 20971520 5 freebsd-ufs (10G)
81788928 629145600 6 freebsd-ufs (300G)
710934528 1242590514 7 freebsd-ufs (592G)
1953525042 63 - free - (31k)Both the slice and the last partition must have at least
one free block at the end of the disk.Create file systems on these new partitions. The number
of partitions will vary to match the original disk,
ada0.&prompt.root; newfs -U /dev/mirror/gm0s1a
&prompt.root; newfs -U /dev/mirror/gm0s1d
&prompt.root; newfs -U /dev/mirror/gm0s1e
&prompt.root; newfs -U /dev/mirror/gm0s1f
&prompt.root; newfs -U /dev/mirror/gm0s1gMake the mirror bootable by installing bootcode in the
MBR and bsdlabel and setting the active
slice:&prompt.root; gpart bootcode -b /boot/mbr mirror/gm0
&prompt.root; gpart set -a active -i 1 mirror/gm0
&prompt.root; gpart bootcode -b /boot/boot mirror/gm0s1Adjust /etc/fstab to use the new
partitions on the mirror. Back up this file first by copying
it to /etc/fstab.orig.&prompt.root; cp /etc/fstab /etc/fstab.origEdit /etc/fstab, replacing
/dev/ada0 with
mirror/gm0.# Device Mountpoint FStype Options Dump Pass#
/dev/mirror/gm0s1a / ufs rw 1 1
/dev/mirror/gm0s1b none swap sw 0 0
/dev/mirror/gm0s1d /var ufs rw 2 2
/dev/mirror/gm0s1e /usr ufs rw 2 2
/dev/mirror/gm0s1f /data1 ufs rw 2 2
/dev/mirror/gm0s1g /data2 ufs rw 2 2If the geom_mirror.ko kernel module
has not been built into the kernel, edit
/boot/loader.conf to load it at
boot:geom_mirror_load="YES"File systems from the original disk can now be copied onto
the mirror with &man.dump.8; and &man.restore.8;. Each file
system dumped with dump -L will create a
snapshot first, which can take some time.&prompt.root; mount /dev/mirror/gm0s1a /mnt
&prompt.root; dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)
&prompt.root; mount /dev/mirror/gm0s1d /mnt/var
&prompt.root; mount /dev/mirror/gm0s1e /mnt/usr
&prompt.root; mount /dev/mirror/gm0s1f /mnt/data1
&prompt.root; mount /dev/mirror/gm0s1g /mnt/data2
&prompt.root; dump -C16 -b64 -0aL -f - /usr | (cd /mnt/usr && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /var | (cd /mnt/var && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /data1 | (cd /mnt/data1 && restore -rf -)
&prompt.root; dump -C16 -b64 -0aL -f - /data2 | (cd /mnt/data2 && restore -rf -)Restart the system, booting from
ada1. If everything is working, the
system will boot from mirror/gm0, which
now contains the same data as ada0 had
previously. See if
there are problems booting.At this point, the mirror still consists of only the
single ada1 disk.After booting from mirror/gm0
successfully, the final step is inserting
ada0 into the mirror.When ada0 is inserted into the
mirror, its former contents will be overwritten by data from
the mirror. Make certain that
mirror/gm0 has the same contents as
ada0 before adding
ada0 to the mirror. If the contents
previously copied by &man.dump.8; and &man.restore.8; are
not identical to what was on ada0,
revert /etc/fstab to mount the file
systems on ada0, reboot, and start the
whole procedure again.&prompt.root; gmirror insert gm0 ada0
GEOM_MIRROR: Device gm0: rebuilding provider ada0Synchronization between the two disks will start
immediately. Use gmirror status to view
the progress.&prompt.root; gmirror status
Name Status Components
mirror/gm0 DEGRADED ada1 (ACTIVE)
ada0 (SYNCHRONIZING, 64%)After a while, synchronization will finish.GEOM_MIRROR: Device gm0: rebuilding provider ada0 finished.
&prompt.root; gmirror status
Name Status Components
mirror/gm0 COMPLETE ada1 (ACTIVE)
ada0 (ACTIVE)mirror/gm0 now consists
of the two disks ada0 and
ada1, and the contents are automatically
synchronized with each other. In use,
mirror/gm0 will behave just like the
original single drive.TroubleshootingIf the system no longer boots, BIOS
settings may have to be changed to boot from one of the new
mirrored drives. Either mirror drive can be used for booting,
as they contain identical data.If the boot stops with this message, something is wrong
with the mirror device:Mounting from ufs:/dev/mirror/gm0s1a failed with error 19.
Loader variables:
vfs.root.mountfrom=ufs:/dev/mirror/gm0s1a
vfs.root.mountfrom.options=rw
Manual root filesystem specification:
<fstype>:<device> [options]
Mount <device> using filesystem <fstype>
and with the specified (optional) option list.
eg. ufs:/dev/da0s1a
zfs:tank
cd9660:/dev/acd0 ro
(which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /)
? List valid disk boot devices
. Yield 1 second (for background tasks)
<empty line> Abort manual input
mountroot>Forgetting to load the geom_mirror.ko
module in /boot/loader.conf can cause
this problem. To fix it, boot from a &os;
installation media and choose Shell at the
first prompt. Then load the mirror module and mount the
mirror device:&prompt.root; gmirror load
&prompt.root; mount /dev/mirror/gm0s1a /mntEdit /mnt/boot/loader.conf, adding a
line to load the mirror module:geom_mirror_load="YES"Save the file and reboot.Other problems that cause error 19
require more effort to fix. Although the system should boot
from ada0, another prompt to select a
shell will appear if /etc/fstab is
incorrect. Enter ufs:/dev/ada0s1a at the
boot loader prompt and press Enter. Undo the
edits in /etc/fstab then mount the file
systems from the original disk (ada0)
instead of the mirror. Reboot the system and try the
procedure again.Enter full pathname of shell or RETURN for /bin/sh:
&prompt.root; cp /etc/fstab.orig /etc/fstab
&prompt.root; rebootRecovering from Disk FailureThe benefit of disk mirroring is that an individual disk
can fail without causing the mirror to lose any data. In the
above example, if ada0 fails, the mirror
will continue to work, providing data from the remaining
working drive, ada1.To replace the failed drive, shut down the system and
physically replace the failed drive with a new drive of equal
or greater capacity. Manufacturers use somewhat arbitrary
values when rating drives in gigabytes, and the only way to
really be sure is to compare the total count of sectors shown
by diskinfo -v. A drive with larger
capacity than the mirror will work, although the extra space
on the new drive will not be used.After the computer is powered back up, the mirror will be
running in a degraded mode with only one drive.
The mirror is told to forget drives that are not currently
connected:&prompt.root; gmirror forget gm0Any old metadata should be cleared from the replacement
disk using the instructions in
. Then the replacement
disk, ada4 for this example, is inserted
into the mirror:&prompt.root; gmirror insert gm0 /dev/ada4Resynchronization begins when the new drive is inserted
into the mirror. This process of copying mirror data to a new
drive can take a while. Performance of the mirror will be
greatly reduced during the copy, so inserting new drives is
best done when there is low demand on the computer.Progress can be monitored with gmirror
status, which shows drives that are being
synchronized and the percentage of completion. During
resynchronization, the status will be
DEGRADED, changing to
COMPLETE when the process is
finished.RAID3 - Byte-level Striping with
Dedicated ParityMarkGladmanWritten by DanielGerzoTomRhodesBased on documentation by MurrayStokelyGEOMRAID3RAID3 is a method used to combine several
disk drives into a single volume with a dedicated parity disk.
In a RAID3 system, data is split up into a
number of bytes that are written across all the drives in the
array except for one disk which acts as a dedicated parity disk.
This means that disk reads from a RAID3
implementation access all disks in the array. Performance can
be enhanced by using multiple disk controllers. The
RAID3 array provides a fault tolerance of 1
drive, while providing a capacity of 1 - 1/n times the total
capacity of all drives in the array, where n is the number of
hard drives in the array. Such a configuration is mostly
suitable for storing data of larger sizes such as multimedia
files.At least 3 physical hard drives are required to build a
RAID3 array. Each disk must be of the same
size, since I/O requests are interleaved to
read or write to multiple disks in parallel. Also, due to the
nature of RAID3, the number of drives must be
equal to 3, 5, 9, 17, and so on, or 2^n + 1.This section demonstrates how to create a software
RAID3 on a &os; system.While it is theoretically possible to boot from a
RAID3 array on &os;, that configuration is
uncommon and is not advised.Creating a Dedicated RAID3
ArrayIn &os;, support for RAID3 is
implemented by the &man.graid3.8; GEOM
class. Creating a dedicated RAID3 array on
&os; requires the following steps.First, load the geom_raid3.ko
kernel module by issuing one of the following
commands:&prompt.root; graid3 loador:&prompt.root; kldload geom_raid3Ensure that a suitable mount point exists. This
command creates a new directory to use as the mount
point:&prompt.root; mkdir /multimediaDetermine the device names for the disks which will be
added to the array, and create the new
RAID3 device. The final device listed
will act as the dedicated parity disk. This example uses
three unpartitioned ATA drives:
ada1 and
ada2 for
data, and
ada3 for
parity.&prompt.root; graid3 label -v gr0 /dev/ada1 /dev/ada2 /dev/ada3
Metadata value stored on /dev/ada1.
Metadata value stored on /dev/ada2.
Metadata value stored on /dev/ada3.
Done.Partition the newly created gr0
device and put a UFS file system on
it:&prompt.root; gpart create -s GPT /dev/raid3/gr0
&prompt.root; gpart add -t freebsd-ufs /dev/raid3/gr0
&prompt.root; newfs -j /dev/raid3/gr0p1Many numbers will glide across the screen, and after a
bit of time, the process will be complete. The volume has
been created and is ready to be mounted:&prompt.root; mount /dev/raid3/gr0p1 /multimedia/The RAID3 array is now ready to
use.Additional configuration is needed to retain this setup
across system reboots.The geom_raid3.ko module must be
loaded before the array can be mounted. To automatically
load the kernel module during system initialization, add
the following line to
/boot/loader.conf:geom_raid3_load="YES"The following volume information must be added to
/etc/fstab in order to
automatically mount the array's file system during the
system boot process:/dev/raid3/gr0p1 /multimedia ufs rw 2 2Software RAID DevicesWarrenBlockOriginally contributed by GEOMSoftware RAID DevicesHardware-assisted RAIDSome motherboards and expansion cards add some simple
hardware, usually just a ROM, that allows the
computer to boot from a RAID array. After
booting, access to the RAID array is handled
by software running on the computer's main processor. This
hardware-assisted software
RAID gives RAID
arrays that are not dependent on any particular operating
system, and which are functional even before an operating system
is loaded.Several levels of RAID are supported,
depending on the hardware in use. See &man.graid.8; for a
complete list.&man.graid.8; requires the geom_raid.ko
kernel module, which is included in the
GENERIC kernel starting with &os; 9.1.
If needed, it can be loaded manually with
graid load.Creating an ArraySoftware RAID devices often have a menu
that can be entered by pressing special keys when the computer
is booting. The menu can be used to create and delete
RAID arrays. &man.graid.8; can also create
arrays directly from the command line.graid label is used to create a new
array. The motherboard used for this example has an Intel
software RAID chipset, so the Intel
metadata format is specified. The new array is given a label
of gm0, it is a mirror
(RAID1), and uses drives
ada0 and
ada1.Some space on the drives will be overwritten when they
are made into a new array. Back up existing data
first!&prompt.root; graid label Intel gm0 RAID1 ada0 ada1
GEOM_RAID: Intel-a29ea104: Array Intel-a29ea104 created.
GEOM_RAID: Intel-a29ea104: Disk ada0 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:0-ada0 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Disk ada1 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Array started.
GEOM_RAID: Intel-a29ea104: Volume gm0 state changed from STARTING to OPTIMAL.
Intel-a29ea104 created
GEOM_RAID: Intel-a29ea104: Provider raid/r0 for volume gm0 created.A status check shows the new mirror is ready for
use:&prompt.root; graid status
Name Status Components
raid/r0 OPTIMAL ada0 (ACTIVE (ACTIVE))
ada1 (ACTIVE (ACTIVE))The array device appears in
/dev/raid/. The first array is called
r0. Additional arrays, if present, will
be r1, r2, and so
on.The BIOS menu on some of these devices
can create arrays with special characters in their names. To
avoid problems with those special characters, arrays are given
simple numbered names like r0. To show
the actual labels, like gm0 in the
example above, use &man.sysctl.8;:&prompt.root; sysctl kern.geom.raid.name_format=1Multiple VolumesSome software RAID devices support
more than one volume on an array.
Volumes work like partitions, allowing space on the physical
drives to be split and used in different ways. For example,
Intel software RAID devices support two
volumes. This example creates a 40 G mirror for safely
storing the operating system, followed by a 20 G
RAID0 (stripe) volume for fast temporary
storage:&prompt.root; graid label -S 40G Intel gm0 RAID1 ada0 ada1
&prompt.root; graid add -S 20G gm0 RAID0Volumes appear as additional
rX entries
in /dev/raid/. An array with two volumes
will show r0 and
r1.See &man.graid.8; for the number of volumes supported by
different software RAID devices.Converting a Single Drive to a MirrorUnder certain specific conditions, it is possible to
convert an existing single drive to a &man.graid.8; array
without reformatting. To avoid data loss during the
conversion, the existing drive must meet these minimum
requirements:The drive must be partitioned with the
MBR partitioning scheme.
GPT or other partitioning schemes with
metadata at the end of the drive will be overwritten and
corrupted by the &man.graid.8; metadata.There must be enough unpartitioned and unused space at
the end of the drive to hold the &man.graid.8; metadata.
This metadata varies in size, but the largest occupies
64 M, so at least that much free space is
recommended.If the drive meets these requirements, start by making a
full backup. Then create a single-drive mirror with that
drive:&prompt.root; graid label Intel gm0 RAID1 ada0 NONE&man.graid.8; metadata was written to the end of the drive
in the unused space. A second drive can now be inserted into
the mirror:&prompt.root; graid insert raid/r0 ada1Data from the original drive will immediately begin to be
copied to the second drive. The mirror will operate in
degraded status until the copy is complete.Inserting New Drives into the ArrayDrives can be inserted into an array as replacements for
drives that have failed or are missing. If there are no
failed or missing drives, the new drive becomes a spare. For
example, inserting a new drive into a working two-drive mirror
results in a two-drive mirror with one spare drive, not a
three-drive mirror.In the example mirror array, data immediately begins to be
copied to the newly-inserted drive. Any existing information
on the new drive will be overwritten.&prompt.root; graid insert raid/r0 ada1
GEOM_RAID: Intel-a29ea104: Disk ada1 state changed from NONE to ACTIVE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 state changed from NONE to NEW.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 state changed from NEW to REBUILD.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-ada1 rebuild start at 0.Removing Drives from the ArrayIndividual drives can be permanently removed from a
from an array and their metadata erased:&prompt.root; graid remove raid/r0 ada1
GEOM_RAID: Intel-a29ea104: Disk ada1 state changed from ACTIVE to OFFLINE.
GEOM_RAID: Intel-a29ea104: Subdisk gm0:1-[unknown] state changed from ACTIVE to NONE.
GEOM_RAID: Intel-a29ea104: Volume gm0 state changed from OPTIMAL to DEGRADED.Stopping the ArrayAn array can be stopped without removing metadata from the
drives. The array will be restarted when the system is
booted.&prompt.root; graid stop raid/r0Checking Array StatusArray status can be checked at any time. After a drive
was added to the mirror in the example above, data is being
copied from the original drive to the new drive:&prompt.root; graid status
Name Status Components
raid/r0 DEGRADED ada0 (ACTIVE (ACTIVE))
ada1 (ACTIVE (REBUILD 28%))Some types of arrays, like RAID0 or
CONCAT, may not be shown in the status
report if disks have failed. To see these partially-failed
arrays, add :&prompt.root; graid status -ga
Name Status Components
Intel-e2d07d9a BROKEN ada6 (ACTIVE (ACTIVE))Deleting ArraysArrays are destroyed by deleting all of the volumes from
them. When the last volume present is deleted, the array is
stopped and metadata is removed from the drives:&prompt.root; graid delete raid/r0Deleting Unexpected ArraysDrives may unexpectedly contain &man.graid.8; metadata,
either from previous use or manufacturer testing.
&man.graid.8; will detect these drives and create an array,
interfering with access to the individual drive. To remove
the unwanted metadata:Boot the system. At the boot menu, select
2 for the loader prompt. Enter:OK set kern.geom.raid.enable=0
OK bootThe system will boot with &man.graid.8;
disabled.Back up all data on the affected drive.As a workaround, &man.graid.8; array detection
can be disabled by addingkern.geom.raid.enable=0to /boot/loader.conf.To permanently remove the &man.graid.8; metadata
from the affected drive, boot a &os; installation
CD-ROM or memory stick, and select
Shell. Use status
to find the name of the array, typically
raid/r0:&prompt.root; graid status
Name Status Components
raid/r0 OPTIMAL ada0 (ACTIVE (ACTIVE))
ada1 (ACTIVE (ACTIVE))Delete the volume by name:&prompt.root; graid delete raid/r0If there is more than one volume shown, repeat the
process for each volume. After the last array has been
deleted, the volume will be destroyed.Reboot and verify data, restoring from backup if
necessary. After the metadata has been removed, the
kern.geom.raid.enable=0 entry in
/boot/loader.conf can also be
removed.GEOM Gate NetworkGEOM provides a simple mechanism for
providing remote access to devices such as disks,
CDs, and file systems through the use of the
GEOM Gate network daemon,
ggated. The system with the device
runs the server daemon which handles requests made by clients
using ggatec. The devices should not
contain any sensitive data as the connection between the client
and the server is not encrypted.Similar to NFS, which is discussed in
, ggated
is configured using an exports file. This file specifies which
systems are permitted to access the exported resources and what
level of access they are offered. For example, to give the
client 192.168.1.5
read and write access to the fourth slice on the first
SCSI disk, create
/etc/gg.exports with this line:192.168.1.5 RW /dev/da0s4dBefore exporting the device, ensure it is not currently
mounted. Then, start ggated:&prompt.root; ggatedSeveral options are available for specifying an alternate
listening port or changing the default location of the exports
file. Refer to &man.ggated.8; for details.To access the exported device on the client machine, first
use ggatec to specify the
IP address of the server and the device name
of the exported device. If successful, this command will
display a ggate device name to mount. Mount
that specified device name on a free mount point. This example
connects to the /dev/da0s4d partition on
192.168.1.1, then mounts
/dev/ggate0 on
/mnt:&prompt.root; ggatec create -o rw 192.168.1.1 /dev/da0s4d
ggate0
&prompt.root; mount /dev/ggate0 /mntThe device on the server may now be accessed through
/mnt on the client. For more details about
ggatec and a few usage examples, refer to
&man.ggatec.8;.The mount will fail if the device is currently mounted on
either the server or any other client on the network. If
simultaneous access is needed to network resources, use
NFS instead.When the device is no longer needed, unmount it with
umount so that the resource is available to
other clients.Labeling Disk DevicesGEOMDisk LabelsDuring system initialization, the &os; kernel creates
device nodes as devices are found. This method of probing for
devices raises some issues. For instance, what if a new disk
device is added via USB? It is likely that
a flash device may be handed the device name of
da0 and the original
da0 shifted to
da1. This will cause issues mounting
file systems if they are listed in
/etc/fstab which may also prevent the
system from booting.One solution is to chain SCSI devices
in order so a new device added to the SCSI
card will be issued unused device numbers. But what about
USB devices which may replace the primary
SCSI disk? This happens because
USB devices are usually probed before the
SCSI card. One solution is to only insert
these devices after the system has been booted. Another method
is to use only a single ATA drive and never
list the SCSI devices in
/etc/fstab.A better solution is to use glabel to
label the disk devices and use the labels in
/etc/fstab. Because
glabel stores the label in the last sector of
a given provider, the label will remain persistent across
reboots. By using this label as a device, the file system may
always be mounted regardless of what device node it is accessed
through.glabel can create both transient and
permanent labels. Only permanent labels are consistent across
reboots. Refer to &man.glabel.8; for more information on the
differences between labels.Label Types and ExamplesPermanent labels can be a generic or a file system label.
Permanent file system labels can be created with
&man.tunefs.8; or &man.newfs.8;. These types of labels are
created in a sub-directory of /dev, and
will be named according to the file system type. For example,
UFS2 file system labels will be created in
/dev/ufs. Generic permanent labels can
be created with glabel label. These are
not file system specific and will be created in
/dev/label.Temporary labels are destroyed at the next reboot. These
labels are created in /dev/label and are
suited to experimentation. A temporary label can be created
using glabel create.To create a permanent label for a
UFS2 file system without destroying any
data, issue the following command:&prompt.root; tunefs -L home/dev/da3A label should now exist in /dev/ufs
which may be added to /etc/fstab:/dev/ufs/home /home ufs rw 2 2The file system must not be mounted while attempting
to run tunefs.Now the file system may be mounted:&prompt.root; mount /homeFrom this point on, so long as the
geom_label.ko kernel module is loaded at
boot with /boot/loader.conf or the
GEOM_LABEL kernel option is present,
the device node may change without any ill effect on the
system.File systems may also be created with a default label
by using the flag with
newfs. Refer to &man.newfs.8; for
more information.The following command can be used to destroy the
label:&prompt.root; glabel destroy homeThe following example shows how to label the partitions of
a boot disk.Labeling Partitions on the Boot DiskBy permanently labeling the partitions on the boot disk,
the system should be able to continue to boot normally, even
if the disk is moved to another controller or transferred to
a different system. For this example, it is assumed that a
single ATA disk is used, which is
currently recognized by the system as
ad0. It is also assumed that the
standard &os; partition scheme is used, with
/,
/var,
/usr and
/tmp, as
well as a swap partition.Reboot the system, and at the &man.loader.8; prompt,
press 4 to boot into single user mode.
Then enter the following commands:&prompt.root; glabel label rootfs /dev/ad0s1a
GEOM_LABEL: Label for provider /dev/ad0s1a is label/rootfs
&prompt.root; glabel label var /dev/ad0s1d
GEOM_LABEL: Label for provider /dev/ad0s1d is label/var
&prompt.root; glabel label usr /dev/ad0s1f
GEOM_LABEL: Label for provider /dev/ad0s1f is label/usr
&prompt.root; glabel label tmp /dev/ad0s1e
GEOM_LABEL: Label for provider /dev/ad0s1e is label/tmp
&prompt.root; glabel label swap /dev/ad0s1b
GEOM_LABEL: Label for provider /dev/ad0s1b is label/swap
&prompt.root; exitThe system will continue with multi-user boot. After
the boot completes, edit /etc/fstab and
replace the conventional device names, with their respective
labels. The final /etc/fstab will
look like this:# Device Mountpoint FStype Options Dump Pass#
/dev/label/swap none swap sw 0 0
/dev/label/rootfs / ufs rw 1 1
/dev/label/tmp /tmp ufs rw 2 2
/dev/label/usr /usr ufs rw 2 2
/dev/label/var /var ufs rw 2 2The system can now be rebooted. If everything went
well, it will come up normally and mount
will show:&prompt.root; mount
/dev/label/rootfs on / (ufs, local)
devfs on /dev (devfs, local)
/dev/label/tmp on /tmp (ufs, local, soft-updates)
/dev/label/usr on /usr (ufs, local, soft-updates)
/dev/label/var on /var (ufs, local, soft-updates)The &man.glabel.8; class
supports a label type for UFS file
systems, based on the unique file system id,
ufsid. These labels may be found in
/dev/ufsid and are
created automatically during system startup. It is possible
to use ufsid labels to mount partitions
using /etc/fstab. Use glabel
status to receive a list of file systems and their
corresponding ufsid labels:&prompt.user; glabel status
Name Status Components
ufsid/486b6fc38d330916 N/A ad4s1d
ufsid/486b6fc16926168e N/A ad4s1fIn the above example, ad4s1d
represents /var,
while ad4s1f represents
/usr.
Using the ufsid values shown, these
partitions may now be mounted with the following entries in
/etc/fstab:/dev/ufsid/486b6fc38d330916 /var ufs rw 2 2
/dev/ufsid/486b6fc16926168e /usr ufs rw 2 2Any partitions with ufsid labels can be
mounted in this way, eliminating the need to manually create
permanent labels, while still enjoying the benefits of device
name independent mounting.UFS Journaling Through GEOMGEOMJournalingSupport for journals on
UFS file systems is available on &os;. The
implementation is provided through the GEOM
subsystem and is configured using gjournal.
Unlike other file system journaling implementations, the
gjournal method is block based and not
implemented as part of the file system. It is a
GEOM extension.Journaling stores a log of file system transactions, such as
changes that make up a complete disk write operation, before
meta-data and file writes are committed to the disk. This
transaction log can later be replayed to redo file system
transactions, preventing file system inconsistencies.This method provides another mechanism to protect against
data loss and inconsistencies of the file system. Unlike Soft
Updates, which tracks and enforces meta-data updates, and
snapshots, which create an image of the file system, a log is
stored in disk space specifically for this task. For better
performance, the journal may be stored on another disk. In this
configuration, the journal provider or storage device should be
listed after the device to enable journaling on.The GENERIC kernel provides support for
gjournal. To automatically load the
geom_journal.ko kernel module at boot time,
add the following line to
/boot/loader.conf:geom_journal_load="YES"If a custom kernel is used, ensure the following line is in
the kernel configuration file:options GEOM_JOURNALOnce the module is loaded, a journal can be created on a new
file system using the following steps. In this example,
da4 is a new SCSI
disk:&prompt.root; gjournal load
&prompt.root; gjournal label /dev/da4This will load the module and create a
/dev/da4.journal device node on
/dev/da4.A UFS file system may now be created on
the journaled device, then mounted on an existing mount
point:&prompt.root; newfs -O 2 -J /dev/da4.journal
&prompt.root; mount /dev/da4.journal /mntIn the case of several slices, a journal will be created
for each individual slice. For instance, if
ad4s1 and ad4s2 are
both slices, then gjournal will create
ad4s1.journal and
ad4s2.journal.Journaling may also be enabled on current file systems by
using tunefs. However,
always make a backup before attempting to
alter an existing file system. In most cases,
gjournal will fail if it is unable to create
the journal, but this does not protect against data loss
incurred as a result of misusing tunefs.
Refer to &man.gjournal.8; and &man.tunefs.8; for more
information about these commands.It is possible to journal the boot disk of a &os; system.
Refer to the article Implementing UFS
Journaling on a Desktop PC for detailed
instructions.
Index: head/en_US.ISO8859-1/books/handbook/serialcomms/chapter.xml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/serialcomms/chapter.xml (revision 52152)
+++ head/en_US.ISO8859-1/books/handbook/serialcomms/chapter.xml (revision 52153)
@@ -1,2191 +1,2191 @@
Serial CommunicationsSynopsisserial communications&unix; has always had support for serial communications as
the very first &unix; machines relied on serial lines for user
input and output. Things have changed a lot from the days
when the average terminal consisted of a 10-character-per-second
serial printer and a keyboard. This chapter covers some of the
ways serial communications can be used on &os;.After reading this chapter, you will know:How to connect terminals to a &os; system.How to use a modem to dial out to remote hosts.How to allow remote users to login to a &os; system
with a modem.How to boot a &os; system from a serial console.Before reading this chapter, you should:Know how to configure and
install a custom kernel.Understand &os; permissions
and processes.Have access to the technical manual for the serial
hardware to be used with &os;.Serial Terminology and HardwareThe following terms are often used in serial
communications:bpsBits per
Secondbits-per-second
(bps) is the rate at which data is
transmitted.DTEData Terminal
EquipmentDTE
(DTE) is one of two endpoints in a
serial communication. An example would be a
computer.DCEData Communications
EquipmentDCE
(DTE) is the other endpoint in a
serial communication. Typically, it is a modem or serial
terminal.RS-232The original standard which defined hardware serial
communications. It has since been renamed to
TIA-232.When referring to communication data rates, this section
does not use the term baud. Baud refers
to the number of electrical state transitions made in a period
of time, while bps is the correct term to
use.To connect a serial terminal to a &os; system, a serial port
on the computer and the proper cable to connect to the serial
device are needed. Users who are already familiar with serial
hardware and cabling can safely skip this section.Serial Cables and PortsThere are several different kinds of serial cables. The
two most common types are null-modem cables and standard
RS-232 cables. The documentation for the
hardware should describe the type of cable required.These two types of cables differ in how the wires are
connected to the connector. Each wire represents a signal,
with the defined signals summarized in . A standard serial
cable passes all of the RS-232C signals
straight through. For example, the Transmitted
Data pin on one end of the cable goes to the
Transmitted Data pin on the other end. This is
the type of cable used to connect a modem to the &os; system,
and is also appropriate for some terminals.A null-modem cable switches the Transmitted
Data pin of the connector on one end with the
Received Data pin on the other end. The
connector can be either a DB-25 or a
DB-9.A null-modem cable can be constructed using the pin
connections summarized in ,
, and . While the standard calls for
a straight-through pin 1 to pin 1 Protective
Ground line, it is often omitted. Some terminals
work using only pins 2, 3, and 7, while others require
different configurations. When in doubt, refer to the
documentation for the hardware.null-modem cable
RS-232C Signal NamesAcronymsNamesRDReceived DataTDTransmitted DataDTRData Terminal ReadyDSRData Set ReadyDCDData Carrier DetectSGSignal GroundRTSRequest to SendCTSClear to Send
When one pin at one end connects to a pair of pins at
the other end, it is usually implemented with one short wire
between the pair of pins in their connector and a long wire
to the other single pin.Serial ports are the devices through which data is
transferred between the &os; host computer and the terminal.
Several kinds of serial ports exist. Before purchasing or
constructing a cable, make sure it will fit the ports on the
terminal and on the &os; system.Most terminals have DB-25 ports.
Personal computers may have DB-25 or
DB-9 ports. A multiport serial card may
have RJ-12 or RJ-45/
ports. See the documentation that accompanied the hardware
for specifications on the kind of port or visually verify the
type of port.In &os;, each serial port is accessed through an entry in
/dev. There are two different kinds of
entries:Call-in ports are named
/dev/ttyuN
where N is the port number,
starting from zero. If a terminal is connected to the
first serial port (COM1), use
/dev/ttyu0 to refer to the terminal.
If the terminal is on the second serial port
(COM2), use
/dev/ttyu1, and so forth. Generally,
the call-in port is used for terminals. Call-in ports
require that the serial line assert the Data
Carrier Detect signal to work correctly.Call-out ports are named
/dev/cuauN
on &os; versions 8.X and higher and
/dev/cuadN
on &os; versions 7.X and lower. Call-out ports are
usually not used for terminals, but are used for modems.
The call-out port can be used if the serial cable or the
terminal does not support the Data Carrier
Detect signal.&os; also provides initialization devices
(/dev/ttyuN.init
and
/dev/cuauN.init
or
/dev/cuadN.init)
and locking devices
(/dev/ttyuN.lock
and
/dev/cuauN.lock
or
/dev/cuadN.lock).
The initialization devices are used to initialize
communications port parameters each time a port is opened,
such as crtscts for modems which use
RTS/CTS signaling for flow control. The
locking devices are used to lock flags on ports to prevent
users or programs changing certain parameters. Refer to
&man.termios.4;, &man.sio.4;, and &man.stty.1; for information
on terminal settings, locking and initializing devices, and
setting terminal options, respectively.Serial Port ConfigurationBy default, &os; supports four serial ports which are
commonly known as COM1,
COM2, COM3, and
COM4. &os; also supports dumb multi-port
serial interface cards, such as the BocaBoard 1008 and 2016,
as well as more intelligent multi-port cards such as those
made by Digiboard. However, the default kernel only looks for
the standard COM ports.To see if the system recognizes the serial ports, look for
system boot messages that start with
uart:&prompt.root; grep uart /var/run/dmesg.bootIf the system does not recognize all of the needed serial
ports, additional entries can be added to
/boot/device.hints. This file already
contains hint.uart.0.* entries for
COM1 and hint.uart.1.*
entries for COM2. When adding a port
entry for COM3 use
0x3E8, and for COM4
use 0x2E8. Common IRQ
addresses are 5 for
COM3 and 9 for
COM4.ttyucuauTo determine the default set of terminal
I/O settings used by the port, specify its
device name. This example determines the settings for the
call-in port on COM2:&prompt.root; stty -a -f /dev/ttyu1System-wide initialization of serial devices is controlled
by /etc/rc.d/serial. This file affects
the default settings of serial devices. To change the
settings for a device, use stty. By
default, the changed settings are in effect until the device
is closed and when the device is reopened, it goes back to the
default set. To permanently change the default set, open and
adjust the settings of the initialization device. For
example, to turn on mode, 8 bit
communication, and flow control for
ttyu5, type:&prompt.root; stty -f /dev/ttyu5.init clocal cs8 ixon ixoffrc filesrc.serialTo prevent certain settings from being changed by an
application, make adjustments to the locking device. For
example, to lock the speed of ttyu5 to
57600 bps, type:&prompt.root; stty -f /dev/ttyu5.lock 57600Now, any application that opens ttyu5
and tries to change the speed of the port will be stuck with
57600 bps.TerminalsSeanKellyContributed by terminalsTerminals provide a convenient and low-cost way to access
a &os; system when not at the computer's console or on a
connected network. This section describes how to use terminals
with &os;.The original &unix; systems did not have consoles. Instead,
users logged in and ran programs through terminals that were
connected to the computer's serial ports.The ability to establish a login session on a serial port
still exists in nearly every &unix;-like operating system
today, including &os;. By using a terminal attached to an
unused serial port, a user can log in and run any text program
that can normally be run on the console or in an
xterm window.Many terminals can be attached to a &os; system. An older
spare computer can be used as a terminal wired into a more
powerful computer running &os;. This can turn what might
otherwise be a single-user computer into a powerful
multiple-user system.&os; supports three types of terminals:Dumb terminalsDumb terminals are specialized hardware that connect
to computers over serial lines. They are called
dumb because they have only enough
computational power to display, send, and receive text.
No programs can be run on these devices. Instead, dumb
terminals connect to a computer that runs the needed
programs.There are hundreds of kinds of dumb terminals made by
many manufacturers, and just about any kind will work with
&os;. Some high-end terminals can even display graphics,
but only certain software packages can take advantage of
these advanced features.Dumb terminals are popular in work environments where
workers do not need access to graphical
applications.Computers Acting as TerminalsSince a dumb terminal has just enough ability to
display, send, and receive text, any spare computer can
be a dumb terminal. All that is needed is the proper
cable and some terminal emulation
software to run on the computer.This configuration can be useful. For example, if one
user is busy working at the &os; system's console, another
user can do some text-only work at the same time from a
less powerful personal computer hooked up as a terminal to
the &os; system.There are at least two utilities in the base-system of
&os; that can be used to work through a serial connection:
&man.cu.1; and &man.tip.1;.For example, to connect from a client system that runs
&os; to the serial connection of another system:&prompt.root; cu -l /dev/cuauNPorts are numbered starting from zero. This means that
COM1 is
/dev/cuau0.Additional programs are available through the Ports
Collection, such as
comms/minicom.X TerminalsX terminals are the most sophisticated kind of
terminal available. Instead of connecting to a serial
port, they usually connect to a network like Ethernet.
Instead of being relegated to text-only applications, they
can display any &xorg;
application.This chapter does not cover the setup, configuration,
or use of X terminals.Terminal ConfigurationThis section describes how to configure a &os; system to
enable a login session on a serial terminal. It assumes that
the system recognizes the serial port to which the terminal is
connected and that the terminal is connected with the correct
cable.In &os;, init reads
/etc/ttys and starts a
getty process on the available terminals.
The getty process is responsible for
reading a login name and starting the login
program. The ports on the &os; system which allow logins are
listed in /etc/ttys. For example, the
first virtual console, ttyv0, has an
entry in this file, allowing logins on the console. This file
also contains entries for the other virtual consoles, serial
ports, and pseudo-ttys. For a hardwired terminal, the serial
port's /dev entry is listed without the
/dev part. For example,
/dev/ttyv0 is listed as
ttyv0.The default /etc/ttys configures
support for the first four serial ports,
ttyu0 through
ttyu3:ttyu0 "/usr/libexec/getty std.9600" dialup off secure
ttyu1 "/usr/libexec/getty std.9600" dialup off secure
ttyu2 "/usr/libexec/getty std.9600" dialup off secure
ttyu3 "/usr/libexec/getty std.9600" dialup off secureWhen attaching a terminal to one of those ports, modify
the default entry to set the required speed and terminal type,
to turn the device on and, if needed, to
change the port's secure setting. If the
terminal is connected to another port, add an entry for the
port. configures two terminals in
/etc/ttys. The first entry configures a
Wyse-50 connected to COM2. The second
entry configures an old computer running
Procomm terminal software emulating
a VT-100 terminal. The computer is connected to the sixth
serial port on a multi-port serial card.Configuring Terminal Entriesttyu1 "/usr/libexec/getty std.38400" wy50 on insecure
ttyu5 "/usr/libexec/getty std.19200" vt100 on insecureThe first field specifies the device name of the
serial terminal.The second field tells getty to
initialize and open the line, set the line speed, prompt
for a user name, and then execute the
login program. The optional
getty type configures
characteristics on the terminal line, like
bps rate and parity. The available
getty types are listed in
/etc/gettytab. In almost all
cases, the getty types that start with
std will work for hardwired terminals
as these entries ignore parity. There is a
std entry for each
bps rate from 110 to 115200. Refer
to &man.gettytab.5; for more information.When setting the getty type, make sure to match the
communications settings used by the terminal. For this
example, the Wyse-50 uses no parity and connects at
38400 bps. The computer uses no parity and
connects at 19200 bps.The third field is the type of terminal. For
dial-up ports, unknown or
dialup is typically used since users
may dial up with practically any type of terminal or
software. Since the terminal type does not change for
hardwired terminals, a real terminal type from
/etc/termcap can be specified. For
this example, the Wyse-50 uses the real terminal type
while the computer running
Procomm is set to emulate a
VT-100.The fourth field specifies if the port should be
enabled. To enable logins on this port, this field must
be set to on.The final field is used to specify whether the port
is secure. Marking a port as secure
means that it is trusted enough to allow root to login from that
port. Insecure ports do not allow root logins. On an
insecure port, users must login from unprivileged
accounts and then use su or a similar
mechanism to gain superuser privileges, as described in
. For security
reasons, it is recommended to change this setting to
insecure.After making any changes to
/etc/ttys, send a SIGHUP (hangup) signal
to the init process to force it to re-read
its configuration file:&prompt.root; kill -HUP 1Since init is always the first process
run on a system, it always has a process ID
of 1.If everything is set up correctly, all cables are in
place, and the terminals are powered up, a
getty process should now be running on each
terminal and login prompts should be available on each
terminal.Troubleshooting the ConnectionEven with the most meticulous attention to detail,
something could still go wrong while setting up a terminal.
Here is a list of common symptoms and some suggested
fixes.If no login prompt appears, make sure the terminal is
plugged in and powered up. If it is a personal computer
acting as a terminal, make sure it is running terminal
emulation software on the correct serial port.Make sure the cable is connected firmly to both the
terminal and the &os; computer. Make sure it is the right
kind of cable.Make sure the terminal and &os; agree on the
bps rate and parity settings. For a video
display terminal, make sure the contrast and brightness
controls are turned up. If it is a printing terminal, make
sure paper and ink are in good supply.Use ps to make sure that a
getty process is running and serving the
terminal. For example, the following listing shows that a
getty is running on the second serial port,
ttyu1, and is using the
std.38400 entry in
/etc/gettytab:&prompt.root; ps -axww|grep ttyu
22189 d1 Is+ 0:00.03 /usr/libexec/getty std.38400 ttyu1If no getty process is running, make
sure the port is enabled in /etc/ttys.
Remember to run kill -HUP 1 after modifying
/etc/ttys.If the getty process is running but the
terminal still does not display a login prompt, or if it
displays a prompt but will not accept typed input, the
terminal or cable may not support hardware handshaking. Try
changing the entry in /etc/ttys from
std.38400 to
3wire.38400, then run kill -HUP
1 after modifying /etc/ttys.
The 3wire entry is similar to
std, but ignores hardware handshaking. The
baud rate may need to be reduced or software flow control
enabled when using 3wire to prevent buffer
overflows.If garbage appears instead of a login prompt, make sure
the terminal and &os; agree on the bps rate
and parity settings. Check the getty
processes to make sure the correct
getty type is in use. If not, edit
/etc/ttys and run kill
-HUP 1.If characters appear doubled and the password appears when
typed, switch the terminal, or the terminal emulation
software, from half duplex or local
echo to full duplex.Dial-in ServiceGuyHelmerContributed by SeanKellyAdditions by dial-in serviceConfiguring a &os; system for dial-in service is similar to
configuring terminals, except that modems are used instead of
terminal devices. &os; supports both external and internal
modems.External modems are more convenient because they often can
be configured via parameters stored in non-volatile
RAM and they usually provide lighted
indicators that display the state of important
RS-232 signals, indicating whether the modem
is operating properly.Internal modems usually lack non-volatile
RAM, so their configuration may be limited to
setting DIP switches. If the internal modem
has any signal indicator lights, they are difficult to view when
the system's cover is in place.modemWhen using an external modem, a proper cable is needed. A
standard RS-232C serial cable should
suffice.&os; needs the RTS and
CTS signals for flow control at speeds above
2400 bps, the CD signal to detect when a
call has been answered or the line has been hung up, and the
DTR signal to reset the modem after a session
is complete. Some cables are wired without all of the needed
signals, so if a login session does not go away when the line
hangs up, there may be a problem with the cable. Refer to for more information about these
signals.Like other &unix;-like operating systems, &os; uses the
hardware signals to find out when a call has been answered or a
line has been hung up and to hangup and reset the modem after a
call. &os; avoids sending commands to the modem or watching for
status reports from the modem.&os; supports the NS8250,
NS16450, NS16550, and
NS16550A-based RS-232C
(CCITT V.24) communications interfaces. The
8250 and 16450 devices have single-character buffers. The 16550
device provides a 16-character buffer, which allows for better
system performance. Bugs in plain 16550 devices prevent the use
of the 16-character buffer, so use 16550A devices if possible.
Because single-character-buffer devices require more work by the
operating system than the 16-character-buffer devices,
16550A-based serial interface cards are preferred. If the
system has many active serial ports or will have a heavy load,
16550A-based cards are better for low-error-rate
communications.The rest of this section demonstrates how to configure a
modem to receive incoming connections, how to communicate with
the modem, and offers some troubleshooting tips.Modem ConfigurationgettyAs with terminals, init spawns a
getty process for each configured serial
port used for dial-in connections. When a user dials the
modem's line and the modems connect, the Carrier
Detect signal is reported by the modem. The kernel
notices that the carrier has been detected and instructs
getty to open the port and display a
login: prompt at the specified initial line
speed. In a typical configuration, if garbage characters are
received, usually due to the modem's connection speed being
different than the configured speed, getty
tries adjusting the line speeds until it receives reasonable
characters. After the user enters their login name,
getty executes login,
which completes the login process by asking for the user's
password and then starting the user's shell./usr/bin/loginThere are two schools of thought regarding dial-up modems.
One configuration method is to set the modems and systems so
that no matter at what speed a remote user dials in, the
dial-in RS-232 interface runs at a locked
speed. The benefit of this configuration is that the remote
user always sees a system login prompt immediately. The
downside is that the system does not know what a user's true
data rate is, so full-screen programs like
Emacs will not adjust their
screen-painting methods to make their response better for
slower connections.The second method is to configure the
RS-232 interface to vary its speed based on
the remote user's connection speed. Because
getty does not understand any particular
modem's connection speed reporting, it gives a
login: message at an initial speed and
watches the characters that come back in response. If the
user sees junk, they should press Enter until
they see a recognizable prompt. If the data rates do not
match, getty sees anything the user types
as junk, tries the next speed, and gives the
login: prompt again. This procedure normally
only takes a keystroke or two before the user sees a good
prompt. This login sequence does not look as clean as the
locked-speed method, but a user on a low-speed connection
should receive better interactive response from full-screen
programs.When locking a modem's data communications rate at a
particular speed, no changes to
/etc/gettytab should be needed. However,
for a matching-speed configuration, additional entries may be
required in order to define the speeds to use for the modem.
This example configures a 14.4 Kbps modem with a top
interface speed of 19.2 Kbps using 8-bit, no parity
connections. It configures getty to start
the communications rate for a V.32bis connection at
19.2 Kbps, then cycles through 9600 bps,
2400 bps, 1200 bps, 300 bps, and back to
19.2 Kbps. Communications rate cycling is implemented
with the nx= (next table) capability. Each
line uses a tc= (table continuation) entry
to pick up the rest of the settings for a particular data
rate.#
# Additions for a V.32bis Modem
#
um|V300|High Speed Modem at 300,8-bit:\
:nx=V19200:tc=std.300:
un|V1200|High Speed Modem at 1200,8-bit:\
:nx=V300:tc=std.1200:
uo|V2400|High Speed Modem at 2400,8-bit:\
:nx=V1200:tc=std.2400:
up|V9600|High Speed Modem at 9600,8-bit:\
:nx=V2400:tc=std.9600:
uq|V19200|High Speed Modem at 19200,8-bit:\
:nx=V9600:tc=std.19200:For a 28.8 Kbps modem, or to take advantage of
compression on a 14.4 Kbps modem, use a higher
communications rate, as seen in this example:#
# Additions for a V.32bis or V.34 Modem
# Starting at 57.6 Kbps
#
vm|VH300|Very High Speed Modem at 300,8-bit:\
:nx=VH57600:tc=std.300:
vn|VH1200|Very High Speed Modem at 1200,8-bit:\
:nx=VH300:tc=std.1200:
vo|VH2400|Very High Speed Modem at 2400,8-bit:\
:nx=VH1200:tc=std.2400:
vp|VH9600|Very High Speed Modem at 9600,8-bit:\
:nx=VH2400:tc=std.9600:
vq|VH57600|Very High Speed Modem at 57600,8-bit:\
:nx=VH9600:tc=std.57600:For a slow CPU or a heavily loaded
system without 16550A-based serial ports, this configuration
may produce siosilo errors at 57.6 Kbps./etc/ttysThe configuration of /etc/ttys is
similar to , but a different
argument is passed to getty and
dialup is used for the terminal type.
Replace xxx with the process
init will run on the device:ttyu0 "/usr/libexec/getty xxx" dialup onThe dialup terminal type can be
changed. For example, setting vt102 as the
default terminal type allows users to use
VT102 emulation on their remote
systems.For a locked-speed configuration, specify the speed with
a valid type listed in /etc/gettytab.
This example is for a modem whose port speed is locked at
19.2 Kbps:ttyu0 "/usr/libexec/getty std.19200" dialup onIn a matching-speed configuration, the entry needs to
reference the appropriate beginning auto-baud
entry in /etc/gettytab. To continue the
example for a matching-speed modem that starts at
19.2 Kbps, use this entry:ttyu0 "/usr/libexec/getty V19200" dialup onAfter editing /etc/ttys, wait until
the modem is properly configured and connected before
signaling init:&prompt.root; kill -HUP 1rc filesrc.serialHigh-speed modems, like V.32,
V.32bis, and V.34
modems, use hardware (RTS/CTS) flow
control. Use stty to set the hardware flow
control flag for the modem port. This example sets the
crtscts flag on COM2's
dial-in and dial-out initialization devices:&prompt.root; stty -f /dev/ttyu1.init crtscts
&prompt.root; stty -f /dev/cuau1.init crtsctsTroubleshootingThis section provides a few tips for troubleshooting a
dial-up modem that will not connect to a &os; system.Hook up the modem to the &os; system and boot the system.
If the modem has status indication lights, watch to see
whether the modem's DTR indicator lights
when the login: prompt appears on the
system's console. If it lights up, that should mean that &os;
has started a getty process on the
appropriate communications port and is waiting for the modem
to accept a call.If the DTR indicator does not light,
login to the &os; system through the console and type
ps ax to see if &os; is running a
getty process on the correct port: 114 ?? I 0:00.10 /usr/libexec/getty V19200 ttyu0If the second column contains a d0
instead of a ?? and the modem has not
accepted a call yet, this means that getty
has completed its open on the communications port. This could
indicate a problem with the cabling or a misconfigured modem
because getty should not be able to open
the communications port until the carrier detect signal has
been asserted by the modem.If no getty processes are waiting to
open the port, double-check that the entry for the port is
correct in /etc/ttys. Also, check
/var/log/messages to see if there are
any log messages from init or
getty.Next, try dialing into the system. Be sure to use 8 bits,
no parity, and 1 stop bit on the remote system. If a prompt
does not appear right away, or the prompt shows garbage, try
pressing Enter about once per second. If
there is still no login: prompt,
try sending a BREAK. When using a
high-speed modem, try dialing again after locking the
dialing modem's interface speed.If there is still no login: prompt, check
/etc/gettytab again and double-check
that:The initial capability name specified in the entry in
/etc/ttys matches the name of a
capability in /etc/gettytab.Each nx= entry matches another
gettytab capability name.Each tc= entry matches another
gettytab capability name.If the modem on the &os; system will not answer, make
sure that the modem is configured to answer the phone when
DTR is asserted. If the modem seems to be
configured correctly, verify that the
DTR line is asserted by checking the
modem's indicator lights.If it still does not work, try sending an email
to the &a.questions; describing the modem and the
problem.Dial-out Servicedial-out serviceThe following are tips for getting the host to connect over
the modem to another computer. This is appropriate for
establishing a terminal session with a remote host.This kind of connection can be helpful to get a file on the
Internet if there are problems using PPP. If PPP is not
working, use the terminal session to FTP the needed file. Then
use zmodem to transfer it to the machine.Using a Stock Hayes ModemA generic Hayes dialer is built into
tip. Use at=hayes in
/etc/remote.The Hayes driver is not smart enough to recognize some of
the advanced features of newer modems messages like
BUSY, NO DIALTONE, or
CONNECT 115200. Turn those messages off
when using tip with
ATX0&W.The dial timeout for tip is 60
seconds. The modem should use something less, or else
tip will think there is a communication
problem. Try ATS7=45&W.Using AT Commands/etc/remoteCreate a direct entry in
/etc/remote. For example, if the modem
is hooked up to the first serial port,
/dev/cuau0, use the following
line:cuau0:dv=/dev/cuau0:br#19200:pa=noneUse the highest bps rate the modem
supports in the br capability. Then, type
tip cuau0 to connect to the modem.Or, use cu as root with the following
command:&prompt.root; cu -lline -sspeedline is the serial port, such
as /dev/cuau0, and
speed is the speed, such as
57600. When finished entering the AT
commands, type ~. to exit.The @ Sign Does Not WorkThe @ sign in the phone number
capability tells tip to look in
/etc/phones for a phone number. But, the
@ sign is also a special character in
capability files like /etc/remote, so it
needs to be escaped with a backslash:pn=\@Dialing from the Command LinePut a generic entry in
/etc/remote. For example:tip115200|Dial any phone number at 115200 bps:\
:dv=/dev/cuau0:br#115200:at=hayes:pa=none:du:
tip57600|Dial any phone number at 57600 bps:\
:dv=/dev/cuau0:br#57600:at=hayes:pa=none:du:This should now work:&prompt.root; tip -115200 5551234Users who prefer cu over
tip, can use a generic
cu entry:cu115200|Use cu to dial any number at 115200bps:\
:dv=/dev/cuau1:br#57600:at=hayes:pa=none:du:and type:&prompt.root; cu 5551234 -s 115200Setting the bps RatePut in an entry for tip1200 or
cu1200, but go ahead and use whatever
bps rate is appropriate with the
br capability.
tip thinks a good default is 1200 bps
which is why it looks for a tip1200 entry.
1200 bps does not have to be used, though.Accessing a Number of Hosts Through a Terminal
ServerRather than waiting until connected and typing
CONNECT host
each time, use tip's cm
capability. For example, these entries in
/etc/remote will let you type
tip pain or tip muffin
to connect to the hosts pain or
muffin, and tip
deep13 to connect to the terminal server.pain|pain.deep13.com|Forrester's machine:\
:cm=CONNECT pain\n:tc=deep13:
muffin|muffin.deep13.com|Frank's machine:\
:cm=CONNECT muffin\n:tc=deep13:
deep13:Gizmonics Institute terminal server:\
:dv=/dev/cuau2:br#38400:at=hayes:du:pa=none:pn=5551234:Using More Than One Line with
tipThis is often a problem where a university has several
modem lines and several thousand students trying to use
them.Make an entry in /etc/remote and use
@ for the pn
capability:big-university:\
:pn=\@:tc=dialout
dialout:\
:dv=/dev/cuau3:br#9600:at=courier:du:pa=none:Then, list the phone numbers in
/etc/phones:big-university 5551111
big-university 5551112
big-university 5551113
big-university 5551114tip will try each number in the listed
order, then give up. To keep retrying, run
tip in a while
loop.Using the Force CharacterCtrlP is the default force character,
used to tell tip that the next character is
literal data. The force character can be set to any other
character with the ~s escape, which means
set a variable.Type
~sforce=single-char
followed by a newline. single-char
is any single character. If
single-char is left out, then the
force character is the null character, which is accessed by
typing
Ctrl2
or CtrlSpace. A pretty good value for
single-char is
ShiftCtrl6, which is only used on some terminal
servers.To change the force character, specify the following in
~/.tiprc:force=single-charUpper Case CharactersThis happens when
CtrlA is pressed, which is tip's
raise character, specially designed for people
with broken caps-lock keys. Use ~s to set
raisechar to something reasonable. It can
be set to be the same as the force character, if neither
feature is used.Here is a sample ~/.tiprc for
Emacs users who need to type
Ctrl2 and CtrlA:force=^^
raisechar=^^The ^^ is
ShiftCtrl6.File Transfers with tipWhen talking to another &unix;-like operating system,
files can be sent and received using ~p
(put) and ~t (take). These commands run
cat and echo on the
remote system to accept and send files. The syntax is:~plocal-fileremote-file~tremote-filelocal-fileThere is no error checking, so another protocol, like
zmodem, should probably be used.Using zmodem with
tip?To receive files, start the sending program on the remote
end. Then, type ~C rz to begin receiving
them locally.To send files, start the receiving program on the remote
end. Then, type ~C sz
files to send them to the
remote system.Setting Up the Serial ConsoleKazutakaYOKOTAContributed by BillPaulBased on a document by serial console&os; has the ability to boot a system with a dumb
terminal on a serial port as a console. This configuration is
useful for system administrators who wish to install &os; on
machines that have no keyboard or monitor attached, and
developers who want to debug the kernel or device
drivers.As described in , &os; employs a three
stage bootstrap. The first two stages are in the boot block
code which is stored at the beginning of the &os; slice on the
boot disk. The boot block then loads and runs the boot loader
as the third stage code.In order to set up booting from a serial console, the boot
block code, the boot loader code, and the kernel need to be
configured.Quick Serial Console ConfigurationThis section provides a fast overview of setting up the
serial console. This procedure can be used when the dumb
terminal is connected to COM1.Configuring a Serial Console on
COM1Connect the serial cable to
COM1 and the controlling
terminal.To configure boot messages to display on the serial
console, issue the following command as the
superuser:
- &prompt.root; echo 'console="comconsole"' >> /boot/loader.conf
+ &prompt.root; sysrc -f /boot/loader.conf console=comconsoleEdit /etc/ttys and change
off to on and
dialup to vt100 for
the ttyu0 entry. Otherwise, a
password will not be required to connect via the serial
console, resulting in a potential security hole.Reboot the system to see if the changes took
effect.If a different configuration is required, see the next
section for a more in-depth configuration explanation.In-Depth Serial Console ConfigurationThis section provides a more detailed explanation of the
steps needed to setup a serial console in &os;.Configuring a Serial ConsolePrepare a serial cable.null-modem cableUse either a null-modem cable or a standard serial
cable and a null-modem adapter. See for a discussion on serial
cables.Unplug the keyboard.Many systems probe for the keyboard during the
Power-On Self-Test (POST) and will
generate an error if the keyboard is not detected. Some
machines will refuse to boot until the keyboard is plugged
in.If the computer complains about the error, but boots
anyway, no further configuration is needed.If the computer refuses to boot without a keyboard
attached, configure the BIOS so that it
ignores this error. Consult the motherboard's manual for
details on how to do this.Try setting the keyboard to Not
installed in the BIOS.
This setting tells the BIOS not to
probe for a keyboard at power-on so it should not
complain if the keyboard is absent. If that option is
not present in the BIOS, look for an
Halt on Error option instead. Setting
this to All but Keyboard or to No
Errors will have the same effect.If the system has a &ps2; mouse, unplug it as well.
&ps2; mice share some hardware with the keyboard and
leaving the mouse plugged in can fool the keyboard probe
into thinking the keyboard is still there.While most systems will boot without a keyboard,
quite a few will not boot without a graphics adapter.
Some systems can be configured to boot with no graphics
adapter by changing the graphics adapter
setting in the BIOS configuration to
Not installed. Other systems do not
support this option and will refuse to boot if there is
no display hardware in the system. With these machines,
leave some kind of graphics card plugged in, even if it
is just a junky mono board. A monitor does not need to
be attached.Plug a dumb terminal, an old computer with a modem
program, or the serial port on another &unix; box into the
serial port.Add the appropriate hint.sio.*
entries to /boot/device.hints for the
serial port. Some multi-port cards also require kernel
configuration options. Refer to &man.sio.4; for the
required options and device hints for each supported
serial port.Create boot.config in the root
directory of the a partition on the
boot drive.This file instructs the boot block code how to boot
the system. In order to activate the serial console, one
or more of the following options are needed. When using
multiple options, include them all on the same
line:Toggles between the internal and serial
consoles. Use this to switch console devices. For
instance, to boot from the internal (video) console,
use to direct the boot loader
and the kernel to use the serial port as its console
device. Alternatively, to boot from the serial
port, use to tell the boot
loader and the kernel to use the video display as
the console instead.Toggles between the single and dual console
configurations. In the single configuration, the
console will be either the internal console (video
display) or the serial port, depending on the state
of . In the dual console
configuration, both the video display and the
serial port will become the console at the same
time, regardless of the state of
. However, the dual console
configuration takes effect only while the boot
block is running. Once the boot loader gets
control, the console specified by
becomes the only
console.Makes the boot block probe the keyboard. If no
keyboard is found, the and
options are automatically
set.Due to space constraints in the current
version of the boot blocks, is
capable of detecting extended keyboards only.
Keyboards with less than 101 keys and without F11
and F12 keys may not be detected. Keyboards on
some laptops may not be properly found because of
this limitation. If this is the case, do not use
.Use either to select the console
automatically or to activate the
serial console. Refer to &man.boot.8; and
&man.boot.config.5; for more details.The options, except for , are
passed to the boot loader. The boot loader will
determine whether the internal video or the serial port
should become the console by examining the state of
. This means that if
is specified but
is not specified in /boot.config, the
serial port can be used as the console only during the
boot block as the boot loader will use the internal video
display as the console.Boot the machine.When &os; starts, the boot blocks echo the contents of
/boot.config to the console. For
example:/boot.config: -P
Keyboard: noThe second line appears only if is
in /boot.config and indicates the
presence or absence of the keyboard. These messages go
to either the serial or internal console, or both,
depending on the option in
/boot.config:OptionsMessage goes tononeinternal consoleserial consoleserial and internal consolesserial and internal consoles, keyboard presentinternal console, keyboard absentserial consoleAfter the message, there will be a small pause before
the boot blocks continue loading the boot loader and
before any further messages are printed to the console.
Under normal circumstances, there is no need to interrupt
the boot blocks, but one can do so in order to make sure
things are set up correctly.Press any key, other than Enter, at
the console to interrupt the boot process. The boot
blocks will then prompt for further action:>> FreeBSD/i386 BOOT
Default: 0:ad(0,a)/boot/loader
boot:Verify that the above message appears on either the
serial or internal console, or both, according to the
options in /boot.config. If the
message appears in the correct console, press
Enter to continue the boot
process.If there is no prompt on the serial terminal,
something is wrong with the settings. Enter
then Enter or
Return to tell the boot block (and then
the boot loader and the kernel) to choose the serial port
for the console. Once the system is up, go back and check
what went wrong.During the third stage of the boot process, one can still
switch between the internal console and the serial console by
setting appropriate environment variables in the boot loader.
See &man.loader.8; for more
information.This line in /boot/loader.conf or
/boot/loader.conf.local configures the
boot loader and the kernel to send their boot messages to
the serial console, regardless of the options in
/boot.config:console="comconsole"That line should be the first line of
/boot/loader.conf so that boot messages
are displayed on the serial console as early as
possible.If that line does not exist, or if it is set to
console="vidconsole", the boot loader and
the kernel will use whichever console is indicated by
in the boot block. See
&man.loader.conf.5; for more information.At the moment, the boot loader has no option
equivalent to in the boot block, and
there is no provision to automatically select the internal
console and the serial console based on the presence of the
keyboard.While it is not required, it is possible to provide a
login prompt over the serial line. To
configure this, edit the entry for the serial port in
/etc/ttys using the instructions in
. If the speed of the serial
port has been changed, change std.9600 to
match the new setting.Setting a Faster Serial Port SpeedBy default, the serial port settings are 9600 baud, 8
bits, no parity, and 1 stop bit. To change the default
console speed, use one of the following options:Edit /etc/make.conf and set
BOOT_COMCONSOLE_SPEED to the new
console speed. Then, recompile and install the boot
blocks and the boot loader:&prompt.root; cd /sys/boot
&prompt.root; make clean
&prompt.root; make
&prompt.root; make installIf the serial console is configured in some other way
than by booting with , or if the serial
console used by the kernel is different from the one used
by the boot blocks, add the following option, with the
desired speed, to a custom kernel configuration file and
compile a new kernel:options CONSPEED=19200Add the
boot
option to /boot.config, replacing
19200 with the speed to
use.Add the following options to
/boot/loader.conf. Replace
115200 with the speed to
use.boot_multicons="YES"
boot_serial="YES"
comconsole_speed="115200"
console="comconsole,vidconsole"Entering the DDB Debugger from the Serial LineTo configure the ability to drop into the kernel debugger
from the serial console, add the following options to a custom
kernel configuration file and compile the kernel using the
instructions in . Note that
while this is useful for remote diagnostics, it is also
dangerous if a spurious BREAK is generated on the serial port.
Refer to &man.ddb.4; and &man.ddb.8; for more information
about the kernel debugger.options BREAK_TO_DEBUGGER
options DDB