The smallest unit of organization that FreeBSD uses to find
files is the filename. Filenames are case-sensitive, which
README.TXT are two separate files. FreeBSD
does not use the extension of a file to determine whether the
file is a program, document, or some other form of data.
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 a hierarchy of directories within one another in order to organize data.
Files and directories are referenced by giving the file or
directory name, followed by a forward slash,
/, followed by any other directory names that
are necessary. For example, if the directory
foo contains a directory
bar which contains the
readme.txt, the full name, or
path, to the file is
foo/bar/readme.txt. Note that this is
different from Windows(R) which uses
separate file and directory names. FreeBSD does not use drive
letters, or other drive names in the path. For example, one
would not type
Directories and files are stored in a file system. Each
file system contains exactly one directory at the very top
level, called the root directory for that
file system. This root directory can contain other directories.
One file system is designated the
root file system or
Every other file system is mounted under
the root file system. No matter how many disks are on the FreeBSD
system, every directory appears to be part of the same
Consider three file systems, called
C. Each file
system has one root directory, which contains two other
A the root file system. If
ls(1) is used to view the contents of this directory,
it will show two subdirectories,
A2. The directory tree looks like
A file system must be mounted on to a directory in another
file system. When mounting file system
on to the directory
A1, the root directory
the directories in
Any files that are in the
B2 directories can be reached with the path
/A1/B2 as necessary. Any
files that were in
have been temporarily hidden. They will reappear if
B is unmounted from
B had been mounted on
A2 then the diagram would look like
and the paths would be
File systems can be mounted on top of one another.
Continuing the last example, the
system could be mounted on top of the
directory in the
B file system, leading to
C could be mounted directly on to the
A file system, under the
It is entirely possible to have one large root file system, and not need to create any others. There are some drawbacks to this approach, and one advantage.
Different file systems can have different mount options. For example, the root file system can be mounted read-only, making it impossible for users to inadvertently delete or edit a critical file. Separating user-writable file systems, such as
/home, from other file systems allows them to be mounted nosuid. This option prevents the suid/guid bits on executables stored on the file system from taking effect, possibly improving security.
FreeBSD automatically optimizes the layout of files on a file system, depending on how the file system is being used. So a file system 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 file system this optimization breaks down.
FreeBSD's file systems are robust if power is lost. However, a power loss at a critical point could still damage the structure of the file system. By splitting data over multiple file systems it is more likely that the system will still come up, making it easier to restore from backup as necessary.
File systems are a fixed size. If you create a file system 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 file system with the new size, and then restoring the backed up data.
FreeBSD features the growfs(8) command, which makes it possible to increase the size of file system on the fly, removing this limitation.
File systems are contained in partitions. This does not
have the same meaning as the common usage of the term partition
(for example, MS-DOS(R) partition), because of FreeBSD's UNIX(R)
heritage. Each partition is identified by a letter from
a through to
partition can contain only one file system, which means that
file systems are often described by either their typical mount
point in the file system hierarchy, or the letter of the
partition they are contained in.
FreeBSD also uses disk space for swap space to provide virtual memory. 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.
Some partitions have certain conventions associated with them.
|Normally contains the root file system.|
|Normally contains swap space.|
|Normally the same size as the enclosing slice.
This allows utilities that need to work on the entire
slice, such as a bad block scanner, to work on the
Disks in FreeBSD are divided into slices, referred to in Windows(R) as partitions, which are numbered from 1 to 4. These are then divided into partitions, which contain file systems, and are labeled using letters.
Slice numbers follow the device name, prefixed with an
s, starting at 1. So
“da0s1” is the first slice on
the first SCSI drive. There can only be four physical slices on
a disk, but there can be logical slices inside physical slices
of the appropriate type. These extended slices are numbered
starting at 5, so “ada0s5” is
the first extended slice on the first SATA disk. These devices
are used by file systems that expect to occupy a slice.
Slices, “dangerously dedicated” physical
drives, and other drives contain
partitions, which are represented as
letter is appended to the device name, so
“da0a” is the
a partition on the first
da drive, which is
“ada1s3e” is the fifth
partition in the third slice of the second SATA disk
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 are listed in Table 3.3, “Disk Device Names”.
When referring to a partition, include the disk name,
s, the slice number, and then the partition
letter. Examples are shown in
Example 3.12, “Sample Disk, Slice, and Partition Names”.
Example 3.13, “Conceptual Model of a Disk” shows a conceptual model of a disk layout.
When installing FreeBSD, configure the disk slices, create partitions within the slice to be used for FreeBSD, create a file system or swap space in each partition, and decide where each file system will be mounted.
|Drive Type||Drive Device Name|
|SATA and IDE hard drives|
|SCSI hard drives and USB storage devices|
|SATA and IDE CD-ROM drives|
|SCSI CD-ROM drives|
|Assorted non-standard CD-ROM drives|
|SCSI tape drives|
|IDE tape drives|
|RAID drives||Examples include |
|The first partition (|
|The fifth partition (|
This diagram shows FreeBSD's view of the first
SATA disk attached to the system. Assume
that the disk is 250 GB in size, and contains an
80 GB slice and a 170 GB slice (MS-DOS(R)
partitions). The first slice contains a Windows(R)
NTFS file system,
and the second slice contains a FreeBSD installation. This
example FreeBSD installation has four data partitions and a swap
The four partitions each hold a file system. Partition
a is used for the root file system,
c refers to the entire
slice, and so is not used for ordinary partitions.