Linux Disk Partitioning and Formatting Scheme

Here is my usual Linux disk partitioning/formatting scheme.

It is crucial keep /home the directory on a separate partitions from the system directories. For those who install third-party software, it is also important to keep and /usr/local and /opt separate. This is because the act of replacing the system will re-format the partitions of the system directories. You don’t want to lose your personal files or your non-distribution program installations in an upgrade.

When you format your disks this way, you can do a system upgrade by only backing up the /etc directory (this must be replaced in an upgrade, but a copy facilitates getting your system settings back).

One of the coolest features of modern Linux systems is support for the “journalling” file systems, e.g. ext4. A consistency check of such a file system takes less than a second to complete!

One advantage of ext4 over other journaling filesystems is that it is compatible with ext2, so files an ext4 filesystem can be read by an older operating system that only knows ext2.

Partitioning and formatting scheme

mount point size filesystem

primary 128MB EFI-32
2*RAM swap

logical / 25GB ext4
/usr/local 1-5GB ext4
/opt 5-40GB ext4
/home the rest ext4

The EFI-32 (really VFAT 32) partition (called a BIOS boot sector) is used by modern "UEFI" based systems and is a replacement for the older MBR (Master Boot Record). It may also be useful to have this partition start above the 34k point, to give space for an old style MBR if it's needed. This partition must be the first primary partition, and its "boot" flag must be set.

Other notes:

Non-distribution software will usually install itself in the special directories /opt or /usr/local. It is worthwhile to make special partitions of these, so they will survive system updates. The size depends on your use of them. Most modern third-party software now goes in /opt. If you build a lot of your own software, a larger /usr/local might be in order.

For servers, it may be a good idea to put /var and /tmp onto separate partitions. In contrast to the rest of the system directories, these undergo frequent writing; the hardware may be "tuned" for this special use to improve efficiency. Also, server programs may write into these directories in response to the actions of unknown users. So there are also security reasons for separating them physically from the rest of the system. These issues are usually unimportant for a home system.

Another concern with back-ups is that some servers prefer to put their data files in system directories: MySQL puts its files in /var by default. You need to take care that these aren’t wiped in a system upgrade. I usually just put a link from the default location to a directory in /home, which is backed up regularly.

It is very handy to "label" the partitions, to put a human-readable name on each. Labelled filesystems are much easier to identify in case of system problems and reinstallations. Labelling is done using e2label and fatlabel, and can be done only to unmounted filesystems.