- 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
/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)
parted interactively:
parted, verify the new partition nodes:
References: GNU Parted Documentation
3 — Create filesystems
Format each partition with the desired filesystem and apply labels where helpful for/etc/fstab.
Commands used:
-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:lsblk:
mount output:
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:
/etc/fstab (example snippet). This file controls mounts at boot:
- The
/dev/sdb1entry 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.
/etc/fstab, reload and test:
- Reload systemd units generated from fstab:
- Test fstab entries by attempting to mount all filesystems:
mount -a completes without errors, the fstab entries are valid and the system should mount those filesystems automatically on boot.
Verify with lsblk:
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, anddf - Made mounts persistent by adding entries to
/etc/fstaband testing withmount -a
- Parted manual: https://www.gnu.org/software/parted/manual/parted.html
- fstab(5): https://man7.org/linux/man-pages/man5/fstab.5.html
- mount(8): https://man7.org/linux/man-pages/man8/mount.8.html
- blkid(8): https://man7.org/linux/man-pages/man8/blkid.8.html