Mounting Filesystems: mount, umount, and fstab

Mounting Filesystems: mount, umount, and fstab

What You Will Achieve

  • Attach a device to any mount point with mount
  • Unmount safely with umount and handle "busy" errors
  • Read and write the six fields of /etc/fstab accurately
  • Identify devices durably with UUID / LABEL and verify with blkid / findmnt
  • Explain, with reasoning, how nofail changes whether the system boots

This is the core of LPIC-1 objective 104.3 "Control mounting and unmounting of filesystems". It covers how devices connect to the directory tree, including the exam-frequent fstab mistakes.

What Is Mounting

Mounting attaches a filesystem on a block device to a single point (the mount point) in the existing directory tree. Linux assigns no drive letters; everything is unified into one tree.

Running mount with no arguments lists every currently mounted filesystem, showing device, mount point, type, and options in that order.

mount | grep sdb
/dev/sdb1 on /mnt type ext4 (rw,relatime)

The key idea is that you manage a device-to-directory relationship, not files. Files that were originally in the mount point are hidden while something is mounted there (they are not deleted; they reappear after unmount).

How Do You Mount with mount

The basic form is mount DEVICE MOUNTPOINT. If a matching entry exists in /etc/fstab, specifying just one of the two is enough.

Step 1: Check the target device

lsblk
blkid
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   50G  0 disk
└─sda1   8:1    0   50G  0 part /
sdb      8:16   0   10G  0 disk
└─sdb1   8:17   0   10G  0 part

/dev/sda1: UUID="a1b2c3d4-..." TYPE="ext4"
/dev/sdb1: UUID="e5f6a7b8-..." TYPE="ext4" LABEL="data"

Use lsblk for the block device hierarchy and blkid for each partition's UUID, LABEL, and filesystem type. Know the type before mounting.

Step 2: Mount the device

mount /dev/sdb1 /mnt
findmnt /mnt
TARGET SOURCE    FSTYPE OPTIONS
/mnt   /dev/sdb1 ext4   rw,relatime

mount /dev/sdb1 /mnt attaches /dev/sdb1 to /mnt. In most environments the type is auto-detected, but you can state it explicitly with -t ext4. Verify the result as a tree with findmnt.

Step 3: Mount with options

mount -t ext4 -o ro,noexec /dev/sdb1 /mnt
findmnt -o TARGET,OPTIONS /mnt
TARGET OPTIONS
/mnt   ro,noexec,relatime

-o passes mount options as a comma-separated list. ro means read-only and noexec forbids executing binaries on that filesystem. Combine multiple options as -o ro,noexec.

Step 4: Loopback-mount an ISO image

mount -o loop ubuntu.iso /mnt
findmnt /mnt
TARGET SOURCE                FSTYPE  OPTIONS
/mnt   /dev/loop0[/ubuntu.iso] iso9660 ro,relatime

-o loop mounts a file (such as an ISO image) through a loopback device. You can browse the image's contents as a directory without any physical device.

Step 5: Remount a mounted filesystem

mount -o remount,ro /mnt
findmnt -o TARGET,OPTIONS /mnt
TARGET OPTIONS
/mnt   ro,relatime

-o remount changes only the options without unmounting. Use it to switch a running filesystem from rw to ro, for example. It works even on always-busy filesystems like /.

How Do You Unmount Safely with umount

umount accepts either the mount point or the device name. Since a busy filesystem cannot be unmounted, the key is identifying the offending process.

Step 1: A normal unmount

umount /mnt
findmnt /mnt
(no output)

Unmount with umount /mnt (or umount /dev/sdb1). Note the command is umount (no n), not unmount. No output means success.

Step 2: When the filesystem is busy

umount /mnt
umount: /mnt: target is busy.

If a process has an open file or its current directory on that filesystem, it fails with target is busy. Identify the process with lsof or fuser.

lsof /mnt
fuser -m /mnt
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
bash    4210 user  cwd    DIR    8,17     4096    2 /mnt
/mnt:                 4210c

lsof /mnt lists the processes using the target, and fuser -m /mnt shows the PID. Often it is your own shell that ran cd /mnt; move to another directory and run umount again.

Step 3: Lazy unmount as a last resort

umount -l /mnt
(no output)

-l (lazy) detaches the filesystem from the tree immediately and frees it once no references remain. It avoids "busy" but requires care about in-flight writes, so treat it as a last resort when you cannot stop the offending process.

How Do You Write the Six fstab Fields

/etc/fstab is the static mount-definition file read at boot and by mount -a. Each line has six whitespace- or tab-separated fields.

UUID=e5f6a7b8-...  /data  ext4  defaults,nofail  0  2
# Field Content Example
1 Device What to mount. UUID= / LABEL= / device path UUID=e5f6...
2 Mount point Target directory. swap uses none or swap /data
3 Filesystem type ext4 / xfs / vfat / swap / auto, etc. ext4
4 Mount options Comma-separated. defaults, etc. defaults,nofail
5 dump Whether dump should back it up (usually 0) 0
6 fsck passno Order of fsck at boot (0 = no check) 2

Field 5 is for the dump command and is usually 0. Field 6 (passno) is the filesystem check order at boot: root / is 1, other checked filesystems are 2, and 0 means no check. Same-drive entries are checked sequentially while different drives are checked in parallel.

defaults in field 4 is a shortcut for rw,suid,dev,exec,auto,nouser,async. A standard local disk needs nothing more.

Why Specify by UUID / LABEL

A device name like /dev/sdb1 can change to /dev/sdc1 when you add disks or the detection order shifts. Hard-coding device names in fstab means that a name shift either mounts the wrong device or fails to mount and disrupts boot.

A UUID (a unique identifier assigned when the filesystem is created) and a LABEL (an arbitrary label name) do not depend on the device's connection position, so fstab should use them. Read the values with blkid.

