Intro to Partitions
If you want to change the partition scheme of your hard drive, and/or Dual-Boot multiple operating systems on the same computer, you’ll likely encounter a LOT of terminology you’ve never heard of before. The goal of this post is to give you a 30,000 foot view of the entire process, and help you understand most of the terms you might encounter, as well as a rough idea of what’s actually happening. We’ll talk about the following (at a very, very basic level):
- Partitions and Hard Disks/Drives
- Primary, Extended, and Logical Partitions
- Swap Space
- File Systems
- BIOS and MBR
- UEFI & GPT
Note: Feedback and corrections are appreciated! Leave a comment!
Partitions and Hard Disks/Drives
Most computers come with a single “Drive” with one or more “partitions”. This is all of the space where you can put important cat videos and selfies.
Think of your computer as a giant pizza. The entire pizza is the “Drive”, and the pizza slices are the “partitions”. If the pizza hasn’t been cut, it’s only got one ‘partition’. This partition is usually flavored “Windows” or “Apple” by default.
If there’s enough unused space on your computer, you can cut this pizza in two or more pieces, and give the other pieces their own flavor (like Linux). You can cut the pizza many ways. The point is it’s flexible, and you can re-size and add/remove partitions how you want (for the most part.)
There’s also removable/external drives, like CD/DVD’s, USB sticks, and SD cards. These are their own separate (usually smaller) j”Drive”. they are more portable, so you can easily access your cat videos from any computer it’s plugged into.
In the pictures above, you can see a Flash drive with Ubuntu installed on it. (Disk 1 Removable)
I’ve never bothered to cut these into multiple partitions, but I’m sure you can! When you install an OS, you typically boot up into a CD/DVD or Flash drive, instead of your actual machine.
Here’s another example on Ubuntu’s terminal. Unfortunately the fdisk command is a little more difficult to read. The “Disk /dev/sdb” section is the removable drive part. The fact that it has an /sdb instead of sda/ gives us the hint it’s a separate drive.
Why would you want multiple partitions?
There’s quite a few reasons. Maybe you want to use both Windows AND Linux? Photoshop and Gaming on Windows, coding and everything else on Linux? Or maybe you want a backup “recovery” partition so you can restore a default Windows installation if you break something. Maybe you want a separate partition to store all of your super important data? You may also want a partition that is compatible with multiple OS’s. (exFAT can be read and written to in both Mac and PC)
Primary, Extended, and Logical Partitions
Primary partitions are the ‘major’ partitions you have on your hard drive. Extended and Logical partitions are created because of the flaws in the design of BIOS/MBR systems (We’ll get to those soon!) A BIOS/MBR system only allows you to have 4 primary partitions. If you need more than 4 partitions, then you’ll have to make one primary partition into an “Extended partition”. Within that “extended partition”, you can create many smaller “Logical partitions”.
However you slice and dice, you just can’t have more than 4 “Primary” partitions. (Also a 2 Terabyte limit for the total hard drive)
Swap Space is an area of your hard drive that Linux uses when the system requires more memory than is physically available. The Linux kernel will be able to swap out pages used less and move them to the “swap space” so the currently running programs can use the freed up memory. Some “pages” of an application are only used infrequently, or during startup. Instead of hogging all the memory in the RAM, the system can move those pages to the swap space so your computer can dedicate more resources to processing the current tasks.
Unfortunately, moving information to and from Swap space is SLOW. It can cause some problems, and you don’t want too much of it. There are several different ways you can configure your system to manage what to do if your memory is full, but just having a little swap space is usually good enough.
You don’t even need swap space actually, but without it, your system will start killing “low priority processes” when RAM is full. (programs you’re using, which means unsaved work crashes and stuff.) You can configure your system to prioritize which programs to kill first if you prefer. Otherwise, you should probably have a little swap space to help out.
You can use a “swap file” or a “swap partition”. There’s pros and cons to each.
By the way. It looks like a “Swap partition” doesn’t have a filesystem because it’s not actually storing “files”. (which we’ll get to in a sec). You just assign the partition as “mkswap” or “Linux swap” or whatever the tool you’re using calls it and Linux takes care of the rest. Not super important for an introductory post.
You can’t just cut your hard drive into multiple partitions and start saving cat videos. You need to find ‘unallocated space’ or “unused space” by shrinking existing partitions or reformatting existing drives (erasing stuff).
Once you have this “Free Space”, you need to create a partition for that free space, and give it a “file system”.
You can’t store cat videos without a file system because the system needs a defined way to store and retrieve data. Think of this part like an empty closet with NOTHING inside.
It can’t put any clothes in there because it doesn’t know whether to hang clothes on hangers, or put them in a dresser in the closet, or something else? Your computer needs to know how to store data in this space so it can find it later. The partition needs a “file system”.
Note: Some Linux installers can do this part for you. Ubuntu’s installer will take an empty space and decide everything for you. For me, it took the entire empty space and made an “Ext4” file system and automatically created a swap partiton for me. You can’t always trust an installer though, so it’s good to know how to do it on your own.
Here’s a small list of file systems:
- ext – “Extended file system” (Linux)
- ext2 – Second extended file system (Linux)
- ext3 – Journaled form of ext2 (Linux)
- ext4 – some other Linux fs
- HFS+ – Updated version of Apple’s HFS. Filesystem for MacOS.
- FAT12 (FAT = File Allocation Table)
- NTFS – (New Technology File System) Used on Microsoft Windows Windows NT-based operating systems
- ReiserFS – File system that uses “journaling”
- ZFS – Some apparently super cool BSD file system.
- And more…
Not all file systems are equal. Some file systems are faster than others, some have additional security features, some support drives with large storage capacities while others only work with smaller amount of storage. Some file systems are more resistant to file corruption, while others trade robustness for speed. Some are OS specific.
File systems are just a way to organize the data on a partition so the computer can find it.
A Bootloader is used to help the computer boot up an operating system. By default, Windows has its own bootloader. Linux, and other systems also have their own bootloader, which is usually installed when you install the OS. Sometimes you’ll end up “chainloading”, which means that one bootloader loads another.
When you have two or more systems to choose from on a computer, you’ll get to choose which system to boot up using a bootloader. You’ll probably end up starting with GRUB2 (Linux bootloader), and if you choose a Linux distro, it’ll select the Linux kernel, and start that process to boot up Linux.
If you choose Windows, the GRUB2 bootloader will load the Windows bootloader, which will proceed to do all of its Windows stuff to boot up Windows. (hence the term “chainloading”)
Sometimes bootloaders will be installed on their own partition (/boot usually). Other times they’ll just reside in the partition with the corresponding OS.
Long story short… A bootloader just loads up the operating system of your choosing.
BIOS and MBR
First of all, “BIOS” is outdated. If you have a newer computer you can probably just use GPT/UEFI and be blissfully ignorant. But it’s still good to know!
BIOS stands for “Basic Input-Output System”. BIOS lives inside a chip on your computers motherboard. Inside the BIOS, is a small section called “MBR”, which stands for “Master Boot Record” and is often called “Boot record” or “Boot Sector” or something like it.
MBR is like a booklet that describes the size and location of each partition on the hard drive. It also contains a small section for the bootloader code, but there’s not enough space for modern bootloaders.
The BIOS/MBR is a TINY slice at the BEGINNING of your hard disk that gets run as soon as you startup your computer.
The BIOS’s job is to look at/read the MBR (A small section within BIOS) and load the bootloader, which will start your operating system.
Because there’s not enough space for the full bootloader in the MBR, the bootloader is split into two stages. The first part of the bootloader that actually goes in this tiny little section of MBR is ONLY used to direct the system to the rest of the bootloader, which is either located in its own /boot partition, or in a partition with the OS. Read here for more info: Grub Wiki
This means when you install another system like–some flavor of–Linux, a little section of the MBR can be changed from the default bootloader to the GRUB bootloader. So when you have two systems, it will probably be setup so BIOS reads MBR, then calls GRUB2, which will then ask you which OS you’d like to boot.
One major problem with BIOS is its too small. The MBR section where it defines partition tables only allows for 4 primary partitions (not enough bytes to define more). You can change one of the primary partitions to an “extended partition” and create logical partitions within it, but you’re still limited to a maximum of TWO Terabytes. If the hard drive is larger, anything after 2TB is useless.
There are other issues too, but that’s good for now.
Long story short: BIOS and MBR are poorly designed methods of loading a bootloader, and reading the layout of your hard drive (partitions).
What is UEFI and GPT?
GPT stands for “GUID Partition Table”. We don’t need to go into detail about it, but it’s the replacement for MBR. Think of it as the booklet that UEFI uses to learn about the locations and sizes of the partitions on the hard drive. It does the same thing MBR does, only GPT does it much better. No 2Tib limit, many more partitions can be used, and some other stuff.
UEFI stands for “Unified Extended Firmware Interface”. It replaces the poorly designed “BIOS” system. UEFI is a set of specifications or “rules”.
In this design, there’s a partition used to store all of the important boot data called an “EFI System Partition”. This EFI partition is required to be based on one of the FAT file systems.
All bootloaders and a whole bunch of other important boot-related stuff are supposed to be installed on this EFI partition.
When another system is installed, the Bootloader is supposed to be installed on this EFI partition, and a “Boot entry” is supposed to be added into the “UEFI Boot Manager” that points to the bootloader that corresponds with the system.
When you boot up a UEFI/GPT system, the computers firmware will load up files from this EFI partition, (like the “UEFI Boot Manager”) which will boot up the system, or ask the user which system they’d like to boot.
Note: From what I understand, the bootloader code needs to be compatible with the EFI system, but it doesn’t need to be placed there. Maybe people smarter than I am will leave a comment.
If you really want to geek out, read the UEFI Specification.
Ultimately, UEFI/GPT is just an improved design of the boot process.
How do I make partitions or dual boot my computer?
For the sake of simplicity, it’s much easier to just stick with what is default on your system. If you have MBR/BIOS, then setup your partitions within the primary and logical partitions.
If you must have the improved UEFI/GPT, then either buy a new computer (easier) or check if your existing computer is compatible with UEFI/GPT, and have fun trying to convert it.
Luckily for beginners, most of the Linux installers are pretty smart, and you can let the installer do most of the partitioning if you just create enough free space.
Hopefully this post gave you a rough idea of the components involved in partitioning a hard drive and setting up your computer for dual booting. With this knowledge you should have a strong enough foundation to even handle the partitioning manually, which you’ll have to do on “DIY distributions” like Slackware, Arch, or Gentoo. NOW we can get to the fun part!