pavement

Hard Disk Partition Sizes

From FreeBSDwiki
Revision as of 23:40, 24 December 2005 by Dave (Talk | contribs)
Jump to: navigation, search

Contents

Official Information and Terms

Before we get started, I am acting under the impression that the reader is a relative newbie to the world of FreeBSD, and is attempting to figure out how to partition their disks for the first time. I also assume that the reader is aware of the official FreeBSD documentation related to installing located here: The FreeBSD Handbook Install Section. More aware users will have discovered the partitioning information available under man tuning under FreeBSD 6.0 . By the existence of this page, however, you have also realized that some tweaking to both the default setup and the information in tuning is necessary for many installations.

It is worth repeating that FreeBSD looks at hard disk partitions in a slightly different way from windows and linux. When I refer to partitions in the following sections, I am refering to FreeBSD style partitions, which are a bit different from what you may be used to under linux or Windows. To make a long story short, FreeBSD can hold many partitions inside of a single slice (a FreeBSD slice = a windows or linux partition). This frees FreeBSD from being limited to a rather inconvenient number of 4 or so partitions. Read the handbook carefully for more details

The Default Install

As of FreeBSD 6.0, sysinstall will create partitions sized approximately as follows by default:

/     128MB
SWAP  two times the system RAM
/var  256MB
/tmp  256MB
/usr  remainder of the disk

Many of these partitions are entirely too small, and they are not sized with any thought regarding the usage of the machine. There are a few basic reasons to make a seperate partition:

  1. to nicely size a partition for a wierd backup scheme that cannot handle unusually large backup dumps.
  2. to protect the space needed by something (particularly the base system) from being stepped on by other programs
  3. to limit particularly hungry programs from stepping on the space of everything else.

Some thought about what you are trying to protect, and what you are trying to limit is in order for configuring a system.

One Big Partition

The default install contrasts strongly with a fairly popular partitioning scheme for a system for an individual user:

SWAP  two times the system RAM
/     remainder of disk

Although this can be perfectly appropriate for a personal system with nothing critical on it, this system has two major faults

  • In case of a serious system failure (repeated reboots), the entire drive will need to have it's file system checked with fsck on every reboot. The core systems of FreeBSD do not require very much disk space. Partitions would allow you to only check critical partitions and put off the rest of the checks on the larger partitions until the system is stable.
  • One of the primary reasons to seperate things out, is to prevent one partition from filling up all the space and making other things stop working because they run out of space.

The SWAP partition

This one is fairly easy. The twice the amount of system RAM rule of thumb is a good one. If you have multiple hard disks on the system, man tuning and Partitioning Tips and Tricks#Multiple Disks? Multiple /swap have some good suggestions.

The /tmp partition

It is extremely common for this partition to be undersized. This partition is used in building ports, and several programs will keep fairly large temporary files here. You want to make it a seperate partition:

  • To protect the system from either a very large port compile (such as the larger windowmanagers or an X graphical interface system)
  • To prevent a run-away process that is simply filling the disk with as much data as possible from infringing on your / filespace.
  • To minimize the probability that the often-accessed /tmp directory will cause excessive file corruption on your / partition in the event of a crash.

The danger of making this partition too small is that you will cause yourself unnecessary greif when you want to build a large package or when a program you are running needs alot of temporary space (such as a video editor).

If you are not installing a graphical system and are unlikely to be editing large files, a fairly small tmp should work fine. Even compiling the larger ports should work inside of 128MB-256MB of tmp. If you will be editing either large numbers of image files or video files on the system (or other large files), a large sized tmp partition does seem more reasonable. A bit more than two times the largest file size you are likely to be editing would seem to be a reasonable limit.

The /var partition

var also depends highly on your intended use of the machine. Email, logs, the default mysql databases, another tmp directory and print spooler information is held subdirectories of this partition. You may want to seperate this off to prevent logs or emails from overrunning the system. You may also want to protect emails or the db from other potential problems. (and thus give them their own partition) If you are not running a server, or it will not be very busy, this can often do without it's own partition.

The /var/tmp directory

The /var/tmp directory can be deleted, and replaced with a soft link to the /tmp partition (or vice versa). This can be done with either ln -s /tmp /var/tmp or ln -s /var/tmp /tmp as root. This is recomended since there is essentially no difference between /var/tmp and /tmp on modern systems, but some programs use one instead of the other.

The /usr partition

The /usr partition contains contains a few major sections. There are a few approaches to this section. One is to give it it's own largish partition. Second is to lump it into the main / partition (and either move the ports tree or watch it's size carefully). Third is to split off several sections either into their own partitions or to symlink them from the / partition to a larger partition. Tuning recomends up to 3Gigs for /usr if you are going to have X installed with source, but I personally feel this would be a little bit limiting. 5-10 gigs seems more reasonable if you have the room.

The /usr/src/ directory

This contains the source code for the operating system, this is needed if you want to do a source update of the operating system via cvsup at some point. This really shouldn't have it's own partition, seperated from /usr.

The /usr/ports directory

By default /usr/ports contains the ports collection. /usr/ports/distfiles, which contains the packaged ports downloads, can grow quite large on a system that has many ports installed. On the other hand, you can keep it under control manually by deleting things periodically. Most ports do some of their compilation and install work in their own directories, however, and this will require a bit of stretching room.

The /usr/local directory

This contains most of the files related to installed ports, in addition to your personal configurations in /usr/local/etc. This will need to be roughly sized with whatever you are installing. It will be very large for an X system, but fairly small for a simple ftp server.

The /home or /data partition

Assuming this is not a firewall or similarly specialized machine. Users (even if it is only yourself) will likely log in and want to use files. This partition, not created by the default install, is often given most of the disk. This is particularly true for personal servers and personal machines, which are likely to keep most of their files in this partition.

The default partitioning scheme follows the idea of creating a link from /home to /usr/home, and giving /usr most of the disk. The problem with this is that /usr is needed to bring a system up, and in a situation where you may have as much as 250gigs (or more) of space under /usr, it will take quite awhile to file system check before you can bring the system up to check it. Which is particularly bad if you're having consistent crashes. One way to deal with this is to give /usr and /home their own partitions -- if /home has it's own slice, it will not be made a link to /usr/home during the install.

Other Information

You may also want to look at Partitioning Tips and Tricks#Make yourself a tiny little partition for /mnt.

Personal tools