blkid /dev/sdb1
/dev/sdb1: UUID="e5f6a7b8-1234-..." TYPE="ext4" LABEL="data"
# Example /etc/fstab lines
UUID=e5f6a7b8-1234-...  /data  ext4  defaults,nofail  0  2
LABEL=data              /data  ext4  defaults,nofail  0  2

For UUID, put the value from blkid directly in field 1. LABEL works only for a filesystem that has a label, which you set with a tool like e2label.

How Do You Verify fstab After Editing

An fstab mistake leads directly to an unbootable system. Before rebooting, always verify the entries against the running system.

Test all entries with mount -a

mount -a
(no output = success)

mount -a mounts every auto entry in fstab (everything except noauto). Already-mounted entries are skipped. If no error appears, the fstab entries are valid; any line that errors likely has a mistake.

Cross-check fstab entries with findmnt

findmnt --verify
/data
   [ ] target exists
   [ ] FS options: defaults,nofail
0 parsing errors, 0 errors, 0 warnings

findmnt --verify parses fstab and checks mount-point existence and option validity without actually mounting. Confirm 0 errors before rebooting.

Rebooting after editing fstab without verifying can halt the normal boot and drop you into an emergency shell if there is a mistake. Always confirm with mount -a and findmnt --verify first.

Quick Reference for Key Mount Options

Representative options used in field 4 or mount -o. Combine them comma-separated.

Option Meaning
defaults The standard set rw,suid,dev,exec,auto,nouser,async
ro / rw Read-only / read-write
noexec Forbid executing binaries on that filesystem
nosuid Disable setuid / setgid bits
nodev Forbid interpreting device files
auto / noauto Auto-mount with mount -a/at boot, or not
user / users Allow a regular user to mount (user lets only the mounter umount)
nofail Continue booting even if the device is absent

noexec,nosuid,nodev is a classic hardening set for USB sticks or scratch data areas. Applying it to areas that hold no executables or setuid binaries raises security.

Overview of Automounting with systemd

On modern distributions that use systemd, /etc/fstab is converted at boot into .mount units by systemd-fstab-generator and mounted under systemd's control. Writing fstab still works exactly as before.

Field 4 options can request systemd-specific behavior. For example, x-systemd.automount mounts the target on demand the first time it is accessed (automounting). For network filesystems, _netdev defers the mount until the network is reachable.

# Example: on-demand mount when accessed
UUID=e5f6...  /data  ext4  noauto,x-systemd.automount  0  2

For LPIC-1, it is enough to grasp that fstab is converted by systemd into .mount units, plus options like nofail and _netdev.

Common Mistakes and Fixes

Mistake 1: An fstab error makes the system unbootable

Writing a nonexistent device or wrong UUID in fstab halts boot into an emergency shell by default. Add nofail to non-essential data areas so boot continues even without the device, and always verify after editing with mount -a and findmnt --verify.

Mistake 2: Cannot umount because it is busy

target is busy signals a process with an open file or current directory on that filesystem. Identify it with lsof /mnt or fuser -m /mnt, then end the process or move out of the directory before umount.

Mistake 3: A UUID change breaks the mount

Recreating a filesystem with mkfs changes its UUID, so an fstab entry with the old UUID fails to mount. After reformatting, get the new UUID with blkid and update fstab.

Mistake 4: Typing the command as unmount

The unmount command is umount (no n). unmount does not exist and returns command not found. Exams also test the spelling.

Mistake 5: Thinking the mount point's files disappeared

Files originally in the mount point are merely hidden while something is mounted there; they are not deleted. Unmount and the original files reappear.

Troubleshooting

Symptom: mount gives a "wrong fs type" error

Cause: Filesystem type auto-detection failed, or -t specifies the wrong type

Check:

blkid /dev/sdb1

Fix: Confirm the real type with blkid and state it with mount -t TYPE. If the kernel module or tools for that type (such as xfsprogs) are missing, install them.

Symptom: A data area is not mounted after reboot

Cause: The fstab entry has noauto, or the UUID has drifted

Check:

findmnt --verify
blkid

Fix: Check fstab validity with findmnt --verify, then fix it to auto (or remove noauto) with the correct UUID. Verify manually with mount -a.

Symptom: The disk still cannot be removed after umount -l

Cause: Lazy unmount only detaches from the tree; with referencing processes still alive, it is not actually freed

Check:

fuser -m /dev/sdb1

Fix: Identify and end the remaining processes with fuser -m. The actual release completes once all references are gone.

Completion Checklist

  • [ ] Checked the device and type with lsblk / blkid
  • [ ] Mounted with mount and confirmed with findmnt
  • [ ] Unmounted safely with umount (handled busy with lsof / fuser)
  • [ ] Wrote /etc/fstab using UUID / LABEL
  • [ ] Verified before reboot with mount -a / findmnt --verify
  • [ ] Added nofail to optional areas to avoid an unbootable system

Summary

Scenario Command Purpose
Mount mount -t ext4 -o ro /dev/sdb1 /mnt Attach with type and options
Unmount umount /mnt Detach safely
Handle busy lsof /mnt / fuser -m /mnt Find the cause of "busy"
Read identifiers blkid Get UUID / LABEL / type
Check state findmnt Show the mount tree
Verify fstab mount -a / findmnt --verify Validate before reboot

Mounting is the basis of storage operations and is best learned together with partition creation and the FHS. Because an fstab mistake leads straight to an unbootable system, mastering the verification steps matters for both passing LPIC-1 and real-world work.

Next Reading

Continue Your LPIC-1 Journey

LPIC-1 Hub

  • LPIC-1 Learning Hub — Full LPIC-1 article map, progress tracking, and exam objective coverage

Practice