doc/en_US.ISO8859-1/articles/formatting-media/article.sgml
Doug White b443f02aca Remove text that is clearly wrong after the conversion. Someone stuck
root prompts in front of the commands and removed it from the comment (as they
should be), but the paragraph above says that lines starting with #
are comments. :)

Submitted by:	Ilia Chipitsine <ilia@cgilh.chel.su>
1999-10-30 18:10:14 +00:00

603 lines
18 KiB
Text

<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook V3.1-Based Extension//EN" [
<!ENTITY % man PUBLIC "-//FreeBSD//ENTITIES DocBook Manual Page Entities//EN">
%man;
]>
<!-- $FreeBSD: doc/en_US.ISO_8859-1/articles/formatting-media/article.sgml,v 1.12 1999/10/10 19:21:10 jhb Exp $ -->
<article>
<artheader>
<title>Formatting Media For Use With FreeBSD 2.2-RELEASE</title>
<subtitle>A Tutorial</subtitle>
<authorgroup>
<author>
<firstname>Doug</firstname>
<surname>White</surname>
<affiliation>
<address>
<email>dwhite@resnet.uoregon.edu</email>
</address>
</affiliation>
</author>
</authorgroup>
<pubdate>March 1997</pubdate>
<abstract>
<para>This document describes how to slice, partition, and
format hard disk drives and similar media for use with
FreeBSD. The examples given have been tested under FreeBSD
2.2-GAMMA and may work for other releases.</para>
</abstract>
</artheader>
<sect1>
<title>Introduction & Definitions</title>
<sect2>
<title>Overview</title>
<para>Successfully adding disks to an existing system is the
mark of an experienced system administrator. Slicing,
partitioning, and adding disks requires a careful dance of
proper command and name syntax. One slipped finger and an
entire disk could disappear in seconds. This document is
written in an attempt to simplify this process and avoid
accidents. Thankfully, enhancements to existing tools
(notably sysinstall) have greatly improved this process in
recent releases of FreeBSD.</para>
<para>There are two possible modes of disk formatting:</para>
<itemizedlist>
<listitem>
<para><firstterm>compatibility mode</firstterm>: Arranging a
disk so that it has a slice table for use with other
operating systems.</para>
</listitem>
<listitem>
<para><firstterm>dangerously dedicated mode</firstterm>:
Formatting a disk with no slice table. This makes the
process of adding disks easier, however non-FreeBSD
operating systems may not accept the disk.</para>
</listitem>
</itemizedlist>
<para>For most cases, dedicated mode is the easiest to set up
and use in existing systems, as a new disk is usually
dedicated entirely to FreeBSD. However, compatibility mode
insures optimum interoperability with future installations at
a cost of increased complexity.</para>
<para>In addition to selecting the mode, two methods of slicing
the disk are available. One is using the system installation
tool <command>/stand/sysinstall</command>. 2.1.7-RELEASE and
later versions of <command>sysinstall</command> contain code
to ease setup of disks during normal system operation, mainly
allowing access to the Label and Partition editors and a Write
feature which will update just the selected disk and slice
without affecting other disks. The other method is running
the tools manually from a root command line. For dangerously
dedicated mode, only three or four commands are involved while
<command>sysinstall</command> requires some
manipulation.</para>
</sect2>
<sect2>
<title>Definitions</title>
<para>UNIX disk management over the centuries has invented many
new definitions for old words. The following glossary covers
the definitions used in this document and (hopefully) for
FreeBSD in general.</para>
<!-- I'm tempted to use GLOSSARY here but will resort to a list for
now. -->
<itemizedlist>
<listitem>
<para>compatibility mode: Arranging a disk so that it has a
slice table for use with other operating systems. Oppose
dangerously dedicated mode.</para>
</listitem>
<listitem>
<para>dangerously dedicated mode: Formatting a disk with no
slice table. This makes the process of adding disks
easier, however non-FreeBSD operating systems may not
accept the disk. Oppose compatibility mode.</para>
</listitem>
<listitem>
<para>disk: A circular disc, covered with magnetic or
similarly manipulable material, spun by a motor under a
head. Data is stored on the disk by changing the pattern
of magnetism on the disc, which can be later read. Hard
disks, CD-ROMs, Magneto-optical,and Zip/Jaz removables are
examples of disks.</para>
</listitem>
<listitem>
<para>slice: A division of a disk. Up to four slices are
permitted on one disk in the PC standard. Slices are
composed of contiguous sectors. Slices are recorded in a
<quote>slice table</quote> used by the system BIOS to
locate bootable partitions. The slice table is usually
called the Partition Table in DOS parlance. Maintained by
the fdisk utility.</para>
</listitem>
<listitem>
<para>partition: A division of a slice. Usually used in
reference to divisions of the FreeBSD slice of a disk.
Each filesystem and swap area on a disk resides in a
partition. Maintained using the disklabel utility.</para>
</listitem>
<listitem>
<para>sector: Smallest subdivision of a disk. One sector
usually represents 512 bytes of data.</para>
</listitem>
</itemizedlist>
</sect2>
<sect2>
<title>Warnings & Pitfalls</title>
<para>Building disks is not something to take lightly. It is
quite possible to destroy the contents of other disks in your
system if the proper precautions are not taken.</para>
<para><emphasis>Check your work carefully.</> It is very simple
to destroy the incorrect disk when working with these
commands. When in doubt consult the kernel boot output for
the proper device.</para>
<para>Needless to say, we are not responsible for any damage to
any data or hardware that you may experience. You work at
your own risk!</para>
</sect2>
<sect2>
<title>Zip, Jaz, and Other Removables</title>
<para>Removable disks can be formatted in the same way as normal
hard disks. It is essential to have the disk drive connected
to the system and a disk placed in the drive during startup,
so the kernel can determine the drive's geometry. Check the
<command>dmesg</command> output and make sure your device and
the disk's size is listed. If the kernel reports
<informalexample>
<screen>Can't get the size
</screen>
</informalexample>
then the disk was not in the drive. In this case, you will
need to restart the machine before attempting to format
disks.</para>
</sect2>
</sect1>
<sect1>
<title>Formatting Disks in Dedicated Mode</title>
<sect2>
<title>Introduction</title>
<para>This section details how to make disks that are totally
dedicated to FreeBSD. Remember, dedicated mode disks cannot
be booted by the PC architecture.</para>
</sect2>
<sect2>
<title>Making Dedicated Mode Disks using Sysinstall</title>
<para><command>/stand/sysinstall</command>, the system
installation utility, has been expanded in recent versions to
make the process of dividing disks properly a less tiring
affair. The fdisk and disklabel editors built into sysinstall
are GUI tools that remove much of the confusion from slicing
disks. For FreeBSD versions 2.1.7 and later, this is perhaps
the simplest way to slice disks.</para>
<procedure>
<step>
<para>Start sysinstall as root by typing
<informalexample>
<screen>&prompt.root; <userinput>/stand/sysinstall</userinput>
</screen>
</informalexample>
from the command prompt.</para>
</step>
<step>
<para>Select <command>Index</command>.</para>
</step>
<step>
<para>Select <command>Partition</command>.</para>
</step>
<step>
<para>Select the disk to edit with arrow keys and
<keycap>SPACE</keycap>.</para>
</step>
<step>
<para>If you are using this entire disk for FreeBSD, select
<command>A</command>.</para>
</step>
<step>
<para>When asked:
<informalexample>
<screen>Do you want to do this with a true partition entry so as to remain
cooperative with any future possible operating systems on the
drive(s)?
</screen>
</informalexample>
answer <command>No</command>.</para>
</step>
<step>
<para>When asked if you still want to do this, answer
<command>Yes</command>.</para>
</step>
<step>
<para>Select <command>Write</command>.</para>
</step>
<step>
<para>When warned about Writing on installed systems, answer
<command>Yes</command>.</para>
</step>
<step>
<para><command>Quit</command>the FDISK Editor and
<keycap>ESCAPE</keycap> back to the Index menu.</para>
</step>
<step>
<para>Select <command>Label</command> from the Index
menu.</para>
</step>
<step>
<para>Label as desired. For a single partition, enter
<command>C</command> to Create a partition, accept the
default size, partition type Filesystem, and a mountpoint
(which isn't used).</para>
</step>
<step>
<para>Enter <command>W</command> when done and confirm to
continue. The filesystem will be newfs'd for you, unless
you select otherwise (for news partitions you'll want to
do this!). You'll get the error:
<informalexample>
<screen>Error mounting /mnt/dev/wd2s1e on /mnt/blah : No such file or directory
</screen>
</informalexample>
Ignore.</para>
</step>
<step>
<para>Exit out by repeatedly pressing
<keycap>ESCAPE</keycap>.</para>
</step>
</procedure>
</sect2>
<sect2>
<title>Making Dedicated Mode Disks Using the Command Line</title>
<para>Execute the following commands, replacing wd2 with the
disk name.</para>
<informalexample>
<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/rwd2 count=2</userinput>
&prompt.root; <userinput>disklabel /dev/rwd2 | disklabel -B -R -r wd2 /dev/stdin</userinput>
<lineannotation>We only want one partition, so using slice 'c' should be fine:</lineannotation>
&prompt.root; <userinput>newfs /dev/rwd2c</userinput>
</screen>
</informalexample>
<para>If you need to edit the disklabel to create multiple
partitions (such as swap), use the following: </para>
<informalexample>
<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/rwd2 count=2</userinput>
&prompt.root; <userinput>disklabel /dev/r$d > /tmp/label</userinput>
<lineannotation>Edit disklabel to add partitions:</lineannotation>
&prompt.root; <userinput>vi /tmp/label</userinput>
&prompt.root; <userinput>disklabel -B -R -r wd2 /tmp/label</userinput>
<lineannotation>newfs partitions appropriately</lineannotation>
</screen>
</informalexample>
<para>Your disk is now ready for use.</para>
</sect2>
</sect1>
<sect1>
<title>Making Compatibility Mode Disks</title>
<sect2>
<title>Introduction</title>
<para>The command line is the easiest way to make dedicated
disks, and the worst way to make compatibility disks. The
command-line fdisk utility requires higher math skills and an
in-depth understanding of the slice table, which is more than
most people want to deal with. Use sysinstall for
compatibility disks, as described below.</para>
</sect2>
<sect2>
<title>Making Compatibility Mode Disks Using Sysinstall</title>
<procedure>
<step>
<para>Start sysinstall as root by typing
<informalexample>
<screen>&prompt.root; <userinput>/stand/sysinstall</>
</screen>
</informalexample>
from the command prompt.</para>
</step>
<step>
<para>Select <command>Index</command>.</para>
</step>
<step>
<para>Select <command>Partition</command>.</para>
</step>
<step>
<para>Select the disk to edit with arrow keys and
<keycap>SPACE</keycap>.</para>
</step>
<step>
<para>If you are using this entire disk for FreeBSD, select
<command>A</command>.</para>
</step>
<step>
<para>When asked:
<informalexample>
<screen>Do you want to do this with a true partition entry so as to remain
cooperative with any future possible operating systems on the
drive(s)?
</screen>
</informalexample>
answer <command>yes</command>.</para>
</step>
<step>
<para>Select <command>Write</command>.</para>
</step>
<step>
<para>When asked to install the boot manager, select None
with <keycap>SPACE</keycap> then hit
<keycap>ENTER</keycap> for OK.</para>
</step>
<step>
<para><command>Quit</command> the FDISK Editor.</para>
</step>
<step>
<para>You'll be asked about the boot manager, select
<command>None</command> again. </para>
</step>
<step>
<para>Select <command>Label</command> from the Index
menu.</para>
</step>
<step>
<para>Label as desired. For a single partition, accept the
default size, type filesystem, and a mountpoint (which
isn't used).</para>
</step>
<step>
<para>The filesystem will be newfs'd for you, unless you
select otherwise (for news partitions you'll want to do
this!). You'll get the error:
<informalexample>
<screen>Error mounting /mnt/dev/wd2s1e on /mnt/blah : No such file or directory
</screen>
</informalexample>
Ignore.</para>
</step>
<step>
<para>Exit out by repeatedly pressing
<keycap>ESCAPE</keycap>.</para>
</step>
</procedure>
<para>Your new disk is now ready for use.</para>
</sect2>
</sect1>
<sect1>
<title>Other Disk Operations</title>
<sect2>
<title>Adding Swap Space</title>
<para>As a system grows, it's need for swap space can also grow.
Although adding swap space to existing disks is very
difficult, a new disk can be partitioned with additional swap
space.</para>
<para>To add swap space when adding a disk to a system:</para>
<procedure>
<step>
<para>When partitioning the disk, edit the disklabel and
allocate the amount of swap space to add in partition `b'
and the remainder in another partition, such as `a' or
`e'. The size is given in 512 byte blocks.</para>
</step>
<step>
<para>When newfsing the drive, do NOT newfs the `c'
partition. Instead, newfs the partition where the
non-swap space lies.</para>
</step>
<step>
<para>Add an entry to <filename>/etc/fstab</filename> as
follows:</para>
<informalexample>
<programlisting>/dev/wd0b none swap sw 0 0
</programlisting>
</informalexample>
<para>Change /dev/wd0b to the device of the newly added
space.</para>
</step>
<step>
<para>To make the new space immediately available, use the
<command>swapon</command> command.
<informalexample>
<screen>&prompt.root; <userinput>swapon /dev/sd0b</userinput>
swapon: added /dev/sd0b as swap space
</screen>
</informalexample>
</para>
</step>
</procedure>
</sect2>
<sect2>
<title>Copying the Contents of Disks</title>
<!-- Should have specific tag -->
<para>Submitted By: Renaud Waldura
(<email>renaud@softway.com</email>) </para>
<para>To move file from your original base disk to the fresh new
one, do:
<informalexample>
<screen>&prompt.root; <userinput>mount /dev/wd2 /mnt</userinput>
&prompt.root; <userinput>pax -r -w -p e /usr/home /mnt</userinput>
&prompt.root; <userinput>umount /mnt</userinput>
&prompt.root; <userinput>rm -rf /usr/home/*</userinput>
&prompt.root; <userinput>mount /dev/wd2 /usr/home</userinput>
</screen>
</informalexample>
</para>
</sect2>
<sect2>
<title>Creating Striped Disks using CCD</title>
<para>Commands Submitted By: Stan Brown
(<email>stanb@awod.com</email>) </para>
<para>The Concatenated Disk Driver, or CCD, allows you to treat
several identical disks as a single disk. Striping can result
in increased disk performance by distributing reads and writes
across the disks. See the &man.ccd.4; and &man.ccdconfig.8;
man pages or the <ulink
URL="http://stampede.cs.berkeley.edu/ccd/">CCD
Homepage</ulink> for further details.</para>
<para>To create a new CCD, execute the following commands. This
describes how to add three disks together; simply add or
remove devices as necessary. Remember that the disks to be
striped must be <emphasis>identical.</></para>
<para>Before executing these commands, make sure you add the line
<userinput>pseudo-device ccd 4</userinput>
to your kernel.</para>
<informalexample>
<screen>&prompt.root; <userinput>cd /dev ; sh MAKDEV ccd0</userinput>
&prompt.root; <userinput>disklabel -r -w sd0 auto</userinput>
&prompt.root; <userinput>disklabel -r -w sd1 auto</userinput>
&prompt.root; <userinput>disklabel -r -w sd2 auto</userinput>
&prompt.root; <userinput>disklabel -e sd0c</userinput>
<lineannotation>change type to 4.2BSD</lineannotation>
&prompt.root; <userinput>disklabel -e sd1c</userinput>
<lineannotation>change type to 4.2BSD</lineannotation>
&prompt.root; <userinput>disklabel -e sd2c</userinput>
<lineannotation>change type to 4.2BSD</lineannotation>
&prompt.root; <userinput>ccdconfig ccd0 32 0 /dev/sd0c /dev/sd1c /dev/sd2c</userinput>
&prompt.root; <userinput>newfs /dev/rccd0c</userinput>
</screen>
</informalexample>
<para>Now you can mount and use your CCD by referencing device
/dev/ccd0c.</para>
</sect2>
</sect1>
<sect1>
<title>Credits</title>
<para>The author would like to thank the following individuals for
their contributions to this project:</para>
<itemizedlist>
<listitem>
<para>Darryl Okahata
(<email>darrylo@hpnmhjw.sr.hp.com</email>) for his simple
dedicated mode setup documentation which I have used
repeatedly on freebsd-questions.</para>
</listitem>
<listitem>
<para>Jordan Hubbard (<email>jkh@FreeBSD.org</email>) for
making sysinstall useful for this type of task.</para>
</listitem>
<listitem>
<para>John Fieber (<email>jfieber@indiana.edu</email>) for
making information and examples of the DocBook DTD on which
this document is based.</para>
</listitem>
<listitem>
<para>Greg Lehey (<email>grog@FreeBSD.org</email>) for
checking my work and pointing out inaccuracies, as well as
miscellaneous support.</para>
</listitem>
</itemizedlist>
</sect1>
</article>