LFCA 37 🐧 Mounting and Unmounting Filesystems
The previous chapter covered the concepts: disks, partitions, filesystems, and the mount model. This chapter covers the commands. Mounting is the act of attaching a filesystem to a directory, and unmounting is the reverse. The mount command does the attaching, umount does the detaching, and findmnt reports the current mount tree. The /etc/fstab file declares the filesystems that mount at boot, and the mount -a command applies the file. The blkid command finds the UUIDs that identify the filesystems reliably. The mount command has a set of options that control the behavior — read-only, no-access-time, user-mountable — and the options determine how the filesystem behaves while it is mounted. This chapter covers the full set of commands, the common options, the fstab format, the patterns for mounting a new disk, the removal of a mount, and the recovery from the common failures.
Key point: mount <device> <mountpoint> attaches a filesystem to a directory. umount <mountpoint> or umount <device> detaches it. The mount point must exist and should be empty. The mount command reads /etc/fstab when the device or the mount point is given without the full specification, so mount /home mounts the entry for /home. The mount -a command mounts every entry in fstab that is not already mounted, and it is the way to test a change to the file. The findmnt command shows the mount tree, and the lsblk -f command shows the filesystems on the block devices.
The mount command
The mount command attaches a filesystem to a directory. Its basic form is mount <device> <mountpoint>.
sudo mount /dev/sdb1 /mnt/data
The /dev/sdb1 device is mounted at the /mnt/data directory. After the command, the contents of the filesystem appear at /mnt/data.
Why the mount point must exist. The mount command does not create the directory. The directory must exist before the mount, and the command fails if it does not.
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
The mkdir -p creates the directory and any missing parents. The -p flag suppresses the error if the directory already exists.
Why the mount point should be empty. The directory’s existing contents are hidden after the mount. The filesystem’s contents appear at the directory, and the directory’s own contents are inaccessible until the unmount. The hiding is the model, and an empty directory avoids the confusion.
Why the device must have a filesystem. The mount command reads the filesystem’s superblock. A device with no filesystem has no superblock, and the mount fails with “wrong fs type, bad option, bad superblock.” The device must be formatted before it can be mounted.
Why the command requires root. The mount command changes the system’s mount table, which is a privileged operation. A non-root user cannot mount a filesystem unless the fstab entry has the user option or the user has the CAP_SYS_ADMIN capability.
Why the mount can specify the type. The -t option specifies the filesystem type.
sudo mount -t ext4 /dev/sdb1 /mnt/data
The type is usually auto-detected, and the -t is needed only when the detection fails or when a specific type is required.
Why the mount can specify the options. The -o option specifies the mount options.
sudo mount -o ro,noatime /dev/sdb1 /mnt/data
The options are comma-separated. The ro mounts read-only, and the noatime disables the access time updates. The options are the fine-grained control.
Why the mount can use the fstab. The mount /mnt/data form reads the fstab entry for the mount point, and the mount /dev/sdb1 form reads the entry for the device. The fstab lookup is the convenience.
sudo mount /mnt/data # uses the fstab entry
sudo mount /dev/sdb1 # uses the fstab entry
Why the mount can be a bind mount. The --bind option mounts a directory at another directory, making the contents appear in both places.
sudo mount --bind /var/www /mnt/www
The bind mount is the way to make a directory accessible at a second path. The contents are the same, and the change in one is visible in the other.
Why the mount can be a loop mount. The -o loop option mounts an ISO file or a disk image as a filesystem.
sudo mount -o loop disk.iso /mnt/iso
The loop device is the kernel’s mechanism for treating a file as a block device. The ISO’s contents appear at the mount point.
The umount command
The umount command detaches a filesystem. Its form is umount <mountpoint> or umount <device>.
sudo umount /mnt/data
sudo umount /dev/sdb1
Both forms detach the filesystem. The mount point and the device are interchangeable as the argument.
Why the unmount can fail with “target is busy.” The unmount fails if a process has a file open on the filesystem or has its working directory on it. The kernel refuses the unmount to prevent the data loss.
sudo umount /mnt/data
# umount: /mnt/data: target is busy.
Why the busy check matters. The unmount detaches the filesystem, and the open files and the working directories are left dangling. The kernel prevents this by refusing the unmount. The fix is to find the process and stop it, or to change the working directory.
The lsof and fuser commands find the process.
sudo lsof +f -- /mnt/data
sudo fuser -m /mnt/data
The lsof +f -- /mnt/data lists the open files under the mount point. The fuser -m /mnt/data lists the PIDs with the files open. The two find the process that is blocking the unmount.
The -l option for a lazy unmount. The umount -l option detaches the filesystem immediately and cleans up the references later. The filesystem is no longer visible, and the open files are released when the process closes them.
sudo umount -l /mnt/data
The lazy unmount is the way to detach a filesystem that is busy. The risk is that the process with the open file continues to write to a filesystem that is no longer mounted, and the writes may be lost.
The -f option for a forced unmount. The umount -f option forces the unmount, which is used for the unreachable network filesystems.
sudo umount -f /mnt/nfs
The forced unmount is the last resort. The unmount may fail even with the flag, and the -l is the safer alternative.
Why the unmount should be done before the device is removed. A USB drive that is removed while mounted can lose data. The unmount flushes the buffers and detaches the filesystem, and the device can then be removed safely. The sync command flushes the buffers manually, and the umount does it as part of the detach.
Why the unmount is the reverse of the mount. The mount attaches the filesystem to the directory, and the unmount detaches it. The directory’s original contents become visible again after the unmount. The model is symmetric.
The /etc/fstab file
The /etc/fstab file declares the filesystems that mount at boot. Each line has six fields, and the file is read by the mount command and by the boot process.
# <device> <mountpoint> <type> <options> <dump> <pass>
UUID=1234abcd-... / ext4 defaults 0 1
UUID=5678efgh-... /home ext4 defaults 0 2
UUID=A1B2-C3D4 /boot/efi vfat umask=0077 0 2
/swapfile none swap sw 0 0
The device field. The device is the filesystem to mount. It is given as a UUID, a LABEL, a PARTUUID, or a device path. The UUID is the preferred form because it does not change.
UUID=1234abcd-...
LABEL=data
PARTUUID=5678-...
/dev/sdb1
The mount point field. The mount point is the directory. The swap filesystems use none because they are not mounted at a directory.
The type field. The type is the filesystem type — ext4, xfs, btrfs, vfat, swap, and so on. The auto value lets the kernel detect the type.
The options field. The options are the mount options, comma-separated. The defaults value is the shorthand for rw,suid,dev,exec,auto,nouser,async.
The dump field. The dump field is for the dump backup tool. It is almost always 0, which means the filesystem is not dumped.
The pass field. The pass field is the order for the fsck check at boot. The root filesystem is 1, the other filesystems are 2, and the filesystems that do not need a check are 0.
Why the file is read at boot. The boot process reads the fstab and mounts the entries. The root filesystem is mounted first (the pass of 1), and the others follow. A wrong entry can prevent the boot or delay it.
Why the file should be tested. The mount -a command mounts every entry in the fstab that is not already mounted. It is the way to verify a change before rebooting.
sudo mount -a
The command reads the fstab and mounts the entries. If an entry is wrong, the command fails and the error is displayed. The boot would fail the same way, and the test is the prevention.
Why the nofail option matters. The nofail option tells the boot to continue if the mount fails. It is used for the filesystems that are not essential — a data disk, a USB drive — and it prevents the boot from being blocked by a missing device.
UUID=1234abcd-... /mnt/data ext4 defaults,nofail 0 2
Why the x-systemd options exist. The systemd-specific options control the mount’s behavior in the systemd model. The x-systemd.automount mounts the filesystem on first access, and the x-systemd.device-timeout sets the timeout for the device to appear.
Why the swap entry differs. The swap entry has none as the mount point and swap as the type. The sw option is the swap-specific option.
Why the file is the single source of truth. The fstab is the declaration of the filesystems, and the mount command reads it. The manual mounts are not in the file, and they are lost at the next boot. The fstab is the persistent configuration.
The findmnt command
The findmnt command shows the mount tree. It is the modern replacement for the mount command with no arguments, and its output is structured and filterable.
findmnt
# TARGET SOURCE FSTYPE OPTIONS
# / /dev/sda2 ext4 rw,relatime
# ├─/home /dev/sda3 ext4 rw,relatime
# ├─/boot/efi /dev/sda1 vfat rw,relatime
# └─/mnt/data /dev/sdb1 ext4 rw,relatime
The tree shows the mount points, the sources, the types, and the options. The nesting shows the parent-child relationship of the mounts.
Why the tree is useful. The tree shows which filesystems are mounted under which mount points. The nesting is the model, and the tree is the visual.
The -l option for a flat list. The findmnt -l lists the mounts in a flat table, which is useful for the scripts.
The -t option filters by type. The findmnt -t ext4 shows only the ext4 mounts.
The -S option filters by source. The findmnt -S /dev/sdb1 shows the mount for the source.
The -T option filters by target. The findmnt -T /home shows the mount that contains the target path.
findmnt -T /home/user/file
# TARGET SOURCE FSTYPE OPTIONS
# /home /dev/sda3 ext4 rw,relatime
The -T is the way to find which filesystem contains a path. The output is the mount that holds the path, which is useful for the diagnostics.
The --df option for the usage. The findmnt --df shows the disk usage, like the df command.
Why the findmnt is preferred over mount. The findmnt output is structured, filterable, and consistent. The mount output is the raw mount table, and it is harder to parse. The findmnt is the modern tool.
Why the lsblk -f is the complement. The lsblk -f shows the filesystems on the block devices, including the UUIDs, the labels, and the mount points.
lsblk -f
# NAME FSTYPE FSVER LABEL UUID MOUNTPOINTS
# sda
# ├─sda1 vfat FAT32 A1B2-C3D4 /boot/efi
# ├─sda2 ext4 1.0 1234abcd-... /
# └─sda3 ext4 1.0 5678efgh-... /home
The lsblk -f is the device-oriented view, and the findmnt is the mount-oriented view. The two together cover the storage.
The mount options
The mount options control the behavior of the filesystem while it is mounted. The options are the fine-grained control, and they are the -o argument of the mount command or the fourth field of the fstab.
The common options.
| Option | Effect |
|---|---|
rw | Read-write |
ro | Read-only |
noatime | Do not update the access time |
relatime | Update the access time only if it is older than the modification time |
nodiratime | Do not update the directory access time |
sync | Write synchronously |
async | Write asynchronously (default) |
exec | Allow execution |
noexec | Disallow execution |
suid | Allow setuid |
nosuid | Disallow setuid |
user | Allow a non-root user to mount |
users | Allow any user to mount and unmount |
nouser | Only root can mount (default) |
auto | Mount at boot with -a |
noauto | Do not mount at boot |
defaults | The shorthand for the defaults |
nofail | Do not fail the boot if the mount fails |
Why noatime matters. The noatime option disables the access time updates, which reduces the writes. On a busy filesystem, the access time updates are a significant fraction of the writes, and the noatime improves the performance and the SSD lifetime.
Why noexec matters. The noexec option disallows the execution of the binaries on the filesystem. It is used for the filesystems that hold the data, not the executables, and it is a security measure.
Why nosuid matters. The nosuid option disallows the setuid binaries on the filesystem. It is used for the filesystems that hold the user data, and it prevents a setuid binary from being used to escalate the privileges.
Why user matters. The user option allows a non-root user to mount the filesystem. It is used for the removable media, and it is why a user can mount a USB drive without the root.
Why nofail matters. The nofail option tells the boot to continue if the mount fails. It is used for the filesystems that are not essential, and it prevents the boot from being blocked by a missing device.
Why the options should be deliberate. The options change the behavior, and the wrong option can break the system. The noexec on the root filesystem would prevent the executables from running, and the ro on the home filesystem would prevent the writes. The options should be chosen with the workload in mind.
Why the options can be tested. The mount -o remount,noatime /home command remounts the filesystem with the new option, which is the way to test an option without the reboot. The remount is the safe way to try a change.
Common patterns
Several mount patterns appear in the daily work, and each is worth knowing.
Mounting a new data disk. The disk is partitioned, formatted, and mounted, and the fstab entry is added.
sudo parted /dev/sdb mklabel gpt
sudo parted /dev/sdb mkpart primary ext4 0% 100%
sudo mkfs.ext4 /dev/sdb1
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
sudo blkid /dev/sdb1 # get the UUID
# Add to /etc/fstab:
# UUID=... /mnt/data ext4 defaults,nofail 0 2
sudo mount -a # test
The sequence is the standard, and the nofail is the safety for the non-essential disk.
Mounting a USB drive. The USB drive is mounted at a temporary mount point, and the unmount is required before the removal.
lsblk # find the device
sudo mkdir -p /mnt/usb
sudo mount /dev/sdc1 /mnt/usb
# use the drive
sudo umount /mnt/usb
The USB drive’s device name can change, and the lsblk is the way to find it.
Mounting an ISO. The ISO file is mounted with the loop option.
sudo mkdir -p /mnt/iso
sudo mount -o loop disk.iso /mnt/iso
# use the ISO
sudo umount /mnt/iso
The loop mount is the way to read an ISO without burning it.
The bind mount. The bind mount makes a directory accessible at a second path.
sudo mkdir -p /mnt/www
sudo mount --bind /var/www /mnt/www
The bind mount is the way to expose a directory to a service that expects a specific path.
The NFS mount. The NFS mount attaches a remote filesystem.
sudo mount -t nfs server:/export /mnt/nfs
The NFS mount is the network filesystem, and it is used for the shared storage. The _netdev option in the fstab tells the boot to wait for the network before mounting.
The remount. The remount changes the options of a mounted filesystem.
sudo mount -o remount,ro /mnt/data
The remount is the way to change the options without the unmount. The ro is the common use, and the remount is the way to make a filesystem read-only.
The temporary mount. The mount is not in the fstab, and it is lost at the reboot. The temporary mount is for the one-off work, and the fstab is for the persistent.
Why the patterns are the vocabulary. The patterns are the mount, the unmount, the fstab, the UUID, the options. Each is a small piece, and the combination is the work. The patterns are the daily operations, and the knowledge of them is the skill.
Complete Example Session
# ============================================
# PART 1: THE BASIC MOUNT
# ============================================
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
findmnt /mnt/data
# TARGET SOURCE FSTYPE OPTIONS
# /mnt/data /dev/sdb1 ext4 rw,relatime
# ============================================
# PART 2: THE UNMOUNT
# ============================================
sudo umount /mnt/data
# or
sudo umount /dev/sdb1
# ============================================
# PART 3: THE BUSY UNMOUNT
# ============================================
sudo umount /mnt/data
# umount: /mnt/data: target is busy.
sudo lsof +f -- /mnt/data
# COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
# bash 1234 alice cwd DIR ...
sudo fuser -m /mnt/data
# /mnt/data: 1234c
# Kill the process or change its directory, then unmount.
# ============================================
# PART 4: THE LAZY UNMOUNT
# ============================================
sudo umount -l /mnt/data
# ============================================
# PART 5: THE FSTAB
# ============================================
cat /etc/fstab
# UUID=1234abcd-... / ext4 defaults 0 1
# UUID=5678efgh-... /home ext4 defaults 0 2
# UUID=... /mnt/data ext4 defaults,nofail 0 2
# ============================================
# PART 6: THE UUID
# ============================================
sudo blkid /dev/sdb1
# /dev/sdb1: UUID="abcd1234-..." TYPE="ext4" PARTUUID="..."
# ============================================
# PART 7: THE MOUNT -A TEST
# ============================================
sudo mount -a
# (no output = all entries mounted successfully)
# ============================================
# PART 8: THE FINDMNT
# ============================================
findmnt
# TARGET SOURCE FSTYPE OPTIONS
# / /dev/sda2 ext4 rw,relatime
# ├─/home /dev/sda3 ext4 rw,relatime
# ├─/boot/efi /dev/sda1 vfat rw,relatime
# └─/mnt/data /dev/sdb1 ext4 rw,relatime
findmnt -T /home/user/file
# TARGET SOURCE FSTYPE OPTIONS
# /home /dev/sda3 ext4 rw,relatime
# ============================================
# PART 9: THE OPTIONS
# ============================================
# Read-only
sudo mount -o ro /dev/sdb1 /mnt/data
# No access time updates
sudo mount -o noatime /dev/sdb1 /mnt/data
# Remount with new options
sudo mount -o remount,ro /mnt/data
# ============================================
# PART 10: THE LOOP MOUNT
# ============================================
sudo mkdir -p /mnt/iso
sudo mount -o loop disk.iso /mnt/iso
# ============================================
# PART 11: THE BIND MOUNT
# ============================================
sudo mkdir -p /mnt/www
sudo mount --bind /var/www /mnt/www
# ============================================
# PART 12: WHAT NOT TO DO
# ============================================
# Don't forget to unmount a USB drive before removing it
# sudo umount /mnt/usb
# Don't edit fstab without testing
# sudo mount -a
# Don't use the device name in fstab
# Use UUID.
# Don't mount at a non-empty directory without knowing
# The existing contents are hidden.
# Don't force the unmount when the lazy works
# sudo umount -f # use -l instead
# Don't forget the nofail for a non-essential mount
# The boot can be blocked by a missing device.
The twelve parts cover the basic mount, the unmount, the busy unmount, the lazy unmount, the fstab, the UUID, the test, the findmnt, the options, the loop mount, the bind mount, and the anti-patterns.
Quick Reference
The Commands
| Command | Purpose |
|---|---|
mount <dev> <dir> | Mount |
mount <dir> | Mount from fstab |
mount -a | Mount all fstab entries |
mount -t <type> | Specify the type |
mount -o <opts> | Specify the options |
mount -o remount,<opts> | Change the options |
mount --bind <src> <dst> | Bind mount |
mount -o loop <file> <dir> | Loop mount |
umount <dir> | Unmount |
umount -l <dir> | Lazy unmount |
umount -f <dir> | Forced unmount |
findmnt | Show the mount tree |
blkid | Show the UUIDs |
lsblk -f | Show the filesystems |
The fstab Fields
| Field | Example | Purpose |
|---|---|---|
| Device | UUID=... | The filesystem |
| Mount point | /home | Where to mount |
| Type | ext4 | The filesystem type |
| Options | defaults | The mount options |
| Dump | 0 | The backup flag |
| Pass | 1 or 2 | The fsck order |
The Common Options
| Option | Effect |
|---|---|
defaults | The standard options |
rw / ro | Read-write / read-only |
noatime | Do not update the access time |
noexec | Disallow execution |
nosuid | Disallow setuid |
user | Allow a non-root user to mount |
noauto | Do not mount at boot |
nofail | Do not fail the boot |
_netdev | Wait for the network |
The Busy Unmount
| Command | Purpose |
|---|---|
lsof +f -- <dir> | List the open files |
fuser -m <dir> | List the PIDs |
umount -l <dir> | Lazy unmount |
umount -f <dir> | Forced unmount |
The Finding Commands
| Command | Purpose |
|---|---|
findmnt | The mount tree |
findmnt -l | The flat list |
findmnt -T <path> | The mount containing a path |
lsblk -f | The filesystems on the devices |
blkid | The UUIDs |
df -h | The usage |
Best Practices
✅ Do This:
# Create the mount point first
sudo mkdir -p /mnt/data && sudo mount /dev/sdb1 /mnt/data # ✅
# Use the UUID in fstab
UUID=abcd1234-... /mnt/data ext4 defaults,nofail 0 2 # ✅
# Test the fstab before rebooting
sudo mount -a # ✅
# Use nofail for a non-essential mount
defaults,nofail # ✅
# Use noatime for a busy filesystem
defaults,noatime # ✅
# Use the lazy unmount for a busy filesystem
sudo umount -l /mnt/data # ✅
# Find the blocking process
sudo lsof +f -- /mnt/data # ✅
# Unmount before removing a USB drive
sudo umount /mnt/usb # ✅
❌ Don’t Do This:
# Don't mount at a non-empty directory without knowing
sudo mount /dev/sdb1 /home # hides the contents # ⚠️
# Don't use the device name in fstab
/dev/sdb1 /mnt/data ext4 defaults 0 2 # name can change # ⚠️
# Don't edit fstab without testing
# A wrong entry can break the boot. # ⚠️
# Don't force the unmount when the lazy works
sudo umount -f /mnt/data # use -l # ⚠️
# Don't forget the nofail for a non-essential mount
# The boot can be blocked. # ⚠️
# Don't remove a USB drive without unmounting
# The data can be lost. # ⚠️
# Don't assume the mount point exists
sudo mount /dev/sdb1 /mnt/newdir # fails if the dir missing # ⚠️
Common Pitfalls
| Pitfall | Problem | Solution |
|---|---|---|
| Mount point missing | Mount fails | mkdir -p first |
| Busy unmount | Target is busy | lsof, fuser, -l |
| Device name in fstab | Changes at boot | Use UUID |
| Wrong UUID | Mount fails at boot | blkid to verify |
| Non-empty mount point | Contents hidden | Use an empty directory |
| Wrong options | Unexpected behavior | Test with remount |
Forgot nofail | Boot blocked | Add the option |
| Forgot the fstab | Mount lost at reboot | Add the entry |
Real-World Examples
1. Mount a data disk
sudo mount /dev/sdb1 /mnt/data
2. Unmount
sudo umount /mnt/data
3. Find the blocking process
sudo lsof +f -- /mnt/data
4. Lazy unmount
sudo umount -l /mnt/data
5. Get the UUID
sudo blkid /dev/sdb1
6. The fstab entry
UUID=abcd1234-... /mnt/data ext4 defaults,nofail 0 2
7. Test the fstab
sudo mount -a
8. The mount tree
findmnt
9. The loop mount
sudo mount -o loop disk.iso /mnt/iso
10. The bind mount
sudo mount --bind /var/www /mnt/www
Visual: The Mount
┌──────────────────────────────────────────────────────────┐
│ BEFORE │
│ │
│ / │
│ └── mnt │
│ └── data (empty directory) │
│ │
│ /dev/sdb1 (the filesystem, not mounted) │
│ │
├──────────────────────────────────────────────────────────┤
│ sudo mount /dev/sdb1 /mnt/data │
│ │
├──────────────────────────────────────────────────────────┤
│ AFTER │
│ │
│ / │
│ └── mnt │
│ └── data (the root of the filesystem) │
│ ├── file1 │
│ ├── file2 │
│ └── dir │
│ │
│ The filesystem's contents appear at /mnt/data. │
│ │
└──────────────────────────────────────────────────────────┘
Visual: The fstab
┌──────────────────────────────────────────────────────────┐
│ UUID=1234abcd-... / ext4 defaults 0 1 │
│ UUID=5678efgh-... /home ext4 defaults 0 2 │
│ UUID=abcd1234-... /mnt/data ext4 defaults,nofail 0 2 │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ └── fsck order│
│ │ │ │ │ └── dump flag│
│ │ │ │ └── options │
│ │ │ └── type │
│ │ └── mount point │
│ └── device (UUID) │
│ │
│ Read at boot. Tested with mount -a. │
│ │
└──────────────────────────────────────────────────────────┘
Visual: The Busy Unmount
┌──────────────────────────────────────────────────────────┐
│ sudo umount /mnt/data │
# umount: /mnt/data: target is busy. │
│ │
│ WHY? │
│ A process has a file open on the filesystem, │
│ or its working directory is on the filesystem. │
│ │
│ FIND IT │
│ sudo lsof +f -- /mnt/data │
│ sudo fuser -m /mnt/data │
│ │
│ FIX IT │
│ Stop the process, or change its directory, │
│ or use the lazy unmount: │
│ sudo umount -l /mnt/data │
│ │
└──────────────────────────────────────────────────────────┘
Visual: findmnt
┌──────────────────────────────────────────────────────────┐
│ findmnt │
│ │
│ TARGET SOURCE FSTYPE OPTIONS │
│ / /dev/sda2 ext4 rw,relatime │
│ ├─/home /dev/sda3 ext4 rw,relatime │
│ ├─/boot/efi /dev/sda1 vfat rw,relatime │
│ └─/mnt/data /dev/sdb1 ext4 rw,noatime │
│ │
│ The tree shows the mount hierarchy. │
│ The nesting is the model. │
│ │
│ findmnt -T /home/user/file │
│ → the mount that contains the path │
│ │
│ findmnt -t ext4 │
│ → only the ext4 mounts │
│ │
└──────────────────────────────────────────────────────────┘
Visual: The Mount Options
┌──────────────────────────────────────────────────────────┐
│ defaults │
│ rw,suid,dev,exec,auto,nouser,async │
│ │
│ ro │
│ read-only │
│ │
│ noatime │
│ do not update the access time │
│ fewer writes, better performance │
│ │
│ noexec │
│ disallow execution │
│ security for data filesystems │
│ │
│ nosuid │
│ disallow setuid │
│ security for user filesystems │
│ │
│ user │
│ allow a non-root user to mount │
│ for removable media │
│ │
│ nofail │
│ do not fail the boot if the mount fails │
│ for non-essential filesystems │
│ │
└──────────────────────────────────────────────────────────┘
Summary
| Command | Purpose |
|---|---|
mount <dev> <dir> | Attach a filesystem |
umount <dir> | Detach a filesystem |
mount -a | Mount all fstab entries |
mount -o remount,<opts> | Change the options |
findmnt | Show the mount tree |
blkid | Show the UUIDs |
lsblk -f | Show the filesystems |
lsof +f -- <dir> | Find the open files |
fuser -m <dir> | Find the PIDs |
| fstab Field | Example |
|---|---|
| Device | UUID=... |
| Mount point | /home |
| Type | ext4 |
| Options | defaults,nofail |
| Dump | 0 |
| Pass | 2 |
Key takeaways:
- Mounting attaches a filesystem to a directory — the directory is the mount point, it must exist, and its contents are hidden while the filesystem is mounted
- Unmounting detaches the filesystem — the
umountcommand takes the mount point or the device, and it fails with “target is busy” if a process has the filesystem in use - The busy unmount is fixed with
lsoforfuser— the commands find the process, and theumount -lis the lazy alternative - The
/etc/fstabfile declares the filesystems that mount at boot — the six fields are the device, the mount point, the type, the options, the dump flag, and the fsck order - UUIDs are used instead of device names — the UUID is stored in the filesystem and does not change, and the
blkidcommand finds it - The
mount -acommand tests the fstab — it mounts every entry that is not already mounted, and it is the safe way to verify a change before rebooting - The
nofailoption prevents the boot from being blocked — the option is for the non-essential filesystems, and it tells the boot to continue if the mount fails - The
findmntcommand shows the mount tree — the-Toption finds the mount that contains a path, and the-loption gives a flat list - The
noatimeoption reduces the writes — it disables the access time updates, which improves the performance and the SSD lifetime - The
useroption allows a non-root mount — it is the mechanism for the removable media, and it is why a user can mount a USB drive
Remember: Mounting is the act of attaching a filesystem to a directory, and it is the operation that makes the storage usable. The mount command attaches, the umount command detaches, the /etc/fstab declares the boot-time mounts, and the findmnt shows the tree. Use the UUIDs, test the fstab with mount -a, add the nofail for the non-essential mounts, and unmount before removing the device. The commands are the interface, and the fstab is the persistence.
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!