Skip to content

Partitioning Disks


A raw disk, fresh out of the box, isn’t directly usable — before any filesystem can go onto it, it needs to be divided into one or more partitions, logical sections of the disk that each get treated as an independent unit. This chapter covers the tools that do that dividing, and — since you specifically asked which one is actually best — a clear answer on when to reach for which.

Partitioning Schemes: MBR vs. GPT, Practically

Before touching a tool, it’s worth knowing there are two competing standards for how partition information is recorded on a disk, because the tool you need depends on which one you’re working with.

MBR (Master Boot Record) is the older standard. It supports a maximum of four “primary” partitions directly (extendable with awkward workarounds involving “extended” and “logical” partitions), and it can’t address disks larger than 2TB.

GPT (GUID Partition Table) is the modern standard, and the one you should default to for anything new. It supports up to 128 partitions with no extended-partition workaround needed, handles disks far larger than 2TB, and stores a backup copy of its partition table at the end of the disk for resilience against corruption.

Unless you’re dealing with genuinely old hardware or a specific legacy requirement, GPT is the right default — and every tool in this chapter supports it.

fdisk: The Traditional, Interactive Tool

fdisk has existed for decades and remains the most commonly reached-for partitioning tool. Despite the name suggesting otherwise, modern fdisk supports both MBR and GPT, not just the older standard its name implies.

Start by listing existing disks and their partitions — the same information lsblk gave you in the last file, from a different tool:

sudo fdisk -l

To actually work on a specific disk, open it interactively:

sudo fdisk /dev/sdb

This drops you into an interactive prompt, entirely separate from your normal shell — commands here are single letters, not the usual command-flag-argument shape from earlier in this course.

CommandAction
pPrint the current partition table
nCreate a new partition
dDelete a partition
tChange a partition’s type
wWrite changes to disk and exit
qQuit without saving any changes

Tip

This is the one genuinely reassuring thing about fdisk: nothing you do inside this interactive session actually touches the disk until you explicitly type w. You can create partitions, delete them, second-guess yourself, and start over freely — as long as you quit with q instead of w, the disk is exactly as it was when you started. This is the opposite behavior of most destructive commands covered so far in this course, and worth remembering specifically because parted, covered next, doesn’t work this way.

parted: Scriptable And Immediate

parted covers similar ground to fdisk but with two meaningful differences: it’s built to be scripted non-interactively, and — this is the important part — it applies changes immediately, not on an explicit save step.

sudo parted /dev/sdb

Inside its interactive prompt, commands are full words rather than single letters:

(parted) print
(parted) mklabel gpt
(parted) mkpart primary ext4 0% 100%
(parted) quit

mklabel gpt initializes the disk with a GPT partition table, and mkpart creates a partition spanning the given range — here, the entire disk, expressed as a percentage.

Warning

Unlike fdisk, parted does not wait for a final “write” command — each action takes effect on the disk the moment you run it. mklabel gpt genuinely rewrites the disk’s partition table immediately, not as a preview you can back out of with quit. Treat every parted command as already committed the instant you press Enter, and double-check the target device with lsblk before opening parted at all, not after.

parted can also run entirely non-interactively, one command per invocation — genuinely useful for scripting, though outside the scope of what this chapter covers hands-on:

sudo parted /dev/sdb mklabel gpt
sudo parted /dev/sdb mkpart primary ext4 0% 100%

gdisk: fdisk’s Interface, GPT-Only

gdisk is worth knowing about specifically because you’ll see it referenced in older guides: it offers essentially the same interactive, letter-command interface as fdisk (including the “nothing’s written until you save” safety behavior), but is dedicated specifically to GPT disks. Since modern fdisk gained full GPT support, gdisk’s original reason for existing — GPT support that plain fdisk lacked — has largely been absorbed into fdisk itself. You’re unlikely to need it on a current Debian/Ubuntu system, but recognizing it prevents confusion if you encounter it in documentation or an older environment.

Which Tool Should You Actually Use

SituationReach for
Interactive, one-off partitioning, want a safety net before committingfdisk
Scripting partition creation, or need to resize partitions laterparted
Working with an older system where fdisk genuinely lacks GPT supportgdisk

For the hands-on examples in the rest of this section, we’ll use fdisk — its explicit “nothing happens until w” behavior makes it the safer tool to be learning on, which matters more early on than parted’s scripting convenience.

What’s Next

You now know how to divide a disk into partitions and which tool fits which situation. One specific partition deserves its own explanation before going further, since it’s a genuine source of confusion: the boot partition — what it actually is, and why systems handle it differently depending on whether they boot via legacy BIOS or modern UEFI.

Last updated on