Sizing Up Partitions

Exploring partition options


Looking at partition choices for different situations, plus resizing.

Partitioning is a basic step in any Linux installation. Many users breeze past it, content to let the installer use a single partition, or else to accept its recommendations without much thought, sparing themselves the stress of learning yet another task. However, manually partitioning can help to isolate directories from each other, optimize performance, and aid in recovery when troubles arise. If manual partitioning takes some extra time, down the line, you might be glad you make the extra effort.

As you probably know, Linux is organized into a series of directories, each with its own purpose. Directories can be on the same device, or else a mount point for a separate device. In either case, users are presented with a single directory tree. Usually, each device will be formatted with ext4, although recent Fedora releases default to Btrfs, or on servers, XFS. On systems that include a Windows installation, an ntfs or fat32 partition is included. Partitioning is done on a blank system, or from an external device so that no partition is mounted. Older tools such as fdisk are still around, but today's most common tools are parted (Figure 1) or gparted, its graphical equivalent.

Figure 1: F1_parted.png: Parted is a comprehensive partitioning tool. For ease of use, you might want to give each partition a name or label.

As an alternative to what might be called traditional partitioning, many prefer a Logical Volume Manager (LVM). Unlike traditional partitioning, LVMs do not work with the space on a single device. Rather, all the memory available on all devices is pooled to create a single source from which to create partitions. The main advantage of LVMs is that they can be edited on the fly, without unmounting them or booting from a DVD or flash external device. Instead, LVMs use commands such as pvcreate, pvremove, or pvmove, although you can also used parted or gparted. Moreover, LVMs, unlike traditional partitions, are not limited to four primary drives plus extended partitions on the same physical drive. However, booting from an LVM partition with GRUB2 requires loading the LVM module into the kernel with insmod. Even more importantly, if a drive fails, crashing an LVM, all the LVMs collapse, and data is unlikely to be recoverable. For this reason, many admins prefer to remain with traditional partitions, which tend not to fail all at once. But whichever partitioning approach you prefer, the same choices of filesystem and size are much the same. Only the details of operation differ – and they are beyond the scope of this article.

Choosing Directory Sizes

The size of every directory does not need to be considered. The directories that matter are:

Root (/) – Not to be confused with /root (the root user's personal directory), / is the top-level directory. Using the ls command or a file manager, it includes every other directory except the swap, although some individuals you may want to resize separately. A rookie mistake is to allocate the majority of the available storage space to /, but in most cases, that is unnecessary. For the most part, Linux applications take up remarkably little space, and exceptions such as LibreOffice are too rare to matter much. Fifteen gigabytes is often enough for a home or dedicated machine, although you might want 25-50GB, depending on what the computer is used for. Much more and searches might become somewhat slower, and considerable space might go unused that could be put to better purpose elsewhere.

Swap – Along with /, the swap partition is one of the two partitions that is always created for Linux. Its purpose is to supplement the system RAM with emergency memory. Although swap memory is slower than RAM, it is still preferable – most of the time – to having overloaded RAM churning away endlessly. But how large should a swap be? The question is endlessly debated. Back in the days when a personal computer had only 1MB of RAM, the conventional wisdom was that a swap partition should have twice as much memory as the system has RAM. Then, when 2-4MB was the norm, a common suggestion was that a swap partition should have half the memory of RAM. With a modern system with solid state drives of 1TB or greater, the guided partitioning of the Debian installer recommends 1GB, which should be enough for almost all uses. If you are doing video or graphic design, or some other memory-intensive work that makes your system grind, you can quickly add a swap file to give you more swap memory.

/boot – This partition contains all the files needed to start the system, including the kernels. Its subdirectories are /boot/grub, which stores the files for the GRUB2 boot manager, and /boot/uefi, which is used by the computer's UEFI system. A small /boot partition of 2-3GB is useful when a boot manager does not recognize /'s file system. As well, should the contents of /boot be corrupted, a backup of a few files can quickly restore functionality.

/var – In /var (short for variable), Linux stores files used during operation, including log files, caches, and lock files. The size of this mount point is at least partially controlled by rotating logs that change whenever the current log reaches maximum capacity. 1-2GB is more than enough for it. Any more and the system can take longer to locate the information it needs.

/tmp – As the name suggests, /tmp stores files that are created temporarily while applications and utilities run. These files are either deleted when no longer needed, or upon reboot. There is no need to manually delete the contents of /tmp, but placing it on a separate partition guarantees that it cannot grow to such a size that there is no storage space for the rest if the system – something which can be a real possibility on an older or smaller system. Should a separate /tmp partition fill, it should be empty upon reboot. However, if /tmp is too small, crashes can become a recurring nuisance, while if /tmp is too large, the system might not find the files it needs efficiently. In my experience, 2GB is usually enough for /tmp.

/home – This directory is the traditional home of regular users' accounts. Its size depends on the number of users, but usually, it stores the really large files on a system, such as music, graphics, and movies, although the popularity today of streaming services makes /home a less populated place than it tended to be a decade or more ago. Still, allotting a minimum of several hundred gigabytes is reasonable on a modern system.

In addition, /home is a good choice for putting on another drive. That way, if you have to reinstall, you can reformat the partitions for the operating system and leave personal files untouched. Just mount the drive as /home, then make sure you do not reformat it during reinstallation, and on first boot the computer will be the same as before.

Partitions for Other Operating Systems

You might want a Windows partition – especially if you game – or multiple Linux distributions on the same machine. Allocate a minimum of 100GB for both Windows 11 and secondary distributions, and more if you plan on using them regularly. Traditionally, additional operating systems are mounted in sub-directories of /mnt, but they could also be mounted in /media, or in top level directories you create especially for them. You will also need to edit GRUB2 to make all the operating systems available when you log in.

Resizing After the Fact

Manual formatting can be complicated, so you might want to plan out your system before beginning. Yet, even with planning, you might miscalculate or find that your needs change over time. Fortunately, though, you can use the same tools to resize partitions or even change mount points. If you are unsure where to begin, you can consult the recommendations for guided partitioning in any installer (Figure 2) and consider whether you need to modify them for your own purposes. All these things can mean that installation takes significantly longer, but in the end, the extra effort can pay off in your system's everyday convenience and efficiency.

Figure 2: F2_guided-partitions.png: Installers' guided partitioning schemes can help you with manual partitioning. Just remember not to apply the suggested scheme unless it satisfies your needs. Shown here is the Debian installer.

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More