Move section about "Disk Organization" from Install to UNIX Basics

chapter.  This information is repeated in more basic terms in the
Install chapter, so this more in depth explanation is better suited in
Basics.

Sponsored by:	FreeBSD Mall, Inc.
This commit is contained in:
Chern Lee 2003-09-26 17:43:08 +00:00
parent 3455d4784a
commit 37905c3a95
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=18248
2 changed files with 507 additions and 506 deletions

View file

@ -601,6 +601,513 @@
</sect1>
<sect1>
<title>Disk Organization</title>
<para>The smallest unit of organization that FreeBSD uses to find files
is the filename. Filenames are case-sensitive, which means that
<filename>readme.txt</filename> and <filename>README.TXT</filename>
are two separate files. FreeBSD does not use the extension
(<filename>.txt</filename>) of a file to determine whether the file is
program, or a document, or some other form of data.</para>
<para>Files are stored in directories. A directory may contain no
files, or it may contain many hundreds of files. A directory can also
contain other directories, allowing you to build up a hierarchy of
directories within one another. This makes it much easier to organize
your data.</para>
<para>Files and directories are referenced by giving the file or
directory name, followed by a forward slash, <literal>/</literal>,
followed by any other directory names that are necessary. If you have
directory <filename>foo</filename>, which contains directory
<filename>bar</filename>, which contains the file
<filename>readme.txt</filename>, then the full name, or
<firstterm>path</firstterm> to the file is
<filename>foo/bar/readme.txt</filename>.</para>
<para>Directories and files are stored in a filesystem. Each filesystem
contains exactly one directory at the very top level, called the
<firstterm>root directory</firstterm> for that filesystem. This root
directory can then contain other directories.</para>
<para>So far this is probably similar to any other operating system you
may have used. There are a few differences; for example, DOS uses
<literal>\</literal> to separate file and directory names, while &macos;
uses <literal>:</literal>.</para>
<para>FreeBSD does not use drive letters, or other drive names in the
path. You would not write <filename>c:/foo/bar/readme.txt</filename>
on FreeBSD.</para>
<para>Instead, one filesystem is designated the <firstterm>root
filesystem</firstterm>. The root filesystem's root directory is
referred to as <literal>/</literal>. Every other filesystem is then
<firstterm>mounted</firstterm> under the root filesystem. No matter
how many disks you have on your FreeBSD system, every directory
appears to be part of the same disk.</para>
<para>Suppose you have three filesystems, called <literal>A</literal>,
<literal>B</literal>, and <literal>C</literal>. Each filesystem has
one root directory, which contains two other directories, called
<literal>A1</literal>, <literal>A2</literal> (and likewise
<literal>B1</literal>, <literal>B2</literal> and
<literal>C1</literal>, <literal>C2</literal>).</para>
<para>Call <literal>A</literal> the root filesystem. If you used the
<command>ls</command> command to view the contents of this directory
you would see two subdirectories, <literal>A1</literal> and
<literal>A2</literal>. The directory tree looks like this:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir1" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
|
`--- A2</literallayout>
</textobject>
</mediaobject>
<para>A filesystem must be mounted on to a directory in another
filesystem. So now suppose that you mount filesystem
<literal>B</literal> on to the directory <literal>A1</literal>. The
root directory of <literal>B</literal> replaces <literal>A1</literal>,
and the directories in <literal>B</literal> appear accordingly:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir2" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
| |
| +--- B1
| |
| `--- B2
|
`--- A2</literallayout>
</textobject>
</mediaobject>
<para>Any files that are in the <literal>B1</literal> or
<literal>B2</literal> directories can be reached with the path
<filename>/A1/B1</filename> or <filename>/A1/B2</filename> as
necessary. Any files that were in <filename>/A1</filename> have been
temporarily hidden. They will reappear if <literal>B</literal> is
<firstterm>unmounted</firstterm> from A.</para>
<para>If <literal>B</literal> had been mounted on <literal>A2</literal>
then the diagram would look like this:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir3" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
|
`--- A2
|
+--- B1
|
`--- B2</literallayout>
</textobject>
</mediaobject>
<para>and the paths would be <filename>/A2/B1</filename> and
<filename>/A2/B2</filename> respectively.</para>
<para>Filesystems can be mounted on top of one another. Continuing the
last example, the <literal>C</literal> filesystem could be mounted on
top of the <literal>B1</literal> directory in the <literal>B</literal>
filesystem, leading to this arrangement:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir4" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
|
`--- A2
|
+--- B1
| |
| +--- C1
| |
| `--- C2
|
`--- B2</literallayout>
</textobject>
</mediaobject>
<para>Or <literal>C</literal> could be mounted directly on to the
<literal>A</literal> filesystem, under the <literal>A1</literal>
directory:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir5" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
| |
| +--- C1
| |
| `--- C2
|
`--- A2
|
+--- B1
|
`--- B2</literallayout>
</textobject>
</mediaobject>
<para>If you are familiar with DOS, this is similar, although not
identical, to the <command>join</command> command.</para>
<para>This is not normally something you need to concern yourself with.
Typically you create filesystems when installing FreeBSD and decide
where to mount them, and then never change them unless you add a new
disk.</para>
<para>It is entirely possible to have one large root filesystem, and not
need to create any others. There are some drawbacks to this approach,
and one advantage.</para>
<itemizedlist>
<title>Benefits of Multiple Filesystems</title>
<listitem>
<para>Different filesystems can have different <firstterm>mount
options</firstterm>. For example, with careful planning, the
root filesystem can be mounted read-only, making it impossible for
you to inadvertently delete or edit a critical file. Separating
user-writable filesystems, such as <filename>/home</filename>,
from other filesystems also allows them to be mounted
<firstterm>nosuid</firstterm>; this option prevents the
<firstterm>suid</firstterm>/<firstterm>guid</firstterm> bits on
executables stored on the filesystem from taking effect, possibly
improving security.</para>
</listitem>
<listitem>
<para>FreeBSD automatically optimizes the layout of files on a
filesystem, depending on how the filesystem is being used. So a
filesystem that contains many small files that are written
frequently will have a different optimization to one that contains
fewer, larger files. By having one big filesystem this
optimization breaks down.</para>
</listitem>
<listitem>
<para>FreeBSD's filesystems are very robust should you lose power.
However, a power loss at a critical point could still damage the
structure of the filesystem. By splitting your data over multiple
filesystems it is more likely that the system will still come up,
making it easier for you to restore from backup as necessary.</para>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Benefit of a Single Filesystem</title>
<listitem>
<para>Filesystems are a fixed size. If you create a filesystem when
you install FreeBSD and give it a specific size, you may later
discover that you need to make the partition bigger. This is not
easily accomplished without backing up, recreating the filesystem
with the new size, and then restoring the backed up data.</para>
<important>
<para>FreeBSD&nbsp;4.4 and later versions feature the &man.growfs.8;
command, which makes it possible to increase the size of
filesystem on the fly, removing this limitation.</para>
</important>
</listitem>
</itemizedlist>
<para>Filesystems are contained in partitions. This does not have the
same meaning as the earlier usage of the term partition in this
chapter, because of FreeBSD's &unix; heritage. Each partition is
identified by a letter from <literal>a</literal> through to
<literal>h</literal>. Each partition can contain only one filesystem,
which means that filesystems are often described by either their
typical mount point in the filesystem hierarchy, or the letter of the
partition they are contained in.</para>
<para>FreeBSD also uses disk space for <firstterm>swap
space</firstterm>. Swap space provides FreeBSD with
<firstterm>virtual memory</firstterm>. This allows your computer to
behave as though it has much more memory than it actually does. When
FreeBSD runs out of memory it moves some of the data that is not
currently being used to the swap space, and moves it back in (moving
something else out) when it needs it.</para>
<para>Some partitions have certain conventions associated with
them.</para>
<informaltable frame="none">
<tgroup cols="2">
<colspec colwidth="1*">
<colspec colwidth="5*">
<thead>
<row>
<entry>Partition</entry>
<entry>Convention</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>a</literal></entry>
<entry>Normally contains the root filesystem</entry>
</row>
<row>
<entry><literal>b</literal></entry>
<entry>Normally contains swap space</entry>
</row>
<row>
<entry><literal>c</literal></entry>
<entry>Normally the same size as the enclosing slice. This
allows utilities that need to work on the entire slice (for
example, a bad block scanner) to work on the
<literal>c</literal> partition. You would not normally create
a filesystem on this partition.</entry>
</row>
<row>
<entry><literal>d</literal></entry>
<entry>Partition <literal>d</literal> used to have a special
meaning associated with it, although that is now gone. To
this day, some tools may operate oddly if told to work on
partition <literal>d</literal>, so
<application>sysinstall</application> will not normally create
partition <literal>d</literal>.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>Each partition-that-contains-a-filesystem is stored in what
FreeBSD calls a <firstterm>slice</firstterm>. Slice is FreeBSD's term
for what were earlier called partitions, and again, this is because of
FreeBSD's &unix; background. Slices are numbered, starting at 1,
through to 4.</para>
<indexterm><primary>slices</primary></indexterm>
<indexterm><primary>partitions</primary></indexterm>
<indexterm><primary>dangerously dedicated</primary></indexterm>
<para>Slice numbers follow
the device name, prefixed with an <literal>s</literal>,
starting at 1. So <quote>da0<emphasis>s1</emphasis></quote>
is the first slice on the first SCSI drive. There can only be
four physical slices on a disk, but you can have logical
slices inside physical slices of the appropriate type. These
extended slices are numbered starting at 5, so
<quote>ad0<emphasis>s5</emphasis></quote> is the first
extended slice on the first IDE disk. These devices are used by file
systems that expect to occupy a slice.</para>
<para>Slices, <quote>dangerously dedicated</quote> physical
drives, and other drives contain
<firstterm>partitions</firstterm>, which are represented as
letters from <literal>a</literal> to <literal>h</literal>.
This letter is appended to the device name, so
<quote>da0<emphasis>a</emphasis></quote> is the a partition on
the first da drive, which is <quote>dangerously dedicated</quote>.
<quote>ad1s3<emphasis>e</emphasis></quote> is the fifth partition
in the third slice of the second IDE disk drive.</para>
<para>Finally, each disk on the system is identified. A disk name
starts with a code that indicates the type of disk, and then a number,
indicating which disk it is. Unlike slices, disk numbering starts at
0. Common codes that you will see are listed in
<xref linkend="install-dev-codes">.</para>
<para>When referring to a partition FreeBSD requires that you also name
the slice and disk that contains the partition, and when referring to
a slice you should also refer to the disk name. Do this by listing
the disk name, <literal>s</literal>, the slice number, and then the
partition letter. Examples are shown in
<xref linkend="install-disk-slice-part">.</para>
<para><xref linkend="install-concept-disk-model"> shows a conceptual
model of the disk layout that should help make things clearer.</para>
<para>In order to install FreeBSD you must first configure the disk
slices, then create partitions within the slice you will use for
FreeBSD, and then create a filesystem (or swap space) in each
partition, and decide where that filesystem will be mounted.</para>
<table frame="none" id="install-dev-codes">
<title>Disk Device Codes</title>
<tgroup cols="2">
<colspec colwidth="1*">
<colspec colwidth="5*">
<thead>
<row>
<entry>Code</entry>
<entry>Meaning</entry>
</row>
</thead>
<tbody>
<row>
<entry><devicename>ad</devicename></entry>
<entry>ATAPI (IDE) disk</entry>
</row>
<row>
<entry><devicename>da</devicename></entry>
<entry>SCSI direct access disk</entry>
</row>
<row>
<entry><devicename>acd</devicename></entry>
<entry>ATAPI (IDE) CDROM</entry>
</row>
<row>
<entry><devicename>cd</devicename></entry>
<entry>SCSI CDROM</entry>
</row>
<row>
<entry><devicename>fd</devicename></entry>
<entry>Floppy disk</entry>
</row>
</tbody>
</tgroup>
</table>
<example id="install-disk-slice-part">
<title>Sample Disk, Slice, and Partition Names</title>
<informaltable frame="none">
<tgroup cols="2">
<colspec colwidth="1*">
<colspec colwidth="5*">
<thead>
<row>
<entry>Name</entry>
<entry>Meaning</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>ad0s1a</literal></entry>
<entry>The first partition (<literal>a</literal>) on the first
slice (<literal>s1</literal>) on the first IDE disk
(<literal>ad0</literal>).</entry>
</row>
<row>
<entry><literal>da1s2e</literal></entry>
<entry>The fifth partition (<literal>e</literal>) on the
second slice (<literal>s2</literal>) on the second SCSI disk
(<literal>da1</literal>).</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</example>
<example id="install-concept-disk-model">
<title>Conceptual Model of a Disk</title>
<para>This diagram shows FreeBSD's view of the first IDE disk attached
to the system. Assume that the disk is 4&nbsp;GB in size, and contains
two 2&nbsp;GB slices (DOS partitions). The first slice contains a DOS
disk, <devicename>C:</devicename>, and the second slice contains a
FreeBSD installation. This example FreeBSD installation has three
partitions, and a swap partition.</para>
<para>The three partitions will each hold a filesystem. Partition
<literal>a</literal> will be used for the root filesystem,
<literal>e</literal> for the <filename>/var</filename> directory
hierarchy, and <literal>f</literal> for the
<filename>/usr</filename> directory hierarchy.</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/disk-layout" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced">.-----------------. --.
| | |
| DOS / Windows | |
: : > First slice, ad0s1
: : |
| | |
:=================: ==: --.
| | | Partition a, mounted as / |
| | > referred to as ad0s2a |
| | | |
:-----------------: ==: |
| | | Partition b, used as swap |
| | > referred to as ad0s2b |
| | | |
:-----------------: ==: | Partition c, no
| | | Partition e, used as /var > filesystem, all
| | > referred to as ad0s2e | of FreeBSD slice,
| | | | ad0s2c
:-----------------: ==: |
| | | |
: : | Partition f, used as /usr |
: : > referred to as ad0s2f |
: : | |
| | | |
| | --' |
`-----------------' --'</literallayout>
</textobject>
</mediaobject>
</example>
</sect1>
<sect1 id="mount-unmount">
<title>Mounting and Unmounting File Systems</title>

