|
V.0.1
If there are any questions or comments, please direct them to walt@erudition.net . The newest copy of this How-To can always be retrieved
from www.erudition.net/freebsd/. All rights for the reproduction of this document are reserved.
Summary.
This HowTo will cover general filesystem layout issues to help
newcomers to FreeBSD 4.x/3.x, with an introduction to the partitioning policies used in FreeBSD and most BSD systems, how they relate to filesystem layout, and some comparisons with Windows/DOS and Linux
partitioning methodologies.
1. Introduction
1.1. Why Multiple Filesystem?
1.2. What are Slices and Partitions? 2. What are the Necessary FreeBSD Filesystems?
2.1. What is / for?
2.2. What is /usr for? 2.3.What is /var for? 2.4.What is /home and /tmp for?
3. Appendix
1.Introduction
1.1.Why Multiple Filesystem?
UNIX operating systems are designed with multiple filesystems in mind; although, one can
circumvent this by using one, large, filesystem with sub directories for each taking the place of mount points for the additional filesystems. Linux-based operating systems tend to default to the single-filesystem
philosophy. Although both approaches work, there are three significant advantages for the multiple filesystem approach.
Firstly, multiple filesystems allow one to span an OS easily across multiple hard disks.
If either one requires more hard disk space than available in a single hard disk, one can not afford that hard disk, or finally, one wishes to speed up operations by splitting the OS up among multiple hard disks,
such as in placing an often-used filesystem on a faster hard disk, the multiple filesystem approach will be advantageous.
Secondly, reliability issues may compel one to opt for the multiple filesystem
approach. By using a separate filesystem for often and heavily used directory structures, it minimizes the chance of a filesystem corruption immobilizing the entire OS. For instance, if an improper shutdown occurs,
without synching buffered data to the disks and Unmounting the sole filesystem, in a single-filesystem configuration, it can cause filesystem corruption, render that entire filesystem useless. However, if the
filesystem configuration had utilized multiple filesystems, and the corruption occurred in, say, the /tmp filesystem, the problem is localized. Either spare space or an additional hard disk can be added to support a
new /tmp filesystem, and operations can continue without nearly as much potential trouble. Data can be backed up off the other filesystems and saved for rebuilding a new system, or operations can continue with the
emergency /tmp filesystem that was added.
Thirdly, using the multiple filesystem approach allows an administrator to tune each filesystem individually, depending on the type of load, activity, and purpose it
fulfills, using utilities such as tunefs(8). This allows for a higher system performance potential. If, for instance, a particular filesystem will deal heavily with many tiny files, the administrator can optimize
that filesystem by configuring it with smaller blocks per cylinder group usage (tunefs -e #).
For these reasons, FreeBSD maintains a default policy of using multiple filesystems instead of a single,
monolithic filesystem. Not uncommonly has the question been posed by Linux users, who either are curious, or switching to FreeBSD, as to the reason for the multiple filesystem approach. It does shine less in desktop
operations, although, it clearly does not under perform the single filesystem approach. It is a layout philosophy that is geared toward not only accommodating speed, reliability, and performance issues both on a
hard working workstation, and production servers.
1.2.What are Slices and Partitions?
The BSD concept of slices and partitions often confuses newcomers. It is, however, not completely alien from
other partitioning approaches. Related to the BSD partitioning scheme is the DOS/Linux primary/extended partition analogy. The central point of confusion is terminology. BSD systems refer to DOS/Linux primary
partitions as "slices." Because of archaic BIOS limitations in PCs, PCs are essentially limited to 4 primary partitions. Each primary partition is bootable, and can contain a separate filesystem/OS.
Because 4 partitions quickly becomes a crippling limitation, the concept of "extended" partitions was devised, which consists of multiple, contiguous logical partitions. An extended partition replaces one
of the four primary partitions, and can have many more partitions than the crippling 4 primary partition limitation. Each extended partition is broken into "logical" partitions. Both DOS and Linux makes
use of logical partitions, and indeed, the concept is closely related to BSD partitions.
But, in the BSD world, the terminology is different. As mentioned above, a "slice" is a primary partition. In
addition, a "partition" is a logical partition within a slice. Unlike in the DOS/Linux concept of differing extended and primary partitions, BSD slices are all the same, and can each contain BSD
partitions. An important point of divergence between the Linux and BSD approach is seen in the area of swap. Linux utilizes a special primary partition for swap usage, whereas, BSD utilizes a BSD partition for swap,
which is contained within the BSD slice. As such, BSD can exist completely within a single slice (or primary partition in DOS/Linux parlance), whereas Linux requires at least two primary partitions: one for swap,
and one for the logical partitions, each containing a filesystem (although usually, Linux defaults to a single filesystem approach, as mentioned in the previous section, which often results in a single logical
partition mounted on /).
For a more clear understanding, consider the following diagrams. In parentheses you will see the corresponding FreeBSD and Linux IDE HD device node equivalents; because this HowTo is
not specifically on partitions, their format will not be explained here. Partition entries with a '-' preceding them indicate either BSD partitions or Linux logical partitions:
FreeBSD (note, the device names in FreeBSD 3.x were wd* not ad*):
Partition (Slice)Filesystem ~--------------------------- 1 (ad0s1)FAT32 2 (ad0s2)FreeBSD - 2a (ad0s2a)/
- 2b (ad0s2b)Swap - 2e (ad0s2e)/usr - 2f (ad0s2f)/var - 2g (ad0s2g)/tmp
Linux:
Partition (Slice) Filesystem
----------------- ---------- 1 (hda0)FAT32 2 (hda1)Linux Swap 3 (hda2)/ - 5 (hda4)/usr - 6 (hda5)/var - 7 (hda6)/tmp
Further
explanation will not be dealt with here. This HowTo presents the partitioning approach of BSD systems only so as to give some foundation information for when a newcomer designs the partition layout during
installation.
Keep in mind that there can only be one filesystem per BSD partition, and multiple BSD partitions within a BSD slice. the BSD slice coresponds to FAT/Linux primary partitions, and due to archaic
PC BIOS limitations, there can only be four BSD slices (same as for FAT/Linux primary partitions) per system.
2.What are the Necessary FreeBSD Filesystems?
FreeBSD, like Linux, can get away with simply
one filesystem: the / (root) filesystem (Remember Swap isn't a filesysem, but a special back store for dumping anonymous memory for temporary storing - see Swap-HOWTO at www.freebsd-howto.com), however, as explained
in the first section, this is not recommended, nor the default policy for FreeBSD installations.
Under most circumstances, the following filesystems are installed on a generic FreeBSD system:
/ /usr
/var /home /tmp
2.1.What is / for?
The / (root) filesystem is necessary for seven vital purposes:
1) Main system configuration files in /etc
2) Mount points for additional filesystems 3) Kernel and boot configuration files 4) Basic system binaries in /bin and /sbin 5) Miscellaneous include files in /include 6) process "filesystem"
7) root home directory
The configuration files found in /etc control daemons and aspects of the system that come with the base system. The only other places on the system that comes close in importance in
containing configuration files of similar importance are /usr/local/etc and /usr/X11R6/etc.
The / filesystem being the base filesystem for all things is usually the place mount points are made for additional
non-essential filesystems, and is where all of the essential filesystems (/usr, /var, /home, tmp) are mounted.
The / filesystem is also the home of the kernel and boot configuration files in /boot.
In
addition to binaries' directories in /usr, / also contains two binary directories: /bin and /sbin. /bin contains basic binaries needed to manage a system in single user mode where /usr may not be mounted, such as
ls(1), ps(1), cd(1) and pwd(1). /sbin contains vital system binaries that regular users needn't or shouldn't have access to, but administrators will need to manage a system in single and multi-user mood, such as
mount(8); and that a system itself will need to operate, such as init(8).
The / filesystem also has miscellaneous include files in /include.
Next, the / filesystem is the home of the proc filesystem.
Any df(1) listing will show the 'proc' filesystem. It contains special directories for each process running on the system, each of which contains vital system statistics and data for each respective process. One
rarely has need to access any file in this filesystem.
Finally, the / filesystem holds the root home directory in /root. This is simply because when the system is booted into single user mode, or the /home
filesystem can not be mounted, the root user can still log on and work on the system.
2.2.What is /usr for?
The /usr partition is primarily for user-land binaries, libraries, system/kernel source code,
and configuration files. It is the filesystem that under most circumstances will command the most HD space.
There are several important directories located under /usr that should be known. Firstly, the
follow binary directories:
/usr/bin /usr/sbin
The first is primarily system binaries that many or all users can or will make use of. The second is primarily system binaries that most or all users
should never have access to. Both directories contain binaries that come with the base system and will be found on all FreeBSD systems unless the administrator decides to move them elsewhere.
Next next major directories to be aware of are:
/usr/lib /usr/libexec /usr/libdata
/usr/lib is the main library directory which contains dynamically linked libraries for use with most major
binaries on the system. /usr/libexec contains special binaries, similar to /usr/sbin, not for regular user use. The directory contains maintenance binaries, such as locate.updatedb which updates the locate database,
and daemon binaries (for use with inetd, or standalone) such as telnetd, ftpd, and fingerd. Finally, /usr/libdata will contain some extra data files for use with various applications.
Next we have:
/usr/ports /usr/man /usr/doc /usr/share
The first, clearly, is the directory that contains the ports system. For further information on the ports system, check out the handbook at
www.freebsd.org/handbook/. The /usr/man directory contains manual pages for some system binaries The /usr/doc directory contains some additional miscellaneous documentation that various ports may install in addition
to manual antries. Finally, the /usr/share directory contains various files and directories of files that are to be shared by various programs run by users. Some of the more important directories under /usr/share
are:
/usr/share/zoneinfo (contains time zone information) /usr/share/man (manual pages for most system binaries) /usr/share/skel (skeleton of files to be copied into new accounts)
/usr/share/examples (contains example configuration files for various utilities)
Next, we have:
/usr/obj /usr/src /usr/include /usr/compat /usr/X11R6
/usr/obj will
contain the object files from any 'make world.' Generally, if one hasn't rebuilt the system it will be empty. /usr/src will contain the source code for the base system and kernel if the administrator has
installed the source. The /usr/include directory will contain include files vital to compiling both console and X apps in FreeBSD/usr/compat will contain compatibility files for Linux emulation, if installed, and
finally, /usr/X11R6 will contain X system files if X had been installed. If X has been installed, there are several important directories under /usr/X11R6 that one should be aware of:
/usr/X11R6/GNUstep/apps
/usr/X11R6/etc /usr/X11R6/man /usr/X11R6/share /usr/X11R6/lib /usr/X11R6/include /usr/X11R6/bin
The first directory will contains apps for X window managers that comply with the GNUstep
standards. The second, /usr/X11R6/etc, will contain X initialization config files. The next two, /usr/X11R6/man and /usr/X11R6/share will both contain important X documentation. The former will contain manual pages
for various X binaries and system compotents while the latter will contain files that will be shared among various X apps and users, such as X app documentation and themes.
/usr/X11R6/lib and
/usr/X11R6/include will contain X dynamic libraries and X include files vital for compiling X apps, respectively, and /usr/X11R6/bin will have various X binaries for use by regular X users.
Finally, we have /usr/local, which contains a number of important directories:
/usr/local/bin /usr/local/sbin /usr/local/lib /usr/local/libexec /usr/local/include /usr/local/etc
The
/usr/local directory is primarily for the purpose of holding binaries installed to augment the base system. Things such as games, additional word processors, graphics utilities, etc, are usually installed in
/usr/local. Relatively large apps often get their own subdir under /usr/local while others tend to get installed in either /usr/local/bin or /usr/local/sbin. /usr/local/bin contains binaries primarily for public use
by users whereas /usr/local/sbin primarily contains binaries that most users needn't or shouldn't have access to.
/usr/local/lib will contain dynamic libraries for use by binaries that are not part of the
base system; that is, binaries installed later by the adminstrator. /usr/local/libexec, like /usr/libexec, will contain binaries usually not for general user use (there are exceptions such as the IRC client sirc)
and mostly system daemons, such as tcpd, installed later by the adminstrator.
Next, /usr/local/include will contain include files added by various programs and libraries suites (such as Qt) installed later by
the administrator, and finally, /usr/local/etc will contain configuration files for utilities and daemons also installed later by the administrator, especially, /usr/local/etc/rc.d/ which is the primary place for
system startup scripts to start daemons such as sshd and mysqld.
When deciding on partition sizes for the various filesystems during installation, it is usually best to leave as much as possible for the /usr
filesystem. Several size considerations one must keep in mind are:
/usr/src will require roughly 250M /usr/obj will require roughly 200M
The previous values will be considerablly smaller if one does
not intend to do a 'make world' ever.
/usr/X11R6 will require roughly 300M
Obviously, if one does not install X then one can subtract that value from /usr space considerations. Finally, a default
install, minus X and system source will require roughly 200M for the /usr filesystem. If one wishes to install X and all system source code, then one should set aside roughly 1GB for the /usr filesystem for
installation. In addition, to accomodate additional applications, utilities, and file storage space, one should add additional space to that 1GB accordingly.
2.3.What is /var for?
The /var filesystem
is used for several important tasks in any FreeBSD system. Two vital system operations handled by /var are:
1) mail 2) system databases
Mail for each user is maintained in /var/mail.
Important system databases such as the locate database, and package information for each port installed on the system are maintained in /var/db and /var/db/pkg respecitvely.
Other important areas of the /var filesystem are:
/var/spool /var/ftp
Pretty clearly, the former is for maintaning mail and printer spool data, while the latter is for maintaining the anonymous ftp
chroot(8) environment.
Finally, some additional important directories that we have under /var are:
/var/cron /var/account /var/run
The first is for maintaining user cron tabs. The
next is for maintaining system and session accounting data used by last(1), accton(8), lastcomm(1), and sa(8). Finally, the last is used for maintaining pid files for various running processes; that is, files that
contain the process ID of certain daemons.
2.4.What is /home and /tmp for?
Because the purpose for these filesystems is relatively straight-foward, they have been combined into one section. The former
is the default place for maintining the home directories for users other than root, and the latter is a temporary-file filesystem used for holding anything that is not vital to the system and can be deleted soon
after its use. Examples are files holding temporary data by daemons or unnamed and unsaved documents in word processors.
3.Appendix
Swap-HOWTO @ www.freebsd-howto.com and www.defcon1.org
FreeBSD Handbook @ www.freebsd.org/handbook/
|
|