Instiq
Chapter 2 · Filesystems and storage management·v1.0.0·Updated 7/7/2026·~11 min

What's changed: Initial version (topic 2.02, subtopics 2.02.1–2.02.3)

2.1Configuring and Mounting Filesystems

Key points

Learn how storage is attached to the directory tree via mounting: the persistent configuration in /etc/fstab, manual control with mount/umount, the live view in /proc/mounts, swap handling with swapon/swapoff/mkswap, and device identification with blkid/lsblk/UUID.

Creating a partition or logical volume alone does not make it accessible—Linux must attach it at a specific point in the directory tree, which is mounting. Since you cannot redo this by hand at every boot, you need to handle both persistent configuration and manual operations precisely.

2.1.1/etc/fstab and mount/umount

  • /etc/fstab is the persistent configuration mounted automatically at boot. One line per mount, with six fields: device, mount point, filesystem type, options, dump, fsck order. Devices are named by /dev/sdXn or, more robustly, by UUID (UUID=xxxx)—since device names can shift when disks are added.
  • mount attaches manually (mount /dev/sdb1 /mnt/data; if it is already in fstab, mount /mnt/data alone suffices). mount -a mounts every fstab entry at once (handy for verifying config changes). umount detaches; if busy it fails with umount: target busy—identify the offending process with fuser or lsof.
  • /proc/mounts is a virtual file reflecting the kernel's live view of current mounts in real time (fstab is intent; /proc/mounts is fact). /etc/mtab traditionally recorded mount results separately, but on most modern distributions it is a symlink to /proc/mounts.

2.1.2Swap and device identification

  • Swap is disk space used to offload memory under pressure. Create it with mkswap (mkswap /dev/sdb2 writes the swap signature); activate with swapon (swapon /dev/sdb2; swapon -a activates every fstab swap entry); deactivate with swapoff. Register it persistently in fstab with type swap and option sw.
  • blkid lists each block device's UUID, LABEL, and TYPE (the go-to way to look up a UUID for fstab). lsblk shows block devices as a tree (disk → partition → mount point relationships at a glance).
Exam point

The staples: fstab field order = device, mount point, type, options, dump, fsck order; UUID is resilient to device renaming; mount -a mounts all of fstab, swapon -a activates all fstab swap entries; /proc/mounts is the actual current state. The workflow of looking up a UUID with blkid and writing it into fstab is a classic hands-on question.

Walk through adding a disk, formatting it ext4, and mounting it persistently at /data. First note the UUID with blkid /dev/sdb1, then add a line like UUID=xxxx-xxxx /data ext4 defaults 0 2 to /etc/fstab. Rebooting immediately to check is risky—a formatting mistake can leave the system unable to boot—so the standard practice is to test fstab without rebooting using mount -a. If no error appears, confirm the mount actually happened with df -h, mount | grep /data, or /proc/mounts. Adding swap follows a similar pattern: after creating the partition, mkswap /dev/sdb2 then swapon /dev/sdb2 activates it immediately, while adding UUID=yyyy none swap sw 0 0 to /etc/fstab makes it auto-activate on the next boot too. For mount options, the exam also covers defaults (the bundle rw, suid, dev, exec, auto, nouser, async) as the baseline, plus ro for read-only, the security-hardening nosuid that disables SUID/SGID, and nodev that forbids interpreting device files.

CommandRoleNote
mount -aMount every fstab entryTest fstab without rebooting
swapon -aActivate all fstab swap entriesRequires prior mkswap
blkidList UUID/LABEL/TYPESource of UUIDs for fstab
lsblkTree view of block devicesFor seeing parent/child layout
Warning

Trap: "saving /etc/fstab changes takes effect immediately" is wrong—fstab is merely read at the next mount (typically the next boot); it does not affect already-mounted filesystems. Confirm with mount -a or an explicit remount. Also, "/proc/mounts can be edited to persist settings" is wrong—it is a kernel-generated, read-only snapshot of the current state; persistent configuration belongs in /etc/fstab.

fstab field layout, mount/umount operations, swapon/swapoff/mkswap, and device identification with blkid/lsblk.
fstab is intent, /proc/mounts is fact

2.1.3Section summary

  • /etc/fstab = persistent config (device/mount point/type/options/dump/fsck order). mount -a = verify without rebooting; /proc/mounts = the real current state
  • mkswap then swapon activates swap; get the UUID with blkid and register it in fstab; check the layout with lsblk

Sign in to track progress — Log in.

Quick check

(just a quick review)

Q1. You formatted a new disk as ext4 and want it permanently mounted at /data by UUID. After adding the entry to /etc/fstab, what is the best way to verify it without rebooting?

Q2. You want /dev/sdb2 activated as swap right now, and also automatically activated on every future boot. What is the correct procedure?

Q3. After adding two disks to a server, device name assignment shifts on each boot and fstab mounts start failing. Which fstab device-specification approach fundamentally avoids this?

Check your understandingPractice questions for Chapter 2: Filesystems and storage management