Linux Storage Partitioning and Formatting Scheme

Here is my usual Linux storage 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 storage 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).

partitioning and formatting scheme
mount point size filesystem

primary 128MB EFI-32
2*RAM swap

logical
/ 35GB ext4
/usr/local 1-5GB ext4
/opt 5-50GB ext4
/home the rest ext4

storage label type

For system storage, this should be gpt (GUID partition table). It is necessary for any drive bigger than 2TB in size, and for modern UEFI-based operating systems. The dos storage label is useful only for antique hardware and operating systems.

filesystem type

A couple of storage partitions must be formatted in a specific way. See below. The others could be formatted for a variety of file system types.

One of the coolest features of modern Linux systems is support for the “journallng” file systems, e.g. ext4. A consistency check of such a file system takes less than a second to complete! And my experiences has been that they are much less prone to corruption than older filesystems were.

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.

EFI partition

The EFI System Partition (or ESP) is used by modern UEFI based systems when the system is booted up. It is a replacement for the older MBR (Master Boot Record).

This partition must be the first primary partition, and its “boot” flag must be set, and it should be formatted as VFAT-32. Linux systems use very little of the ESP — only a few MB. 128MB should always suffice. Some Linux systems recommend 512MB, however. 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.

In Linux, this partition is mounted on /boot/efi.

Note that the security options in the computer’s firmware strongly affect UEFI. Incorrect settings will result in failure to install a bootloader or failure to boot. Unfortunately, the settings depend greatly on the device.

swap partition

The swap partition is used as fallback when RAM memory is exhausted. This is a situation to avoid, of course — but it’s really important that it is present, to give the system a chance of recovering from a case of excessive memory allocation. But also, the swap partition is used for the “hibernate” function on portable computers, where the current memory image is copied from RAM to the swap partition. For this, it’s important that the swap space be much larger than the main RAM.

other partitions

The “root” or / partition is where the main operating system files go. Modern Linux distributions require some 5GB, and a reasonable installation of application software will triple that. Some extra room is needed, too, because temporary files are written here for various reasons. Also, the size of all this software is only increasing over the years.

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, and a single third-party compiler suite occupies several gigs these days. If you expect to build a lot of your own software, a larger /usr/local might be in order.

For server systems, 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. Such issues are usually unimportant for a private system, however.

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. One option is to just put a link from the default location to a directory in /home, which is backed up regularly.

partition labels

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.