464 lines
		
	
	
	
		
			16 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			464 lines
		
	
	
	
		
			16 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| <!DOCTYPE BOOK PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
 | |
| <!-- $Id: diskformat.docb,v 1.4 1997-11-28 21:48:46 jfieber Exp $ -->
 | |
| <book>
 | |
| 
 | |
| <bookinfo>
 | |
| <bookbiblio>
 | |
| <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>
 | |
| </bookbiblio>
 | |
| </bookinfo>
 | |
| 
 | |
| <chapter>
 | |
| <title>Introduction & Definitions</title>
 | |
| 
 | |
| <sect1>
 | |
| <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:
 | |
| <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>
 | |
| 
 | |
| <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>
 | |
| </sect1>
 | |
| <sect1>
 | |
| <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>
 | |
| </sect1>
 | |
| 
 | |
| <sect1>
 | |
| <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>
 | |
| 
 | |
| </sect1>
 | |
| 
 | |
| <sect1>
 | |
| <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>
 | |
| </sect1>
 | |
| 
 | |
| </chapter>
 | |
| <chapter>
 | |
| <title>Formatting Disks in Dedicated Mode</title>
 | |
| 
 | |
| <sect1>
 | |
| <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>
 | |
| 
 | |
| </sect1>
 | |
| <sect1>
 | |
| <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>
 | |
| 
 | |
| <orderedlist>
 | |
| <listitem><para>Start sysinstall as root by typing 
 | |
| <informalexample>
 | |
| <screen><userinput>/stand/sysinstall</userinput></screen>
 | |
| </informalexample> 
 | |
| from the command prompt.</para></listitem>
 | |
| 
 | |
| <listitem><para>Select <command>Index</command>.</para></listitem>
 | |
| <listitem><para>Select <command>Partition</command>.</para></listitem>
 | |
| <listitem><para>Select the disk to edit with arrow keys and
 | |
| <keycap>SPACE</keycap>.</para>
 | |
| </listitem>
 | |
| <listitem><para>If you are using this entire disk for FreeBSD, select
 | |
| <command>A</command>.</para></listitem> 
 | |
| <listitem><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></listitem>
 | |
| <listitem><para>When asked if you still want to do this, answer
 | |
| <command>Yes</command>.</para></listitem> 
 | |
| <listitem><para>Select <command>Write</command>.</para></listitem>
 | |
| <listitem><para>When warned about Writing on installed systems, answer
 | |
| <command>Yes</command>.</para></listitem> 
 | |
| <listitem><para><command>Quit</command>the FDISK Editor and
 | |
| <keycap>ESCAPE</keycap> back to the Index menu.</para></listitem>
 | |
| <listitem><para>Select <command>Label</command> from the Index
 | |
| menu.</para></listitem>  
 | |
| <listitem><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></listitem> 
 | |
| <listitem><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></listitem>
 | |
| <listitem><para>Exit out by repeatedly pressing <keycap>ESCAPE</keycap>.</para></listitem>
 | |
| </orderedlist>
 | |
| 
 | |
| </sect1>
 | |
| <sect1>
 | |
| <title>Making Dedicated Mode Disks Using the Command Line</title>
 | |
| 
 | |
| 
 | |
| <para>Execute the following commands, replacing wd2 with the disk
 | |
| name.  Lines beginning with # are comments. </para>
 | |
| <informalexample>
 | |
| <screen>
 | |
| <userinput>  
 | |
|         dd if=/dev/zero of=/dev/rwd2 count=2
 | |
|         disklabel /dev/rwd2 | disklabel -B -R -r wd2 /dev/stdin
 | |
|         # We only want one partition, so using slice 'c' should be fine:
 | |
|         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>
 | |
| <userinput>
 | |
|         dd if=/dev/zero of=/dev/rwd2 count=2
 | |
|         disklabel /dev/r$d > /tmp/label
 | |
|         # Edit disklabel to add partitions:
 | |
|         vi /tmp/label
 | |
|         disklabel -B -R -r wd2 /tmp/label
 | |
|         # newfs partitions appropriately
 | |
| </userinput>
 | |
| </screen>
 | |
| </informalexample>
 | |
| 
 | |
| <para>Your disk is now ready for use.</para>
 | |
| 
 | |
| </sect1>
 | |
| </chapter>
 | |
| 
 | |
| <chapter>
 | |
| <title>Making Compatibility Mode Disks</title>
 | |
| 
 | |
| <sect1>
 | |
| <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>
 | |
| 
 | |
| </sect1>
 | |
| <sect1>
 | |
| 
 | |
| <title>Making Compatibility Mode Disks Using Sysinstall</title>
 | |
| 
 | |
| <orderedlist>
 | |
| <listitem><para>Start sysinstall as root by typing 
 | |
| <informalexample>
 | |
| <screen><userinput>/stand/sysinstall</></screen>
 | |
| </informalexample> 
 | |
| from the command prompt.</para></listitem>
 | |
