You took the plunge.
You painstakingly taught yourself to select, download, and begin installing a Linux distribution.
You were proceeding through the installer like a pro until you came across a page like this:
And a flurry of questions boiled up in your mind. WTF is a partition? What am I supposed to click? What filesystem do I want to use? Do I want to erase everything by formatting this disk? How much wood would a woodchuck chuck if a wood chuck could chuck wood?
Even those familiar with partitions are overwhelmed by this page the first time. We’ve all been stumped by it. But worry not! By the end of this post, you’ll breeze through this page like Linus Torvalds himself.
WTF Is a Disk Partition Anyway?
Partitions are a solution to a problem. What problem is that? Well, out-of-the-box, computer storage devices have one giant block of storage space on them with no way to separate content. But you probably don’t want one block of space. You want to create divisions used for separate tasks, and there are two options.
The first is probably familiar to you. You create folders, or directories in Linux-speak, to organize data. You may have a directory called Documents where you put your documents. And another, called Blackmail, where you store compromising information on powerful people (we don’t judge here). And that’s very handy.
But there is another way of chopping up storage space, called partitioning.
Let me explain partitioning with an analogy. Think of a filing cabinet. The filing cabinet’s purpose is to store folders and files. To make organization simpler, it comes with multiple drawers. The drawers break up the cabinet into smaller, distinct filing spaces.
Well, as with filing cabinets and their drawers, partitions divide up a storage device into smaller, distinct storage spaces.
The difference between a partition and a directory is that a partition effectively becomes its own storage device. If you were to partition a 2 terabyte hard disk into two equal sections, your computer would act as if there were two 1 terabyte hard disks in the machine. Directories are merely logical containers to hold stuff.
While there are many applications for partitions, one of the most useful is separating multiple operating systems. Operating systems are monolithic instruments. They want full control over their kingdom, and don’t like sharing. Giving each operating system its own partition means they get their kingdom, but don’t conflict with each other.
In this era of cheap, large storage devices, partitioning is more useful than ever. A modern hard disk can store several operating systems and all your files simultaneously with room to spare.
Visualizing Partition Layouts
When I started messing with partitions, it was mindbogglingly confusing. I understood the general principle, but couldn’t picture what was going on in my head. While frustratedly Googling one day, some random person explained a simple way to visualize partitions (thank you whoever you are). And now I’m going to pass it on to you. Here’s the method that cleared up my partitioning migraine.
Picture your storage space as a circle, or pie if you will. If you do not divide your disk into multiple partitions, the entire circle is for one task. Perhaps it’s a place for a Microsoft Windows installation:
But now let’s say you want to run both Linux and Windows by setting up a dual-boot system. During the setup, you will divide the space into multiple partitions and your circle looks more like this:
And this is wonderful. But, creating a single storage area for files needed within both operating systems would simplify your life. So you can throw on a third partition for storing data that both operating systems can reach without fighting each other:
Something as simple as visualizing a circle and dividing it into chunks cemented the concept in my mind. A similar way to visualize it is to use a bar instead of a circle.
The bar uses the same principle, but is more compact and easy to draw. Personally, I’ve always been partial to the circle. Maybe because of the pie thing. But, both are perfectly valid. Pick your favorite!
Setting the Partition Table?
Storage devices have special sections on them that store its information. One of those sections is a table with partition information. While there are many partition table types, modern PCs typically use one of two types, MBR or GPT.
The newer table type is GPT. That stands for GUID Partition Table. The older type, MBR, stands for Master Boot Record. Occasionally, MBR is referred to as MSDOS due to its close relationship with the old DOS operating system.
If you are completely erasing, or setting up a brand new storage device, the computer may ask which partition table you want.
Choosing a Partition Table
As you can see, there are a lot of options. But, you should restrict your choices to MBR (called MSDOS in the picture above) and GPT. The others are old, discontinued, or used in special circumstances only.
There are a lot of subtle distinctions between MBR and GPT, but most do not matter to the end-user. The only practical concern, are the limitations of the two.
MBR’s biggest limitation is the maximum size of the storage device. MBR only handles up to 2 terabytes. Considering how cheap and common hard drives over 2 terabytes are, this is a significant problem.
GPT takes care of MBR’s limitation. It supports up to 9.4 zetabytes (5 million times bigger than 2 terabytes). However, as it is still in the early adoption phase, GPT isn’t supported everywhere. Older computer hardware won’t recognize it, and older operating systems won’t work with it.
If you are using a current operating system, on fairly recent hardware, GPT should work, and is worthwhile. However, if backwards compatibility is important, sticking with MBR is your best choice.
What Partitions Do I Want For Linux?
When you install Linux, you choose which partition will store the contents of noteworthy directories. Rephrasing that in geek: “it’s asking you to choose the mount points for the partitions.” If you don’t know what the hell I just said, you may want to skim the following articles:
- The Essential Guide to Linux Filesystem Organization – Covers the directory structure of the Linux operating system. It will discuss those “noteworthy directories.”
- Mounting Filesystems – Covers how Linux accesses data from partitions by explaining what mounting and mount points are.
- WTF Is a Swap Partition – This article will teach you what swapping is and why having a swap partition is a good idea.
The short version of those articles is this: In Linux, you access partitions by “mounting” them to a directory. Then, for all intents and purposes, the contents of the partition are accessed through that directory.
During installation, you decide how many partitions you want, and which Linux directories are mount points for those partitions. If a directory is not a mount point, then it is a normal directory in the root partition. If it is a mount point, then the directory is merely a gateway to the partition.
Linux requires at least one partition, and it must be mounted to root (/). It is also a good idea to have a small swap partition to help with computer performance. This means two partitions.
If so desired, every directory can point to its own partition, though that will likely get you into trouble. Instead, there are a few commonly used partition schemes that don’t typically cause problems. Each has its pros and cons, which I’ll list below.
If this is your first foray into Linux, I recommend you keep things simple and go with either the two or three partition options below. Once you gain a little more familiarity with partitioning, and Linux, then you can branch off into more advanced setups, like 6 partitions, or mix and match to make it just the way you want it.
2 Partitions – Keeping It Simple
With this scheme, the entire operating system, and all related files, go in one partition. And we have that small swap partition. This is the most basic setup you will likely encounter.
- Simple to conceptualize.
- Easy to configure.
- Requires little planning.
- Personal files and settings are lost during operating system changes.
- Difficult to place limits and quotas on storage space.
- Files and settings are on the same partitions as the operating system. This makes recovery and repair of corrupted or broken installations, without data loss, difficult and dangerous.
Due to the simplicity, this setup is ideal for Linux newcomers and throw-away installations. But, for a regularly used machine, with important data and files, investing the time and forethought required for a more complex partitioning scheme is worthwhile.
3 Partitions – Still Simple, But Much Better
This partitioning scheme adds an extra partition which holds the /home directory’s contents. In my opinion, it is the best choice for most Linux users.
- Personal files and settings are not affected by operating system upgrades, reinstalls, deletions, or corruptions as they are on their own private partition.
- Allows for a multi-boot Linux system to use a single, centralized location for settings and files by making the partition mount to /home in both installations.
- You can easily use partition size to limit the amount of space taken by both the operating system (by sizing the root partition) and the user files (by sizing the home partition).
- Requires planning space requirements and allocation.
- May require partition resizing if initial allocation becomes insufficient or wasn’t done correctly.
- Requires manually mounting more than one partition if not setup during installation, or if accessing files from another operating system.
This partition setup requires a bit more forethought, but it is safer because your files and settings are separate from the operating system. For most Linux users, this partition scheme is the best choice. It’s flexible, yet simple. This is what I typically use on my personal machines.
6 Partitions – Because Size Matters
If you’re thinking “to hell with moderation! A true Linux user is never satisfied with good enough,” then this choice is for you. Yes, 3 partitions fills the needs of the average user. But 6 partitions gives you more control and flexibility.
- All the benefits of 3 partitions.
- Using partition sizes, this scheme allows granular control over the storage space used by various components of the operating system. For example, you can keep log files from getting out of control by limiting /var, or prevent too much software from being installed by carefully sizing /usr.
- Easily experiment with custom kernels or single kernels for multiple distributions with a separate boot partition.
Similar to 3 partitions, but more pronounced due to the extra partitions.
- Serious planning is required.
- Will likely need partition sizing changes as your needs and requirements evolve.
- Requires manually mounting multiple partitions if not setup during installation, or if accessing files from another operating system.
This setup requires a lot of forethought and planning to execute correctly. For most users, it is overkill, and for new users, it adds an unnecessary layer of complexity. If you become a Linux professional and oversee servers or manage large Linux networks, complex setups like this can simplify your life. For your own personal computer used to play Creeper World, it isn’t worth it.
Unfortunately, we’re not done. There’s still one major knowledge hurdle to overcome. The filesystem.
To store data, partitions need filesystems. A filesystem controls how partition data is stored and retrieved. Without it, the computer can’t tell where in the partition files and other items start and end. I liken a filesystem to a table of contents. Except, instead of documenting what chapters, headings, and page numbers are in a book, it stores file and directory information and points to its place in the partition. Without that table of contents, your computer won’t know where to look.
You can make a partition without a filesystem, but that’s like designing a car without an engine. What’s the point? Instead, when creating a partition, it is usually formatted with a filesystem.
There are different types of filesystems. Current versions of Microsoft Windows use the NTFS filesystem, and Apple’s OS X uses the HFS+ filesystem. The most popular Linux filesystem is called ext4. Note, however, that Linux has many competing choices and each has a loyal following. In a future article, we will tackle choosing a filesystem (give a shout out if you want us to hurry up and write this). For now, stick with ext4 for Linux.
Creating and Modifying Partitions
BACKUP, BACKUP, BACKUP, BACKUP, BACKUP, BACKUP, BACKUP! Whenever you mess with partitions, there is a risk of something going horribly awry. And when partitioning goes awry, the data in a partition, and sometimes on your whole storage device is at risk. Copy your important files to another storage device before going on.
Hope for the best, prepare for the worst!
Odds are everything will go smoothly, but computers have an evil streak, and will ruin your day without proper precautions.
Operating system installers provide tools for creating and changing partitions. But if you mess with partitions outside an installer, you’ll need a partition manager.
Using Operating System Provided Partition Software
Most operating systems include a basic partition manager. Microsoft Windows has a program called Disk Management. Mac OS X has a program called Disk Utility. And Linux has several tools depending on your distribution (GParted is quite popular).
But the problem with these tools is they require you to boot into the installed operating system to use them. And modifying partitions that are actively used, like the one(s) running your operating system, is problematic and not always possible.
These operating system managers are great for other storage devices, or partitions not used by the currently running operating system. But, if you want to change active partitions, they aren’t very useful.
Linux to the Rescue
To get around this active partition problem, you need to get out of your normal operating system. The easiest and completely free way to do this is to download a Linux Live distribution. Most Live distributions have partitioning software built-in, and if not, you can easily install one.
Partitioning can get a little weird. Sometimes it works simply and beautifully, other times it becomes a horrendous headache. If you plan on running a multi-boot system, necessity will turn you into a partitioning master. If you just dabble with a single copy of Linux in virtual machines or on a test machine, you will rarely deal with partitions.
However, even if you don’t need to master partitioning, you should. Join the dork side. Be a hopeless geek.
You can make it easy on yourself by using a virtual machine. Then you won’t put any important data at risk. Simply create a new virtual machine, with a new virtual hard drive and partition away. If you break it, wipe it and start over. No harm done. If you get sick of it, delete it and it’s out of your life. But the more you experiment, the more you will learn.
Oh no! I almost forgot to address one of the questions from the top of this article… with regards to the woodchuck: he would chuck a quart of conifer if you gave him a quarter for every quart he cut.