Skip to main content
This hands-on demo shows how to work with disks, partitions, and filesystems on Linux. You’ll learn how to:
  • Identify available block devices
  • Create a GPT partition table and partitions using parted
  • Format partitions with XFS, ext4, and VFAT (FAT32)
  • Mount partitions and verify mounts
  • Make mounts persistent by editing /etc/fstab
Prerequisites: root (or sudo) access and an unused block device (in this demo /dev/sdb).

1 — List block devices

Start by listing block devices to identify the device you’ll work on:
Before proceeding, double-check the target device (this demo uses /dev/sdb). Partitioning the wrong disk can cause irreversible data loss.

2 — Create partitions with parted

Create a GPT label and three partitions on the target device. The example below creates:
  • Partition 1: XFS (start 2048s to 500MiB)
  • Partition 2: ext4 (501MiB to 1000MiB)
  • Partition 3: FAT32/VFAT (1001MiB to 1500MiB)
Run parted interactively:
After quitting parted, verify the new partition nodes:
Partition summary: References: GNU Parted Documentation

3 — Create filesystems

Format each partition with the desired filesystem and apply labels where helpful for /etc/fstab. Commands used:
Tip: Use -L (or -n for vfat) to set a label you can reference in /etc/fstab via LABEL=<name>. For stable references across reboots and device enumerations, prefer UUID=. See man mkfs.xfs, man mkfs.ext4, and man mkfs.vfat for options.

4 — Create mount points and mount

Create directories to use as mount points and mount the newly formatted partitions:
Verify mounts with lsblk:
Inspect mounted filesystems with a filtered mount output:
Check available space with df -h:

5 — Make mounts persistent in /etc/fstab

To ensure the filesystems mount automatically at boot, add entries to /etc/fstab. Prefer UUID= or LABEL= references rather than device node paths like /dev/sdb1, since device names can change. Obtain UUIDs and label information:
Or list filesystem information for all devices:
Edit /etc/fstab (example snippet). This file controls mounts at boot:
Notes on the example:
  • The /dev/sdb1 entry uses a device path — acceptable for demos but not recommended for production.
  • The ext4 filesystem is mounted by label (LABEL=ext4fs).
  • The vfat filesystem is mounted by UUID (UUID=B195-D19A) — recommended for stability.
After saving /etc/fstab, reload and test:
  1. Reload systemd units generated from fstab:
  1. Test fstab entries by attempting to mount all filesystems:
If mount -a completes without errors, the fstab entries are valid and the system should mount those filesystems automatically on boot. Verify with lsblk:
You can also test full unmount/remount to ensure behavior:
Always validate /etc/fstab changes with mount -a before rebooting. A malformed fstab can leave the system unbootable or in rescue mode.

Summary

In this tutorial you have:
  • Created a GPT partition table on /dev/sdb
  • Added three partitions (XFS, ext4, VFAT)
  • Formatted each partition with appropriate filesystem tools and applied labels/UUIDs
  • Mounted the filesystems and verified them using lsblk, mount, and df
  • Made mounts persistent by adding entries to /etc/fstab and testing with mount -a
Further reading and references:

Watch Video