Linux Desktop: Alternative Disk Layouts

Installing Linux on the desktop has largely become a “no brainer”. The installation routines of all major distributions have really matured to the point where you literally answer a few basic questions (a little more involved than Windows, but not much) and then you have a fully functional Linux desktop. However, that ease of installation has come with a bit of a price. Installing your system with the defaults can limit your flexibility when it comes layout and segregation (for backups). Today we will talk about some of the options for laying out your desktop storage a bit more “old school”.

First Stop: Think It Through
So, it’s easy to just put all your storage on your primary disk under the root (“/”) partition, most commonly referred to as “/dev/sda1” (remember that Linux refers to everything, devices included, as files or folders, albeit with special attributes). One of the most common problems with this kind of setup is that it can cause a number of issues if you fill the drive completely. The root partition is notoriously sensitive to disk space. If you fill the root partition completely, you can end up with a system that you cannot log into. The recourse for that is to boot to rescue mode, mount the partition and try to remove some files.

Let’s line up some items and assign some percentages to them for disk space on a single drive (we will talk briefly about multiple drives later):

 

    • /boot – recommend giving it 1-2gb rather than a percentage, this will allow all your boot configuration files and compressed kernel images to be stored here

 

  • / – 10% – 20%, since we are separating all the other major disk use categories, you only need enough here to hold the initial OS and updates
  • /opt – 10% – 30% depending on the number of third party applications you intend to install, common applications that install here include Adobe apps, Cisco apps, third party IDEs (like Eclipse when not installed through the distribution repositories), etc
  • /home – 50% of your disk, this is where most of your files on a desktop are going to live, your videos, music, pictures, documents, etc, etc
  • /var – 10 – 20% depending on whether you are going to run a local database (MySQL or PostGRES), which stores their data files here… this is one of the more common directories that can cause a disk to fill (log files), so separating it from everything else will keep your system usable in the event of a storage event

Mount It Up
Let’s take a look at a typical /etc/fstab file that lists all our partitions and mount points:

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 228M 18M 199M 9% /boot
/dev/sda2 15G 4.3G 11.6G 32% /
/dev/sda3 20G 16G 3.1G 84% /opt
/dev/sda4 26G 7.4G 17G 31% /home
/dev/sda5 10G 1G 9G 10% /var

Great, so we have our system installed and our space separated. Will make it easier to backup later AND will to make changes to the layout if we need to increase space later. Keep in mind that if you want to greatly expand your disk space (say adding a new 500gb disk for use just as your /home partition), you can do so easily now. Once you have the drive formatted, you can mount it in a temporary location, ‘cp -rf /home /mnt/home’ and then substitute the drive and partition number in your scheme and reboot. Your /etc/fstab may then look like this:

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 228M 18M 199M 9% /boot
/dev/sda2 15G 4.3G 11.6G 32% /
/dev/sda3 20G 16G 3.1G 84% /opt
/dev/sdb1 500G 7.4G 492.5G 1% /home
/dev/sda5 10G 1G 9G 10% /var

Final Thoughts
One of the key features of Linux is the infinite flexibility and control you have over your operating system. Although Linux will never force you to do things a certain way, we have begun to fall a bit into the “Windows” conveniences and just forgotten to take a few extra minutes to get the most we can out of our systems. Leave a comment below and let everyone know what you do when you install your favorite distribution.

Terrence T. Cox

A veteran of twenty years in Information Technology in a variety of roles. He has worked in development, security and infrastructure well before they merged into what we now call DevOps. He provides training in Linux, VMWare, DevOps (Ansible, Jenkins, etc) as well as containers and AWS topics.