| 
 | |
| <listitem><para>Select <command>Index</command>.</para> </listitem>
 | |
| <listitem><para>Select <command>Partition</command>.</para></listitem>
 | |
| <listitem><para>Select the disk to edit with arrow keys and
 | |
| <keycap>SPACE</keycap>.
 | |
| </para></listitem>
 | |
| <listitem><para>If you are using this entire disk for FreeBSD, select
 | |
| <command>A</command>.</para></listitem> 
 | |
| 
 | |
| <listitem><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></listitem>
 | |
| <listitem><para>Select <command>Write</command>.</para></listitem>
 | |
| <listitem><para>When asked to install the boot manager, select None with
 | |
| <keycap>SPACE</keycap> then hit <keycap>ENTER</keycap> for OK.</para></listitem>
 | |
| <listitem><para><command>Quit</command> the FDISK Editor.</para></listitem>
 | |
| <listitem><para>You'll be asked about the boot manager, select
 | |
| <command>None</command> 
 | |
| again. </para></listitem> 
 | |
| <listitem><para>Select <command>Label</command> from the Index
 | |
| menu.</para></listitem>  
 | |
| <listitem><para>Label as desired.  For a single partition, accept the
 | |
| default size, type filesystem, and a mountpoint (which isn't
 | |
| used).</para></listitem> 
 | |
| <listitem><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></listitem>
 | |
| <listitem><para>Exit out by repeatedly pressing <keycap>ESCAPE</keycap>.</para></listitem>
 | |
| </orderedlist>
 | |
| 
 | |
| <para>Your new disk is now ready for use.</para>
 | |
| 
 | |
| </sect1>
 | |
| </chapter>
 | |
| 
 | |
| <chapter>
 | |
| <title>Other Disk Operations</title>
 | |
| <sect1>
 | |
| <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:
 | |
| <orderedlist>
 | |
| <listitem><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></listitem>
 | |
| <listitem><para>When newfsing the drive, do NOT newfs the `c'
 | |
| partition.  Instead, newfs the partition where the non-swap space
 | |
| lies.</para></listitem> 
 | |
| <listitem><para>Add an entry to <filename>/etc/fstab</filename> as follows:
 | |
| <informalexample>
 | |
| <programlisting>
 | |
| /dev/wd0b                       none            swap    sw 0 0
 | |
| </programlisting>
 | |
| </informalexample>
 | |
| Change /dev/wd0b to the device of the newly added
 | |
| space.</para></listitem>
 | |
| <listitem><para>To make the new space immediately available, use the
 | |
| <command>swapon</command> command.
 | |
| <informalexample>
 | |
| <screen>
 | |
| <userinput>
 | |
| $ swapon /dev/sd0b
 | |
| </userinput>
 | |
| swapon:  added /dev/sd0b as swap space
 | |
| </screen>
 | |
| </informalexample>
 | |
| </para></listitem>
 | |
| </orderedlist>
 | |
| </para>
 | |
| </sect1>
 | |
| 
 | |
| <sect1>
 | |
| <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>
 | |
| <userinput>
 | |
| mount /dev/wd2 /mnt
 | |
| pax -r -w -p e /usr/home /mnt
 | |
| umount /mnt
 | |
| rm -rf /usr/home/*
 | |
| mount /dev/wd2 /usr/home
 | |
| </userinput>
 | |
| </screen>
 | |
| </informalexample>
 | |
| </para>
 | |
| </sect1>
 | |
| 
 | |
| <sect1>
 | |
| <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 ccd(4) and ccdconfig(4) 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>
 | |
| <userinput>
 | |
| cd /dev ; sh MAKDEV ccd0
 | |
| 
 | |
| disklabel -r -w sd0 auto
 | |
| disklabel -r -w sd1 auto
 | |
| disklabel -r -w sd2 auto
 | |
| 
 | |
| disklabel -e sd0c # change type to 4.2BSD
 | |
| disklabel -e sd1c # change type to 4.2BSD
 | |
| disklabel -e sd2c # change type to 4.2BSD
 | |
| 
 | |
| ccdconfig ccd0 32 0 /dev/sd0c /dev/sd2c /dev/sd2c
 | |
| 
 | |
| newfs /dev/rccd0c
 | |
| </userinput>
 | |
| </screen>
 | |
| </informalexample>
 | |
| 
 | |
| <para>Now you can mount and use your CCD by referencing device /dev/ccd0c.
 | |
| </para>
 | |
| 
 | |
| </sect1>
 | |
| </chapter>
 | |
| 
 | |
| <chapter>
 | |
| <title>Credits</title>
 | |
| 
 | |
| 
 | |
| 
 | |
| <para>The author would like to thank the following individuals for
 | |
| their contributions to this project:
 | |
| <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>
 | |
| </para>
 | |
| 
 | |
| </chapter>
 | |
| 
 | |
| 
 | |
| 
 | |
| </book>
 |