This is a mildly frobbed version of the discussion in The Complete FreeBSD. The considerations apply
to all UNIX-like operating systems.
When UNIX was young, disks were tiny. At the time of the third edition of UNIX, in 1972, the
root file system was on a Digital RF-11, a fixed head disk with 512 kB. The system was
growing, and it was no longer possible to keep the entire system on this disk, so a second
file system became essential. It was mounted on a Digital RK03 with 2 MB of storage. To quote
from a paper published in the
Communications of the ACM in July 1974:
In our installation, for example, the root directory resides on the fixed-head disk, and
the large disk drive, which contains user's files, is mounted by the system initialization
program...
As time went on, UNIX got bigger, but so did the disks. By the early 80s, disks were large
enough to put / and /usr on the same disk, and it would have been possible to
merge / and /usr, but they didn't, mainly because of reliability concerns.
Since that time, an additional file system, /var, has come into common use for
frequently changed data, and some systems automatically add other file systems, such as
/opt and /home. When I wrote the 4th edition of “The Complete
FreeBSD” in 2003, the default installation gave you a 128 MB root file system, 256 MB
/var, 256 MB /tmp, and the rest of the disk—even then 20 GB—as the
/usr file system. And that's all.
It's relatively simple to estimate the size of the root file system, and the default value
of 128 MB is reasonable. But what about /var and /tmp? Is 256 MB too much or
too little? In fact, both file systems put together would be lost in the 18.7 GB of
/usr file system. Why are things still this way? Let's look at the advantages and
disadvantages:
-
If you write to a file system and the system crashes before all the data can be written
to disk, the data integrity of that file system can be severely compromised. For
performance reasons, the system doesn't write everything to disk immediately, so there's
quite a reasonable chance of this happening.
-
If you have a crash and lose the root file system, recovery can be difficult.
-
If a file system fills up, it can cause lots of trouble. Most messages about file
systems on the FreeBSD-questions mailing list are complaining about file systems
filling up. If you have a large number of small file systems, the chances are higher that
one will fill up while space remains on another.
-
On the other hand, some file systems are more important than others. If the /var
file system fills up (due to overly active logging, for example), you may not worry too
much. If your root file system fills up, you could have serious problems.
-
In single-user mode, only the root file system is mounted. With the classical layout,
this means that the only programs you can run are those in /bin and /sbin. To
run other programs, you must first mount the file system on which they are located.
-
It's nice to keep your personal files separate from the system files. That way you can
upgrade a system much more easily.
-
It's very difficult to estimate in advance the size needs of some file systems. For
example, on some systems /var can be very small, maybe only 2 or 3 MB. It's hardly
worth making a separate file system for that much data. On the other hand, other systems,
such as ftp or web servers, may have a /var system of 50 or 100 GB. How do you
choose the correct size for your system?
-
When doing backups, it's a good idea to be able to get a file system on a single
tape.
In the early days of UNIX, system crashes were relatively common, and the damage they did to
the file systems was relatively serious. Times have changed, and nowadays file system damage
is relatively seldom, particularly on file systems that have little activity. On the other
hand, disk drives have grown beyond most peoples' wildest expectations. The first edition of
“The Complete FreeBSD”, in 1997, showed how to install on a 200 MB drive. The
smallest disk drives in current production are now 80 GB in size, more than will fit on many
tapes.
As a result of these considerations, I have changed my recommendations. In earlier
editions of “The Complete FreeBSD”, I recommended putting a small root file
system and a /usr file system on the first (or only) disk on the system. /var
was to be a symbolic link to /usr/var.
This is still a valid layout, but it has a couple of problems:
-
In the example we're looking at, /usr is about 19 GB in size. Not many people
have backup devices that can write this much data on a single medium.
-
Many people had difficulty with the symbolic link to /usr/var.
As a result, I now recommend:
-
Make two root file systems, each between 4 and 6 GB.
-
Do not have a separate /usr file system.
-
Do not have a separate /var file system unless you have a good idea how big it
should be. A good example might be a web server, where (contrary to FreeBSD's
recommendations) it's a good idea to put the web pages on the /var file system.
-
Use the rest of the space on disk for a /home file system, as long as it's
possible to back it up on a single tape. Otherwise make multiple file systems. /home
is the normal directory for user files.
The second root file system is for upgrades. This layout allows for easy backup of the
file systems, and it also allows for easy upgrading to a new system version: when you upgrade
the system, you can install it on the other root file system. It's not a perfect fit for all
applications, though. Ultimately you need to make your own decisions.