View file

@ -1576,512 +1576,6 @@ Mounting root from ufs:/dev/md0c
</sidebar>
</sect2>
<sect2>
<title>Disk Organization</title>
<para>The smallest unit of organization that FreeBSD uses to find files
is the filename. Filenames are case-sensitive, which means that
<filename>readme.txt</filename> and <filename>README.TXT</filename>
are two separate files. FreeBSD does not use the extension
(<filename>.txt</filename>) of a file to determine whether the file is
program, or a document, or some other form of data.</para>
<para>Files are stored in directories. A directory may contain no
files, or it may contain many hundreds of files. A directory can also
contain other directories, allowing you to build up a hierarchy of
directories within one another. This makes it much easier to organize
your data.</para>
<para>Files and directories are referenced by giving the file or
directory name, followed by a forward slash, <literal>/</literal>,
followed by any other directory names that are necessary. If you have
directory <filename>foo</filename>, which contains directory
<filename>bar</filename>, which contains the file
<filename>readme.txt</filename>, then the full name, or
<firstterm>path</firstterm> to the file is
<filename>foo/bar/readme.txt</filename>.</para>
<para>Directories and files are stored in a filesystem. Each filesystem
contains exactly one directory at the very top level, called the
<firstterm>root directory</firstterm> for that filesystem. This root
directory can then contain other directories.</para>
<para>So far this is probably similar to any other operating system you
may have used. There are a few differences; for example, DOS uses
<literal>\</literal> to separate file and directory names, while &macos;
uses <literal>:</literal>.</para>
<para>FreeBSD does not use drive letters, or other drive names in the
path. You would not write <filename>c:/foo/bar/readme.txt</filename>
on FreeBSD.</para>
<para>Instead, one filesystem is designated the <firstterm>root
filesystem</firstterm>. The root filesystem's root directory is
referred to as <literal>/</literal>. Every other filesystem is then
<firstterm>mounted</firstterm> under the root filesystem. No matter
how many disks you have on your FreeBSD system, every directory
appears to be part of the same disk.</para>
<para>Suppose you have three filesystems, called <literal>A</literal>,
<literal>B</literal>, and <literal>C</literal>. Each filesystem has
one root directory, which contains two other directories, called
<literal>A1</literal>, <literal>A2</literal> (and likewise
<literal>B1</literal>, <literal>B2</literal> and
<literal>C1</literal>, <literal>C2</literal>).</para>
<para>Call <literal>A</literal> the root filesystem. If you used the
<command>ls</command> command to view the contents of this directory
you would see two subdirectories, <literal>A1</literal> and
<literal>A2</literal>. The directory tree looks like this:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir1" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
|
`--- A2</literallayout>
</textobject>
</mediaobject>
<para>A filesystem must be mounted on to a directory in another
filesystem. So now suppose that you mount filesystem
<literal>B</literal> on to the directory <literal>A1</literal>. The
root directory of <literal>B</literal> replaces <literal>A1</literal>,
and the directories in <literal>B</literal> appear accordingly:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir2" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
| |
| +--- B1
| |
| `--- B2
|
`--- A2</literallayout>
</textobject>
</mediaobject>
<para>Any files that are in the <literal>B1</literal> or
<literal>B2</literal> directories can be reached with the path
<filename>/A1/B1</filename> or <filename>/A1/B2</filename> as
necessary. Any files that were in <filename>/A1</filename> have been
temporarily hidden. They will reappear if <literal>B</literal> is
<firstterm>unmounted</firstterm> from A.</para>
<para>If <literal>B</literal> had been mounted on <literal>A2</literal>
then the diagram would look like this:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir3" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
|
`--- A2
|
+--- B1
|
`--- B2</literallayout>
</textobject>
</mediaobject>
<para>and the paths would be <filename>/A2/B1</filename> and
<filename>/A2/B2</filename> respectively.</para>
<para>Filesystems can be mounted on top of one another. Continuing the
last example, the <literal>C</literal> filesystem could be mounted on
top of the <literal>B1</literal> directory in the <literal>B</literal>
filesystem, leading to this arrangement:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir4" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
|
`--- A2
|
+--- B1
| |
| +--- C1
| |
| `--- C2
|
`--- B2</literallayout>
</textobject>
</mediaobject>
<para>Or <literal>C</literal> could be mounted directly on to the
<literal>A</literal> filesystem, under the <literal>A1</literal>
directory:</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/example-dir5" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced"> /
|
+--- A1
| |
| +--- C1
| |
| `--- C2
|
`--- A2
|
+--- B1
|
`--- B2</literallayout>
</textobject>
</mediaobject>
<para>If you are familiar with DOS, this is similar, although not
identical, to the <command>join</command> command.</para>
<para>This is not normally something you need to concern yourself with.
Typically you create filesystems when installing FreeBSD and decide
where to mount them, and then never change them unless you add a new
disk.</para>
<para>It is entirely possible to have one large root filesystem, and not
need to create any others. There are some drawbacks to this approach,
and one advantage.</para>
<itemizedlist>
<title>Benefits of Multiple Filesystems</title>
<listitem>
<para>Different filesystems can have different <firstterm>mount
options</firstterm>. For example, with careful planning, the
root filesystem can be mounted read-only, making it impossible for
you to inadvertently delete or edit a critical file. Separating
user-writable filesystems, such as <filename>/home</filename>,
from other filesystems also allows them to be mounted
<firstterm>nosuid</firstterm>; this option prevents the
<firstterm>suid</firstterm>/<firstterm>guid</firstterm> bits on
executables stored on the filesystem from taking effect, possibly
improving security.</para>
</listitem>
<listitem>
<para>FreeBSD automatically optimizes the layout of files on a
filesystem, depending on how the filesystem is being used. So a
filesystem that contains many small files that are written
frequently will have a different optimization to one that contains
fewer, larger files. By having one big filesystem this
optimization breaks down.</para>
</listitem>
<listitem>
<para>FreeBSD's filesystems are very robust should you lose power.
However, a power loss at a critical point could still damage the
structure of the filesystem. By splitting your data over multiple
filesystems it is more likely that the system will still come up,
making it easier for you to restore from backup as necessary.</para>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Benefit of a Single Filesystem</title>
<listitem>
<para>Filesystems are a fixed size. If you create a filesystem when
you install FreeBSD and give it a specific size, you may later
discover that you need to make the partition bigger. This is not
easily accomplished without backing up, recreating the filesystem
with the new size, and then restoring the backed up data.</para>
<important>
<para>FreeBSD&nbsp;4.4 and later versions feature the &man.growfs.8;
command, which makes it possible to increase the size of
filesystem on the fly, removing this limitation.</para>
</important>
</listitem>
</itemizedlist>
<para>Filesystems are contained in partitions. This does not have the
same meaning as the earlier usage of the term partition in this
chapter, because of FreeBSD's &unix; heritage. Each partition is
identified by a letter from <literal>a</literal> through to
<literal>h</literal>. Each partition can contain only one filesystem,
which means that filesystems are often described by either their
typical mount point in the filesystem hierarchy, or the letter of the
partition they are contained in.</para>
<para>FreeBSD also uses disk space for <firstterm>swap
space</firstterm>. Swap space provides FreeBSD with
<firstterm>virtual memory</firstterm>. This allows your computer to
behave as though it has much more memory than it actually does. When
FreeBSD runs out of memory it moves some of the data that is not
currently being used to the swap space, and moves it back in (moving
something else out) when it needs it.</para>
<para>Some partitions have certain conventions associated with
them.</para>
<informaltable frame="none">
<tgroup cols="2">
<colspec colwidth="1*">
<colspec colwidth="5*">
<thead>
<row>
<entry>Partition</entry>
<entry>Convention</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>a</literal></entry>
<entry>Normally contains the root filesystem</entry>
</row>
<row>
<entry><literal>b</literal></entry>
<entry>Normally contains swap space</entry>
</row>
<row>
<entry><literal>c</literal></entry>
<entry>Normally the same size as the enclosing slice. This
allows utilities that need to work on the entire slice (for
example, a bad block scanner) to work on the
<literal>c</literal> partition. You would not normally create
a filesystem on this partition.</entry>
</row>
<row>
<entry><literal>d</literal></entry>
<entry>Partition <literal>d</literal> used to have a special
meaning associated with it, although that is now gone. To
this day, some tools may operate oddly if told to work on
partition <literal>d</literal>, so
<application>sysinstall</application> will not normally create
partition <literal>d</literal>.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>Each partition-that-contains-a-filesystem is stored in what
FreeBSD calls a <firstterm>slice</firstterm>. Slice is FreeBSD's term
for what were earlier called partitions, and again, this is because of
FreeBSD's &unix; background. Slices are numbered, starting at 1,
through to 4.</para>
<indexterm><primary>slices</primary></indexterm>
<indexterm><primary>partitions</primary></indexterm>
<indexterm><primary>dangerously dedicated</primary></indexterm>
<para>Slice numbers follow
the device name, prefixed with an <literal>s</literal>,
starting at 1. So <quote>da0<emphasis>s1</emphasis></quote>
is the first slice on the first SCSI drive. There can only be
four physical slices on a disk, but you can have logical
slices inside physical slices of the appropriate type. These
extended slices are numbered starting at 5, so
<quote>ad0<emphasis>s5</emphasis></quote> is the first
extended slice on the first IDE disk. These devices are used by file
systems that expect to occupy a slice.</para>
<para>Slices, <quote>dangerously dedicated</quote> physical
drives, and other drives contain
<firstterm>partitions</firstterm>, which are represented as
letters from <literal>a</literal> to <literal>h</literal>.
This letter is appended to the device name, so
<quote>da0<emphasis>a</emphasis></quote> is the a partition on
the first da drive, which is <quote>dangerously dedicated</quote>.
<quote>ad1s3<emphasis>e</emphasis></quote> is the fifth partition
in the third slice of the second IDE disk drive.</para>
<para>Finally, each disk on the system is identified. A disk name
starts with a code that indicates the type of disk, and then a number,
indicating which disk it is. Unlike slices, disk numbering starts at
0. Common codes that you will see are listed in
<xref linkend="install-dev-codes">.</para>
<para>When referring to a partition FreeBSD requires that you also name
the slice and disk that contains the partition, and when referring to
a slice you should also refer to the disk name. Do this by listing
the disk name, <literal>s</literal>, the slice number, and then the
partition letter. Examples are shown in
<xref linkend="install-disk-slice-part">.</para>
<para><xref linkend="install-concept-disk-model"> shows a conceptual
model of the disk layout that should help make things clearer.</para>
<para>In order to install FreeBSD you must first configure the disk
slices, then create partitions within the slice you will use for
FreeBSD, and then create a filesystem (or swap space) in each
partition, and decide where that filesystem will be mounted.</para>
<table frame="none" id="install-dev-codes">
<title>Disk Device Codes</title>
<tgroup cols="2">
<colspec colwidth="1*">
<colspec colwidth="5*">
<thead>
<row>
<entry>Code</entry>
<entry>Meaning</entry>
</row>
</thead>
<tbody>
<row>
<entry><devicename>ad</devicename></entry>
<entry>ATAPI (IDE) disk</entry>
</row>
<row>
<entry><devicename>da</devicename></entry>
<entry>SCSI direct access disk</entry>
</row>
<row>
<entry><devicename>acd</devicename></entry>
<entry>ATAPI (IDE) CDROM</entry>
</row>
<row>
<entry><devicename>cd</devicename></entry>
<entry>SCSI CDROM</entry>
</row>
<row>
<entry><devicename>fd</devicename></entry>
<entry>Floppy disk</entry>
</row>
</tbody>
</tgroup>
</table>
<example id="install-disk-slice-part">
<title>Sample Disk, Slice, and Partition Names</title>
<informaltable frame="none">
<tgroup cols="2">
<colspec colwidth="1*">
<colspec colwidth="5*">
<thead>
<row>
<entry>Name</entry>
<entry>Meaning</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>ad0s1a</literal></entry>
<entry>The first partition (<literal>a</literal>) on the first
slice (<literal>s1</literal>) on the first IDE disk
(<literal>ad0</literal>).</entry>
</row>
<row>
<entry><literal>da1s2e</literal></entry>
<entry>The fifth partition (<literal>e</literal>) on the
second slice (<literal>s2</literal>) on the second SCSI disk
(<literal>da1</literal>).</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</example>
<example id="install-concept-disk-model">
<title>Conceptual Model of a Disk</title>
<para>This diagram shows FreeBSD's view of the first IDE disk attached
to the system. Assume that the disk is 4&nbsp;GB in size, and contains
two 2&nbsp;GB slices (DOS partitions). The first slice contains a DOS
disk, <devicename>C:</devicename>, and the second slice contains a
FreeBSD installation. This example FreeBSD installation has three
partitions, and a swap partition.</para>
<para>The three partitions will each hold a filesystem. Partition
<literal>a</literal> will be used for the root filesystem,
<literal>e</literal> for the <filename>/var</filename> directory
hierarchy, and <literal>f</literal> for the
<filename>/usr</filename> directory hierarchy.</para>
<mediaobject>
<imageobject>
<imagedata fileref="install/disk-layout" format="EPS">
</imageobject>
<textobject>
<literallayout class="monospaced">.-----------------. --.
| | |
| DOS / Windows | |
: : > First slice, ad0s1
: : |
| | |
:=================: ==: --.
| | | Partition a, mounted as / |
| | > referred to as ad0s2a |
| | | |
:-----------------: ==: |
| | | Partition b, used as swap |
| | > referred to as ad0s2b |
| | | |
:-----------------: ==: | Partition c, no
| | | Partition e, used as /var > filesystem, all
| | > referred to as ad0s2e | of FreeBSD slice,
| | | | ad0s2c
:-----------------: ==: |
| | | |
: : | Partition f, used as /usr |
: : > referred to as ad0s2f |
: : | |
| | | |
| | --' |
`-----------------' --'</literallayout>
</textobject>
</mediaobject>
</example>
</sect2>
<sect2 id="main-fdisk">
<title>Creating Slices Using FDisk</title>