Proper sizing of disk partitions

From The Network People, Inc. - Wiki
Jump to navigation Jump to search

Quick Version

If you do not know already what size partitions you need, use these:

Disk Partitions:

 /root    2  GB  
 swap    (2xRAM)  GB 
 /var    12  GB   
 /tmp    1   GB
 /usr     12   GB   
 /home   <the remainder>
/usr needs a min of 4GB: ports(600-2000M), src (500M), obj (1G), & local (1GB)
/var holds logs, databases (mysql, bayesian), email queue

Long Version

Begin by reading man hier and man tuning.

The disk layout shown above will make sense after you have read man hier. Here's a brief explanation of each partition.

/root - contains only the files required by the OS.

nothing that changes regularly should be stored on the /root partition. My intent with every server I build is that, once built, /root will be mounted read only so that it cannot be tampered with. FreeBSD 8.2 with 2 kernels installed takes 521MB, so having a 2GB /root leaves plenty of room for the future.

/var - multi-purpose log, temporary, transient, and spool files

you will fill up /var eventually, so do not fear making it too large. Your main concern is leaving enough space for your /home partition and whatever you will store there. On a small mail server, 1-2 GB might be plenty. On a busy mail server, anywhere from 4-12GB could be appropriate.

/tmp - anything you don't care about losing after a reboot

lots of applications use /tmp for temporary storage, including downloads. I seldom have more than 1MB of data in /tmp but every so often 1GB is barely enough. Having a separate /tmp is much better than having /tmp fill up your /root partition. (panic time!). Another option is to not have a dedicated /tmp partition and instead symlink /tmp to /var/tmp. There are good arguments for doing it each way.

/usr - the majority of user utilities and applications

all of the Mail Toaster applications, libraries, and config files will live in /usr. So too does the FreeBSD ports collection, sources, build objects, and other files. 3GB is just barely squeaking by, and 5GB is comfortable.

/home - user specific files

on a Mail Toaster, this is the place for your vpopmail home directory. All the delivered email messages get stored on this partition. When it is time to scale your vpopmail installation, /home or somewhere below there is the mount point that will get moved onto another (presumably larger) disk or moved off to a dedicated file server.

Here is a some very relevant file system information from man tuning:

The defaults may be unsuitable for a file system that requires a very large number of i-nodes or is intended to hold a large number of very small files. Such a file system should be created with an 8K or 4K block size. This also requires you to specify a smaller fragment size. We recommend always using a fragment size that is 1/8 the block size (less testing has been done on other fragment size factors). The newfs(8) options for this would be ``newfs -f 1024 -b 8192 ....


by David CL: FreeBSD's handbook suggests a laughable 50 MB as the size of /var, and the "Auto Defaults" feature will choose 256 MB. On a qmail server, we strongly suggest allocating at least 1GB, perhaps 2GB. This provides ample room for the queue, the quarantine files, the MySQL installation, the logs, etc.

If your /var slice fills up, your toaster will stop accepting mail, and it will stop logging. Give it a decent amount of space.

by Matt Simerson - This is very good advice. It has been my experience that many system catastrophes were immediately preceded by a drive partition becoming full. Normally, that is not a crisis (in and of itself) but the "repairs" done by the admin can often be devastating.

Save yourself and those who inherit your creations(s) a favor and size the partitions well enough that resizing is not necessary until you retire the server . Consider what you will store in your MySQL database and how much disk space that is likely to use. How many mail users will you have? How long do you want to save logs?

I like to keep a few years worth of mail and web log files around. I have found that particularly useful when I switched log processors and was able to feed the last 3 years worth of http logs into the new one. Think about how you are going to use your server and then size your partitions accordingly.