Mounting and Unmounting Filesystems — Accessing Storage in Linux¶
Mounting is the process of attaching a filesystem to the Linux directory hierarchy so that users and applications can access the files stored on it. A filesystem cannot be used until it is mounted. Unmounting safely detaches the filesystem, ensuring that all pending data is written to disk before the storage device is removed. Understanding mounting is a fundamental skill for Linux administrators, DevOps engineers, Cloud Architects, Platform Engineers, and Site Reliability Engineers (SREs).
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand mounting and unmounting
- Learn about mount points
- Mount filesystems manually
- Unmount filesystems safely
- Configure persistent mounts
- Understand
/etc/fstab - Troubleshoot mount issues
- Apply storage best practices
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management
- Module 5 – Users and Groups
- Module 6 – Process Management
- Module 7 – Package Management
- Module 8 – Networking
- Module 9 Lessons 1–3
Why Learn Mounting?¶
Imagine:
- A new SSD is attached to a Linux server.
- A cloud block storage volume is added.
- A USB drive is connected.
- A backup disk needs to be mounted.
- A Kubernetes Persistent Volume is attached to a node.
The storage cannot be used until it is mounted.
What is Mounting?¶
Mounting is the process of attaching a filesystem to a directory.
Example:
Linux makes all storage accessible through a single directory tree.
What is a Mount Point?¶
A mount point is an empty directory where a filesystem is attached.
Example:
If /dev/sdb1 is mounted on /data, its contents become available under:
Linux Directory Tree¶
Unlike Windows, Linux does not assign drive letters.
Instead:
Everything is attached somewhere under the root (/) directory.
View Mounted Filesystems¶
Display all mounted filesystems.
Display Mounted Filesystems with Usage¶
Example:
View Block Devices¶
Example:
The MOUNTPOINT column shows where a filesystem is mounted.
Create a Mount Point¶
Create a directory.
Mount a Filesystem¶
Basic syntax:
Example:
Verify the Mount¶
or
or
Access Files¶
After mounting:
Files stored on the partition are now accessible.
Unmount a Filesystem¶
or
Notice the command is
umount, notunmount.
Why Unmount?¶
Unmounting ensures:
- Cached data is written to disk
- Files are closed properly
- Filesystem corruption is avoided
- Devices can be removed safely
Device Busy Error¶
Example:
Possible causes:
- Open files
- Active processes
- Current working directory inside the mount
Find processes using the filesystem.
or
Force Unmount¶
If absolutely necessary:
Force unmount is generally intended for specific situations, such as unreachable network filesystems. Use it carefully.
Lazy Unmount¶
Lazy unmount detaches the filesystem immediately and completes the unmount after active references are released.
Persistent Mounts¶
Manual mounts disappear after reboot.
Persistent mounts are configured in:
Understanding /etc/fstab¶
Example:
Fields:
| Field | Description |
|---|---|
| Device/UUID | Filesystem identifier |
| Mount Point | Directory where it will be mounted |
| Filesystem | ext4, xfs, etc. |
| Options | Mount options |
| Dump | Backup utility flag |
| Pass | Filesystem check order |
View UUID¶
Example:
Using UUIDs is preferred because device names can change after reboot.
Test fstab¶
After editing:
If no errors appear, the configuration is valid.
Common Mount Options¶
| Option | Description |
|---|---|
defaults | Standard mount options |
ro | Read-only |
rw | Read-write |
noexec | Prevent execution of binaries |
nosuid | Ignore SUID/SGID bits |
nodev | Ignore device files |
Example:
Common Commands¶
Mount filesystem.
Unmount filesystem.
Display mounted filesystems.
Display filesystem usage.
Display block devices.
Test fstab.
Real Production Examples¶
Mount a cloud volume.
Verify mount.
View UUID.
Test persistent configuration.
Production Perspective¶
Mounting is essential for:
- Database storage
- Application data
- Backup volumes
- Kubernetes Persistent Volumes
- NFS shares
- SAN storage
- Cloud block storage
- External storage devices
Correct mount configuration ensures storage remains available after system reboots.
Hands-on Lab¶
Task 1¶
Display mounted filesystems.
Task 2¶
Display filesystem usage.
Task 3¶
Create a mount point.
Task 4¶
Mount a test partition.
Task 5¶
Verify the mount.
Task 6¶
Display the UUID.
Task 7¶
Unmount the filesystem.
Task 8¶
Test /etc/fstab.
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
mount | Mount filesystem | Storage activation |
umount | Unmount filesystem | Safe removal |
df -Th | Display mounted filesystems | Capacity monitoring |
lsblk | View mount points | Storage inventory |
blkid | Display UUIDs | Persistent mounting |
mount -a | Test /etc/fstab | Configuration verification |
Common Mount Errors¶
| Error | Possible Cause |
|---|---|
wrong fs type | Missing or incorrect filesystem |
mount point does not exist | Directory not created |
device is busy | Filesystem in use |
permission denied | Insufficient privileges |
special device does not exist | Incorrect device name |
Production Troubleshooting Scenario¶
Scenario
A new cloud storage volume does not appear after reboot.
Investigation:
Check mounted filesystems.
The storage is missing.
Review /etc/fstab.
The administrator used:
Instead of the filesystem UUID.
Retrieve the UUID.
Update /etc/fstab.
Test:
The storage mounts successfully and will persist across reboots.
Best Practices¶
- Always use UUIDs in
/etc/fstab. - Test
/etc/fstabwithmount -abefore rebooting. - Create dedicated mount points.
- Unmount removable devices before disconnecting them.
- Verify successful mounts using
df -Thorlsblk. - Avoid force unmount unless absolutely necessary.
Common Mistakes¶
❌ Forgetting to create the mount point.
✅ Remember to to create the mount point.
❌ Editing /etc/fstab without testing.
✅ Edit /etc/fstab without testing only when appropriate and with a backup.
❌ Removing storage without unmounting.
✅ Avoid this mistake: removing storage without unmounting.
❌ Using device names instead of UUIDs.
✅ Prefer UUIDs rather than using device names.
❌ Unmounting a filesystem while applications are actively using it.
✅ Avoid this mistake: unmounting a filesystem while applications are actively using it.
Interview Questions¶
Beginner¶
- What is mounting?
- What is a mount point?
- Which command mounts a filesystem?
- Which command unmounts a filesystem?
Intermediate¶
- Why are UUIDs preferred over device names?
- What is the purpose of
/etc/fstab? - How do you identify processes preventing an unmount?
- What does
mount -ado?
Architect Level¶
- How would you design persistent storage for production Linux servers?
- How would you troubleshoot a server that fails to boot because of an incorrect
/etc/fstabentry? - What mount options would you use to improve the security of a shared storage volume?
Summary¶
In this lesson, you learned:
- Mounting and unmounting filesystems
- Mount points
- The
mountandumountcommands - Persistent mounts
/etc/fstab- UUIDs
- Mount troubleshooting
- Production storage best practices
Mounting connects a filesystem to the Linux directory tree, making stored data accessible to users and applications. Proper mount configuration, especially using UUIDs and /etc/fstab, is essential for reliable and maintainable Linux storage management.
Key Takeaways¶
- A filesystem must be mounted before it can be used.
- Mount points are directories where filesystems are attached.
- Use
mountto attach andumountto detach filesystems. - Configure persistent mounts using
/etc/fstab. - Use UUIDs instead of device names for reliable mounting.
- Always test
/etc/fstabwithmount -abefore rebooting.
What's Next?¶
LVM (Logical Volume Manager) — Flexible Storage Management in Linux
You'll explore:
- Physical Volumes (PV)
- Volume Groups (VG)
- Logical Volumes (LV)
- Creating and extending volumes
- Online storage expansion
- Snapshots
- Enterprise storage management
LVM provides flexible storage management and is widely used in enterprise Linux environments for scalable and easily expandable storage.