What are the advantages and disadvantages of mounting various directories on separate partitions?
While installing Ubuntu with the “something else” option, I found out that there are many folders that can be mounted on separate partitions, as you can see in the image below.
So what are the advantages and disadvantages of mounting these folders(or directories) on separate partitions?
Specifically the directories are
Space management and backup.
If your system have many users you can make additional partition for /home/, then users will not exeed that space and root (/) will not be affected.
You can also mount NFS, SMB or partition on other physical disks on those folders. For example :
/dev/sda1 /boot (1GB)
/dev/sda2 / (60GB)
nfs://IP/folder /home ( X TB )
/dev/sdb1 /var (1TB for /var/www or /var/ftp)
/ on m-sata (fast)
/var /home /opt /tmp on hdd (slow)
Generic advantages of having multiple partitions:
- You can use different disks/LUNs and have better performance. This can increase the performance of databases as you can have the transaction log on a storage and the data files on another. Similar for disk I/O intensive web applications.
- You can use different mount options (that increase the security or affect the performance/stability in a more granular way).
- You can have different filesystems.
- You manage the space separately. So you can have a nasty application that fills the space that does not affect other applications.
- Fragmentation of one partition is independent of the other.
- You can snapshot, mount, unmount, format, defragment, monitor for performance of those file systems independently.
- You can have encryption on specific volumes.
- You can mount volumes on demand.
- You can see I/O statistics per each block device.
Generic disadvantages of having multiple partitions:
- It increases the administration overhead.
- You will have greater chances of wasting more disk space.
- You will have more incidents involving disk full.
- It is more difficult to create a consistent snapshot of an application running on different volumes.
- It uses slightly more resources.
- Difficult to shrink. Depending on the volume type (MS-DOS label, LVM, btrfs…) you might not be able to easily allocate space from a volume by shrinking another. Especially online.
- If you partition so that you can use
noexec, this setup can be too limiting and you can obtain better granularity with
AppArmorand just use a big
- If you use old partitioning tools you can get "creative" and misalign partitions with underlying extents. Some disk arrays can detect this and compensate.
- If you use all 4 primary partitions on a MS-DOS disk label, it will be difficult to create new partitions.
Another way to partition your system is to use
/. Allocate just the minimum space for
/ and when needed create logical volumes or extend
/. This leaves you the choice to split in volumes at a later time and has lower maintenance costs.
When you have a new disk volume (disk, disk array, SAN LUN) you can use different disk labels (some can be mixed on top of the other):
- MS-DOS disk label. It is phased out, but still supported in a lot of machines
- GPT. Used with EFI/UEFI, it is similar with MS-DOS disk label, but removes some limitations and adds some stability (backup, checksum)
- LVM – used in Linux, recent versions of GRUB can boot a kernel located on LVM. Most of the people are using it on top of MS-DOS or GPT disk label, but I prefer to use it directly on the volume. This gives me the best flexibility.
- other disk labels (BSD, SUN, Windows Dynamic Disks) may be used if you want to annoy your teammates.
- ZFS, Btrfs – are integrating a filesystem with the volume manager
- format directly the volume with the file system you need. No disk label, like floppy disks.
Now specific stuff:
/bootis good to be a separate partition. The file system must be one supported by your boot loader (usually GRUB).
- If you use EFI/UEFI it is a requirement to have a EFI system partition on a GPT disk label.
/homeis good to separate the user stuff from the OS and applications.
/tmpcan be mounted with
nosuid. It can be a memory mapped file system like
/usrcan be mounted read-only and only remounted RW for updates, it can be remote like a NFS share.
/srv/optwill store the application and application data. If you have an I/O intensive application you can use better disk subsystem (e.g. SSD)
/usr/localis the default used by applications installed locally on the current machine. For example you have everything else on NFS and have a local disk…
There is no perfect solution. If you have no clear reason why to create a new partition, then don’t. The only partition you might need to create besides
Try to use as few partitions as possible and allocate for them only what is required in near future (4-6 months). You can add more and expand them if needed. Use
Btrfs directly on the disk volume, if possible. This gives you the best flexibility.
For desktops/laptops, it is nice to have
/home on a separate partition so that you can reinstall the OS independent of your data.
Long long time ago…
… There was a time when people used to install Linux and configure it by hand for their specific needs. Some of this is true even today for servers. The choices you see in
gparted are some of the popular ones for those who had very different needs as compared with the average desktop users, the intended audience for Ubuntu desktop.
Let us take these one at a time. I will skip the ones I don’t know much about.
/bootThere was a time when the Linux file system was fragile and hard drives were small. People were afraid that the hard drive would fill up or get corrupted and Ubuntu would’t boot. Keeping the kernels in a separate partition helped the system to boot when other things went wrong. In those days, Linux users used to compile their own kernel and clean up old ones. As recently as with Ubuntu 16.04 LTS, the Software Updater app installed the latest kernel update but did not remove the old kernels. As a result, a small
/bootpartition filled up with old kernels, and the system stopped booting unless one cleaned it periodically. See what happened if you had a separate
/bootpartition and forgot to clean it regularly: How do I free up more space in /boot? With Ubuntu 18.04 LTS the Software Updater app not only keeps the system up-to-date, but also removes the old kernels. It keeps the last two kernels in case the latest kernel has some issues and one needs to revert back to the previous one.
- On the other hand, if you want to encrypt the
safeguard the secret software you are working on), you will need a
separate (and unencrypted)
/bootpartition. Otherwise the system
won’t boot. Similarly, if you have a RAID drive, keeping
/bootin a non-RAID partition may be useful. Many people thinks having a separate
/bootpartition is a very good idea for these and other reasons.
/homeKeeping home in a separate partition still makes some sense. This folder/partition has your personal files and having it in a separate partition allows you to format
/and reinstall Ubuntu while keeping your files untouched. Recent versions of the Ubuntu installation software includes a choice of update from DVD/USB. This option keeps
/homeintact even it it is not on a separate partition. If you run out of space in your primary drive with
/partition. You may want to add a new drive and create a single
/homepartition in the new drive.
/tmpis where temporary files go. If you are running a server that creates large temp files, they may fill up all the disk space and bring your server to a halt. Keeping it in a separate partition will only fill up that partition and may stop the process that was creating the big temp files but will not stop the rest of the system. I am told it is easier to deal with a filled up
/tmppartition than a temporary folder under
/usr/localare all places where programs and apps are kept under different conditions. If you develop software for Linux, it may make sense to keep these in separate partitions, so that if you reinstall Ubuntu, you won’t delete the programs you have written or have been working on.
/usr/localin separate partition also makes
sense if you install programs from source (your own or from
somewhere else) and want to use them in another distribution (say
Red Hat) installed in the same computer in its own partition. Then
both the distributions, Ubuntu and Red Hat can share the
/usr/localpartitions. (Thanks Rmano!)
/varare particularly useful as separate partitions if you run servers or develop web pages. For the average desktop user these folders don’t take up much space and does not hold anything that is of value to the user. For a web developer losing
/var/wwwmay mean losing her job.
To be sure, these are not the only directories one can mount as partitions. In Linux, one can mount a partition as any folder anywhere. Partitions are often mounted as sub-directories of
Hope this helps
przemo’s answer, imo, most closely hits the practical points. Here are some additional practical considerations:
Enterprise environments typically use separate partitions for at lease / , /home , /opt , /var , /boot , and additional filesystems (1 per application or application team) under /opt. This is primarily to avoid running the system out of space because of someone home directory getting massive (/home), logs going out of control (/var), or apps consuming tons of space (/opt , /opt// , etc), and /boot so that the other partitions can be built in LVM and also to ensure you can get something of a recovery shell should the primary system partition become corrupt for some reason.
For my own personal non-server uses, I just keep separate / , /boot , and /home partitions so that I can dual boot multiple Linux/UNIX OS’s and use the same /home partition for them.
In the case of building a VM in Oracle Virtualbox, VMWare Player/Workstation/Fusion, etc for personal use, there really is no practical reason to have multiple partitions with different mount points on account of the nice folder sharing capabilities provided by at least VirtualBox and VMWare Player/Workstation/Fusion. The single exception might be /boot for the recovery shell reason given in my “enterprise environment” paragraph.
If something goes really wrong during update or major version upgrade, having /home on a different partition allows you to boot from CD and then wipe completely and reinstall the operating system without losing your data. Also, this makes multiple boot with various Linux distributions possible, some people like to evaluate these side by side.
In addition to the existing answers, you may have non-standard/common compatibility and performance use cases that benefit from different partitions.
You may want to share data with another operating system such as Windows and need to use a filesystem that both Linux and supports.
You may have specialist use cases that allow you to have different tunings (of the same type of file system, such as an EXT4 partition for lots of small files and an EXT4 partition for few large file (such as virtual machines), its possible to optimise storage and performance for both use cases.