LFCS 79 ๐ง Mounting Filesystems โ mount
A filesystem that has been created but not mounted is inert. The kernel sees a block device with metadata on it, but no path leads from the directory tree to the files inside. mount is the command that connects the two: it attaches a filesystem to a directory, making the filesystem’s contents appear at that location. The LFCS exam expects you to perform this operation manually, understand the options that change what the mounted filesystem permits, and know how to make the mount survive a reboot through /etc/fstab.
This chapter covers the mounting step of the storage workflow. It begins with the syntax of mount and the distinction between the explicit device-and-directory form and the abbreviated forms that consult /etc/fstab. It then explains the options that matter in practiceโread-only, noexec, remountโand the unmount discipline that prevents data loss. The final sections address the persistent configuration in /etc/fstab, the use of UUIDs instead of device names, and the verification steps that confirm a mount will survive a reboot.
Key point: mount without arguments shows what is already mounted. mount with arguments attaches something new. The two forms are easy to confuse, and the abbreviated form consults /etc/fstab in ways that are not always obvious.
Why mounting works this way
The unified directory tree. Linux does not assign drive letters to partitions. Every filesystem is attached to a directory somewhere in the single tree that begins at /. The directory is called the mount point, and mounting is the act of making the filesystem’s root appear at that directory . This is why /home can be a separate partition without any special path syntax: the partition is mounted at /home, and the directory tree continues seamlessly.
The temporary versus persistent distinction. A mount command executed at the shell is temporary. It lasts until the system reboots or the filesystem is explicitly unmounted. To make a mount persistent, the entry must be written to /etc/fstab, the file that the boot process reads to reconstruct the mount layout . The mount command and /etc/fstab are two interfaces to the same kernel operation: one immediate, one deferred to boot.
The fstab consultation behavior. When mount is given both a device and a directory, it mounts immediately and does not consult /etc/fstab. When it is given only one of them, it searches /etc/fstab for the matching entry and fills in the missing argument . This behavior is convenient for entries that are already configured, but it can produce surprising results if the fstab entry is stale or if the device name has changed.
The options that change permissions. A mounted filesystem inherits a set of mount options that determine whether it is writable, whether executables can run from it, and whether setuid binaries are honored. The defaults option is a bundle that includes rw, suid, dev, exec, auto, nouser, and async . Overriding individual options is how an administrator hardens a mount or makes it read-only for a specific purpose.
The busy unmount problem. A filesystem cannot be unmounted while any process has a file open on it or while the shell’s current working directory is inside it. The kernel returns “target is busy” and refuses the operation . This is a safety mechanism, not an obstacle: unmounting a filesystem with active writers would corrupt data. The solution is to leave the mount point and close the processes that are using it.
a. The syntax and the abbreviated forms
The explicit form of mount takes the filesystem type, the device, the mount point, and options. Every argument is present, and /etc/fstab is not consulted.
# Explicit mount: type, device, mount point, options.
sudo mount -t ext4 /dev/sdb1 /mnt/data -o defaults
# The type is optional if the kernel can detect it.
# The kernel reads the filesystem superblock and selects the driver.
sudo mount /dev/sdb1 /mnt/data
# Mount a read-only ISO image using the loop device.
# The loop option treats the file as a block device.
sudo mount -o loop,ro /path/to/image.iso /mnt/iso
The abbreviated form supplies only one argument, and mount searches /etc/fstab for the rest. If the device is given, it looks up the matching mount point and type. If the directory is given, it looks up the matching device .
# Abbreviated: only the device. mount looks up the rest in fstab.
sudo mount /dev/sdb1
# Abbreviated: only the mount point. mount looks up the device in fstab.
sudo mount /mnt/data
The mount command with no arguments is a different operation entirely: it lists every mounted filesystem, including virtual filesystems like proc and sysfs. The output format is device on directory type (options) .
# List all mounted filesystems.
mount
# A filtered view is easier to read.
mount | grep /dev/sd
The findmnt command is a more modern alternative for inspecting mounts. It produces tree-formatted output and can filter by device, mount point, or filesystem type.
# Show the mount tree in a readable format.
findmnt
# Show only mounts backed by a specific device.
findmnt /dev/sdb1
b. The options that matter
The -o flag passes a comma-separated list of options to the kernel. The list is parsed strictly: a space after a comma is an error, because mount treats the text after the space as a separate argument . The options that appear most often in LFCS work are the ones that control write access and execution.
ro mounts the filesystem read-only. Writes fail with “read-only filesystem,” which is useful for forensics, for rescue operations, and for filesystems that should not change. rw is the opposite and is included in defaults. noexec prevents binaries on the filesystem from being executed, which hardens a data partition against malware that might be dropped there. nosuid ignores setuid bits, preventing privilege escalation through a mounted filesystem. nodev ignores device files on the filesystem.
# Mount read-only and without execution permission.
# This is a common hardening combination for data partitions.
sudo mount -t ext4 /dev/sdb1 /mnt/data -o ro,noexec
# Remount an already-mounted filesystem with different options.
# This is how a filesystem is switched from rw to ro without unmounting.
sudo mount -o remount,ro /mnt/data
# Remount back to read-write.
sudo mount -o remount,rw /mnt/data
The remount option deserves emphasis because it is the only way to change the options of a mounted filesystem without unmounting it. The device and mount point are still required, but the operation does not create a new mount; it updates the existing one. This is how the root filesystem is often switched to read-only before a filesystem check, and how a filesystem is made writable again afterward.
The user and nouser options control whether non-root users can mount the filesystem. user allows any user to mount it (and the user who mounted it can unmount it); nouser restricts mounting to root. The defaults bundle includes nouser, which is why ordinary partitions require root privileges .
c. Unmounting and the busy filesystem
The command to detach a filesystem is umount, spelled without an n. It takes either the device path or the mount point. Before unmounting, the kernel flushes all pending writes to the device, which is why unmounting is the safe way to remove removable media .
# Unmount by mount point.
sudo umount /mnt/data
# Unmount by device path.
sudo umount /dev/sdb1
# Lazy unmount: detach now, clean up when the device is no longer busy.
# This is for situations where a normal unmount is impossible.
sudo umount -l /mnt/data
The “target is busy” error occurs when a process has a file open on the filesystem or when a shell’s current directory is inside it . The solution is to identify and close the process. lsof lists open files by mount point, and fuser identifies processes using a device. Changing the shell’s directory with cd outside the mount point is the other common fix.
# Find processes with open files on the mount.
sudo lsof +f -- /mnt/data
# Find processes using the device.
sudo fuser -vm /mnt/data
# After closing the processes or leaving the directory, retry.
sudo umount /mnt/data
The -l (lazy) flag detaches the filesystem from the tree immediately but defers the actual cleanup until the filesystem is no longer busy. It is a last resort, not a routine operation: the filesystem is invisible to new accesses, but existing open files continue to work against the detached mount. For a clean shutdown or a removable device, a normal unmount is always preferred.
Complete Example Session
# ============================================
# PART 1: INSPECTION BEFORE MOUNTING
# ============================================
# Confirm the device exists and has a filesystem.
lsblk -f /dev/sdb
# Look for the FSTYPE column: ext4, xfs, or btrfs.
# An empty FSTYPE means mkfs has not been run yet.
# ============================================
# PART 2: CREATE THE MOUNT POINT
# ============================================
# The directory must exist before mounting.
# /mnt is the conventional location for temporary mounts.
sudo mkdir -p /mnt/data
# ============================================
# PART 3: THE EXPLICIT MOUNT
# ============================================
# Type, device, mount point. No fstab consultation.
sudo mount -t ext4 /dev/sdb1 /mnt/data
# ============================================
# PART 4: VERIFY THE MOUNT
# ============================================
# Confirm the filesystem is attached and writable.
findmnt /mnt/data
lsblk /dev/sdb
df -hT /mnt/data
# ============================================
# PART 5: MOUNT OPTIONS
# ============================================
# Remount read-only and test the restriction.
sudo mount -o remount,ro /mnt/data
touch /mnt/data/test 2>&1 | head -1
# Expected: "Read-only file system"
# Restore read-write.
sudo mount -o remount,rw /mnt/data
# ============================================
# PART 6: THE noexec OPTION
# ============================================
# Mount with noexec and verify that binaries cannot run.
sudo mount -o remount,noexec /mnt/data
# If an executable exists on the filesystem:
# /mnt/data/program # Expected: "Permission denied"
sudo mount -o remount,exec /mnt/data
# ============================================
# PART 7: THE ABBREVIATED FORM
# ============================================
# With an fstab entry in place, only one argument is needed.
# Without an entry, this fails.
# sudo mount /mnt/data
# mount: /mnt/data: can't find in /etc/fstab.
# ============================================
# PART 8: THE FSTAB ENTRY
# ============================================
# Get the UUID, then write the persistent entry.
sudo blkid /dev/sdb1
# Note the UUID value.
# Add to /etc/fstab:
# UUID=xxxx /mnt/data ext4 defaults 0 2
# Test the entry without rebooting.
sudo mount -a
findmnt /mnt/data
# ============================================
# PART 9: UNMOUNTING
# ============================================
# Leave the mount point first, then unmount.
cd /root
sudo umount /mnt/data
findmnt /mnt/data # should produce no output
# ============================================
# PART 10: THE BUSY CASE
# ============================================
# Re-mount, then attempt to unmount from inside.
sudo mount /dev/sdb1 /mnt/data
cd /mnt/data
sudo umount /mnt/data
# Expected: "target is busy"
cd /root
sudo umount /mnt/data
# Now it succeeds.
echo "Mount workflow complete."
The ten parts walk through the full lifecycle of a mount: inspect, create the mount point, mount explicitly, verify, change options, write the fstab entry, test it, and unmount. The final part demonstrates the most common operational obstacleโthe busy filesystemโand its solution. The sequence is deliberately repetitive because the LFCS exam tests the ability to perform these steps from memory, without consulting documentation.
Quick Reference
Mount Command Forms
| Form | Example | Consults fstab? |
|---|---|---|
| List mounts | mount | No |
| Explicit | mount -t type /dev/X /mnt | No |
| Device only | mount /dev/X | Yes |
| Mount point only | mount /mnt | Yes |
| All fstab entries | mount -a | Yes |
| Remount | mount -o remount,opt /mnt | No |
Common Mount Options
| Option | Effect | Opposite |
|---|---|---|
ro | Read-only | rw |
rw | Read-write | ro |
noexec | No execution | exec |
nosuid | Ignore setuid | suid |
nodev | Ignore device files | dev |
defaults | Bundle: rw,suid,dev,exec,auto,nouser,async | โ |
remount | Change options on a mounted fs | โ |
loop | Treat a file as a block device | โ |
/etc/fstab Fields
| Field | Example | Meaning |
|---|---|---|
| Device | UUID=xxxx | Block device or UUID |
| Mount point | /mnt/data | Directory to attach |
| Type | ext4 | Filesystem type |
| Options | defaults | Mount options |
| Dump | 0 | Backup flag (obsolete) |
| Pass | 2 | fsck order (0=skip, 1=root, 2=others) |
Unmount Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| “target is busy” | Process has open file or shell is inside | cd out, close processes |
| “not mounted” | Wrong path or already unmounted | Check findmnt |
| “device is busy” | Device in use by LVM/RAID | Stop the dependent stack |
Best Practices
โ Do This:
# Verify the mount after every operation.
findmnt /mnt/data # โ
# Use UUIDs in /etc/fstab, not device names.
UUID=xxxx /mnt/data ext4 defaults 0 2 # โ
# Test fstab entries with mount -a before rebooting.
sudo mount -a && findmnt /mnt/data # โ
# Leave the mount point before unmounting.
cd /root && sudo umount /mnt/data # โ
# Use remount to change options on a live filesystem.
sudo mount -o remount,ro /mnt/data # โ
# Use noexec and nosuid for data partitions.
sudo mount -o defaults,noexec,nosuid /dev/sdb1 /mnt/data # โ
โ Don’t Do This:
# Don't use device names in fstab.
/dev/sdb1 /mnt/data ext4 defaults 0 2 # may change on reboot # โ
# Don't unmount from inside the mount point.
cd /mnt/data && sudo umount /mnt/data # busy # โ
# Don't rely on lazy unmount as a routine.
sudo umount -l /mnt/data # last resort only # โ
# Don't forget the space rule in options.
-o ro, noexec # space is an error # โ
# Don't assume mount -a will fix a broken fstab.
# A syntax error in fstab can prevent boot. # โ
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| “can’t find in /etc/fstab” | Abbreviated form used without an entry | Use explicit form or add the fstab entry |
| “target is busy” | Shell or process inside the mount | cd out, close files, retry |
| Mount does not survive reboot | No fstab entry, or entry has wrong UUID | Add UUID-based entry, test with mount -a |
| “wrong fs type” | -t omitted and detection failed | Specify -t explicitly |
| fstab typo prevents boot | Malformed entry, no nofail option | Use nofail for non-critical mounts |
| Options ignored | Space after comma in -o list | Remove spaces |
| Remount fails | Device and mount point mismatch | Specify both correctly |
Real-World Examples
1. Explicit Mount
sudo mount -t ext4 /dev/sdb1 /mnt/data
2. List Mounts
findmnt
3. Remount Read-Only
sudo mount -o remount,ro /mnt/data
4. Mount ISO
sudo mount -o loop,ro image.iso /mnt/iso
5. Unmount
sudo umount /mnt/data
6. Check Busy
sudo lsof +f -- /mnt/data
7. fstab Entry
UUID=xxxx /mnt/data ext4 defaults,noexec 0 2
8. Test fstab
sudo mount -a
9. Mount All
sudo mount -a
10. Find Mount Source
findmnt -T /mnt/data
Visual
The Mount Operation
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BEFORE MOUNT โ
โ โ
โ / (root filesystem) โ
โ โโโ bin/ โ
โ โโโ etc/ โ
โ โโโ mnt/ โ empty directory โ
โ โโโ var/ โ
โ โ
โ /dev/sdb1: ext4 filesystem, not visible anywhere โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ AFTER: mount /dev/sdb1 /mnt/data โ
โ โ
โ / (root filesystem) โ
โ โโโ bin/ โ
โ โโโ etc/ โ
โ โโโ mnt/ โ
โ โ โโโ data/ โ /dev/sdb1 mounted here โ
โ โ โโโ file1 โ
โ โ โโโ file2 โ
โ โโโ var/ โ
โ โ
โ The filesystem's root appears at /mnt/data. โ
โ The original /mnt/data contents are hidden. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The fstab Fields
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ /etc/fstab line: โ
โ โ
โ UUID=xxxx /mnt/data ext4 defaults,noexec 0 2 โ
โ โ โ โ โ โ โ โ
โ โ โ โ โ โ โโ passโ
โ โ โ โ โ โโโโโ dumpโ
โ โ โ โ โโโโโโโโโโโโโโโโโโโ opts โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโ type โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ mnt โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ deviceโ
โ โ
โ UUID is preferred: device names can change. โ
โ Test with mount -a before trusting a reboot. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The Busy Unmount
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ umount /mnt/data โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Kernel checks: โ โ
โ โ โ โ
โ โ 1. Any process has a file open? โ โ
โ โ โ YES: "target is busy" โ โ
โ โ โ โ
โ โ 2. Any shell's cwd is inside? โ โ
โ โ โ YES: "target is busy" โ โ
โ โ โ โ
โ โ 3. No active users? โ โ
โ โ โ Flush writes, detach from tree โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ Fix: cd /root; lsof +f -- /mnt/data; close files. โ
โ Then retry umount. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Persistent Mount Workflow
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. blkid /dev/sdb1 โ
โ โ โ
โ โผ UUID=abcd-1234 โ
โ 2. Edit /etc/fstab โ
โ โ โ
โ โผ โ
โ UUID=abcd-1234 /mnt/data ext4 defaults 0 2 โ
โ โ โ
โ โผ โ
โ 3. mount -a โ
โ โ โ
โ โผ โ
โ 4. findmnt /mnt/data โ
โ โ โ
โ โผ โ
โ 5. Reboot and verify (optional but recommended) โ
โ โ
โ A wrong fstab entry can prevent boot. โ
โ Use nofail for non-critical mounts: โ
โ UUID=xxxx /mnt/data ext4 defaults,nofail 0 2 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Summary
| Item | Value |
|---|---|
| Mount command | mount -t type device dir -o options |
| List mounts | mount or findmnt |
| Abbreviated form | mount /dev/X or mount /mnt (consults fstab) |
| Read-only | -o ro |
| No execution | -o noexec |
| Change options | -o remount,newopt |
| Unmount | umount /mnt or umount /dev/X |
| Persistent config | /etc/fstab with UUID |
| Test fstab | mount -a |
| Busy fix | Leave directory, close files |
Key takeaways:
- Mounting attaches a filesystem to a directory. The directory is the mount point, and the filesystem’s root appears there. There are no drive letters.
- The explicit form does not consult fstab. Give the type, device, and directory, and
mountacts immediately. The abbreviated form fills missing arguments from fstab. defaultsis a bundle, not a single option. It includesrw,suid,dev,exec,auto,nouser, andasync. Override individual options with a comma-separated list and no spaces.remountchanges options on a live filesystem. It is the only way to switchrwtoro(or back) without unmounting.- Unmounting flushes pending writes. A normal
umountis the safe way to remove media or shut down a filesystem. Lazy unmount is a last resort. - “Target is busy” means something is using the filesystem. A shell inside the mount point or an open file prevents unmounting. Close the process or leave the directory.
/etc/fstabmakes mounts persistent. Use UUIDs, not device names, and test withmount -abefore rebooting.- A malformed fstab can prevent boot. For non-critical mounts, add
nofailso a missing device does not block the boot process. findmntis the modern inspection tool. It shows the mount tree, can filter by device or mount point, and is easier to read thanmountoutput.- Mounting is not the end of the workflow. Permissions, ownership, and application-level configuration are separate concerns that the administrator must address after the mount succeeds.
Remember: mount is the bridge between a filesystem on a block device and the directory tree that applications navigate. The explicit form gives you immediate control; the fstab entry gives you persistence. The options determine what the mounted filesystem permitsโwrite access, execution, device filesโand the remount flag changes them without disruption. Unmounting is the reverse operation, and the busy filesystem is the most common obstacle. The LFCS candidate should be able to mount a device manually, verify it with findmnt, harden it with ro or noexec, write a correct UUID-based fstab entry, test it with mount -a, and unmount it cleanly after leaving the mount point.
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!