06 June 2007

How many disklabel partitions should I have?

In a previous post, I talked about my typical disk layout. I don't do anything radical. From the standard, auto-defaults I eliminate the "/tmp" partition, linking it back to "/var/tmp", and then tweak the sizes of the partitions, based on factors like the machine's future role and total space available. To be clear, I'm just talking about the file system partitions here, not the swap partition(s).

Why change the layouts, why does it matter? If you've got a big disk, why shouldn't you make lots of partitions?

The problem with lots of partitions is that it creates bottlenecks. Rather than having your entire disk available, you really only have the space in the partition that is being used at the time. Exceed that and you'll get the dreaded "warning: filesystem full" message and probably application errors. So, in the absence of any other information, the best partition layout is one big partition for the entire disk. That's our starting point.

Right away, however, there is another partition that we should separate from the single mega-partition: we should have a separate root partition ("/"). The first reason for this is that FreeBSD is laid out in such a way that the essential files and utilities will normally end up in the root partition. "/etc", "/bin", and "/sbin" should all be under the root partition and then they will be easily available for booting, for use in repairing the other filesystems, and what have you. Historically, part of the idea was that perhaps you couldn't even mount the other filesystems before you'd used the various utilities on the root filesystem to repair them. That may not really apply in the same way now that we have background fsck. There've also been concerns about enabling soft updates on the root partition. See here, for example -- and even that (the FAQ) discounts those concerns somewhat.

So, what's the bottom line? Upon examination, none of the issues with a single, large, filesystem partition appear to be critical -- you probably could lay out your disk that way and it probably would work fine. But, I haven't tried that, and I maintain that having a separate root partition is still the best way to go, even if it's less crucial than it once was. The important thing is you have nothing to lose by making a separate "/" partition and several things to gain: faster booting and better recovery and repair, for example.

On all of my machines I will also add a partition for "/var". The rationale for this is precisely that it is a bottle neck! I wish to isolate the logs and mail spool and other write heavy applications from the rest of my disk so that if(/when) things go wrong, it won't fill the entire disk. This is a double-edged sword, of course. If you stuck with just two partitions (root and everything else) you'd have a lot longer to notice a run away log. But, I've found BSD to be very resilient to a full "/var" partition. (I've also found that it's good to have some alerting for high utilization. :) )

Another rationale for the separate "/var" partition is to allow FreeBSD to optimize the I/O of those files. Chapter 2 of the Handbook puts it like this:
"Putting these [/var] files on another filesystem allows FreeBSD to optimize the access of these files without affecting other files in other directories that do not have the same access pattern."
... Which makes sense since "/var" will presumably have many small writes, unlike the other file systems.

And, voilà, the rest of the disk should be dedicated to the "/usr" partition. Since "/home" is linked there and all third-party software is installed there by default, you're probably going to need all that space.



Post a Comment

<< Home