Linucate
~ Linucate_

104.1 Create partitions and filesystems

All Levels

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, and parted.
  • 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 mkfs and mkswap can destroy data very quickly
  • use a VM or spare test disk for hands-on practice
  • always identify the target with lsblk before 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.

  1. a partition table describes how the disk is split
  2. a filesystem is created on a partition
  3. 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/sdX usually means the whole disk
  • /dev/sdX1 usually 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 mkfs on 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 mkfs or mkswap
  • memorizing tool names without understanding the disk -> partition -> filesystem order

Safe Work Order

  1. Identify the correct disk with lsblk.
  2. Decide whether the layout should use MBR or GPT.
  3. Partition the disk with fdisk, gdisk, or parted.
  4. Create the filesystem or swap on the correct partition.
  5. Verify with lsblk -f, blkid, or swapon --show.
  6. Only after that, think about mounting and /etc/fstab.

Practice Step by Step

1) Inspect the current disk layout safely
  1. Run: lsblk -f
  2. Notice: disk names, partition names, filesystem types, and mountpoints.
  3. Ask: which entries are whole disks, and which are partitions?
2) Think through the workflow for a new disk
  1. Check the disk: lsblk
  2. Partition it with fdisk, gdisk, or parted.
  3. Create the filesystem: mkfs.ext4 /dev/sdX1
  4. Verify: lsblk -f
3) Prepare swap on a test partition
  1. Create swap: mkswap /dev/sdX2
  2. Activate: swapon /dev/sdX2
  3. Verify with: swapon --show
  4. 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 tools
  • mkfs = create filesystem
  • mkfs.ext4, mkfs.xfs, mkfs.vfat, mkfs.exfat = common filesystem creation commands
  • mkswap = prepare swap area
  • lsblk -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.