Introduction
This lesson is about preparing storage for use.
The main question is:
How do you create partitions and then place a filesystem on them?
What you should be able to do after this lesson:
- Understand MBR vs GPT at a beginner level.
- Recognize
fdisk,gdisk, andparted. - Create filesystems with
mkfs. - Create swap with
mkswap. - Know the basic idea of ext4, XFS, VFAT, exFAT, and Btrfs.
Before you start:
<disk>and<partition>are placeholders for real device names- commands such as
mkfsandmkswapcan destroy data very quickly - use a VM or spare test disk for hands-on practice
- always identify the target with
lsblkbefore making changes
Big Idea: Disk Layout Has Layers
At beginner level, keep this order in your head:
disk -> partition table -> partitions -> filesystems or swap -> mounts
Partitioning and filesystems are different jobs.
- a partition table describes how the disk is split
- a filesystem is created on a partition
- later, that filesystem can be mounted and used
That is why "make a partition" and "make a filesystem" are not the same command or the same decision.
Safe Identification Before Changes
Before you change anything, inspect the device carefully.
Useful commands:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
blkid
Simple rule:
/dev/sdXusually means the whole disk/dev/sdX1usually means a partition on that disk
Mixing those up is one of the fastest ways to destroy the wrong data.
MBR vs GPT
MBR
Older partition table style.
Beginner facts to remember:
- older design
- limited compared with GPT
- you will still see it on older systems and exam material
GPT
Modern partition table style.
Beginner facts to remember:
- better choice for most new systems
- more flexible than MBR
- common on modern disks and UEFI-based installs
For LPIC:
- know both names
- understand that GPT is the modern default on many systems
Partitioning Tools
fdisk
Classic partitioning tool. You will often meet it first.
gdisk
Partitioning tool focused on GPT.
parted
Another partitioning tool, often used in modern workflows and scripts.
You do not need to master every menu or option in this lesson. The main skill is recognizing the tool names and knowing their job.
Create a Filesystem
The general pattern is:
sudo mkfs -t ext4 /dev/sdX1
Common filesystem examples:
sudo mkfs.ext4 /dev/sdX1
sudo mkfs.xfs /dev/sdX1
sudo mkfs.vfat /dev/sdX1
sudo mkfs.exfat /dev/sdX1
Important beginner warning:
- most of the time you create a filesystem on a partition such as
/dev/sdX1 - if you accidentally run
mkfson the whole disk instead of the intended partition, you can wipe more than you meant to
Create Swap
Swap is not a normal mounted filesystem.
sudo mkswap /dev/sdX2
sudo swapon /dev/sdX2
Example output from lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS:
NAME SIZE TYPE FSTYPE MOUNTPOINTS
sda 0B disk
zram0 4G disk swap [SWAP]
nvme0n1 953.9G disk
|-nvme0n1p1 1G part vfat /boot
|-nvme0n1p2 50G part ext4 /
\-nvme0n1p3 902.9G part ext4 /home
What this shows:
- one disk can contain several partitions
- each partition can have a different filesystem
- swap appears differently from normal mounted filesystems
Choosing a Filesystem
ext4
The most common Linux filesystem for general-purpose use.
For beginners, ext4 is the first one to remember.
XFS
Popular modern filesystem, especially on some server distributions.
VFAT
Common for EFI System Partitions and compatibility with many systems.
exFAT
Common for removable media compatibility.
Btrfs
LPIC expects awareness of features such as:
- multi-device filesystems
- compression
- subvolumes
You do not need deep Btrfs administration here.
Common Beginner Mistakes
- confusing the whole disk with one partition
- creating a filesystem before confirming the partition layout
- treating swap like a normal mounted filesystem
- skipping verification after
mkfsormkswap - memorizing tool names without understanding the disk -> partition -> filesystem order
Safe Work Order
- Identify the correct disk with
lsblk. - Decide whether the layout should use MBR or GPT.
- Partition the disk with
fdisk,gdisk, orparted. - Create the filesystem or swap on the correct partition.
- Verify with
lsblk -f,blkid, orswapon --show. - Only after that, think about mounting and
/etc/fstab.
Practice Step by Step
1) Inspect the current disk layout safely
- Run:
lsblk -f - Notice: disk names, partition names, filesystem types, and mountpoints.
- Ask: which entries are whole disks, and which are partitions?
2) Think through the workflow for a new disk
- Check the disk:
lsblk - Partition it with
fdisk,gdisk, orparted. - Create the filesystem:
mkfs.ext4 /dev/sdX1 - Verify:
lsblk -f
3) Prepare swap on a test partition
- Create swap:
mkswap /dev/sdX2 - Activate:
swapon /dev/sdX2 - Verify with:
swapon --show - Use a test partition only, not a production device you still need.
Cheat Sheet
- partition table = disk layout map
- MBR = older partitioning style
- GPT = modern partitioning style
fdisk,gdisk,parted= partitioning toolsmkfs= create filesystemmkfs.ext4,mkfs.xfs,mkfs.vfat,mkfs.exfat= common filesystem creation commandsmkswap= prepare swap arealsblk -f= verify filesystems and partitions- Btrfs awareness = subvolumes, compression, multi-device support
Test Your Knowledge
Complete the quiz to assess your understanding of this course's concepts.
