umount — Unmount a Filesystem
umount detaches a mounted filesystem from its mount point (directory). Use it when you need to safely detach a backup disk, remount storage with different options, or recover from a stale mount. Unmounting a filesystem that is actively in use can fail (best case) or cause data loss if you force it.
Use sudo umount /mnt/backups to unmount a backup volume, then verify it is gone with findmnt -T /mnt/backups.
Do not force-unmount a local disk just to "make the error go away". If processes are writing to the filesystem, you risk corruption. Find what's using it first.
Mental Model
Mounted: /dev/sdb1 -> /mnt/backups
umount /mnt/backups
Not mounted: /mnt/backups is just an empty directory again
Prerequisites
- Root privileges (
sudo) are usually required. - Know whether you're unmounting by mount point (recommended) or device.
Confirm the mount exists before unmounting:
findmnt -T /mnt/backups
Core Syntax
umount [OPTIONS] <mountpoint>
umount [OPTIONS] <device>
In most operational workflows, unmount by mount point:
sudo umount /mnt/backups
Key Options
| Option | What it does | Example | When to use |
|---|---|---|---|
-v | Verbose | sudo umount -v /mnt/backups | See what is being done |
-l | Lazy unmount | sudo umount -l /mnt/backups | Detach now, cleanup later (use with care) |
-f | Force unmount | sudo umount -f /mnt/backups | Unreachable NFS mounts (not typical for local disks) |
-r | Remount read-only if unmount fails | sudo umount -r /mnt/backups | Safer fallback on failure |
-R | Recursive unmount | sudo umount -R /mnt | Unmount a target and its submounts |
--fake | Dry run (no syscall) | sudo umount --fake /mnt/backups | See what would happen |
Examples (Commands + Expected Output)
On success, umount often prints no output. Verify results with findmnt.
Unmount a filesystem by mount point
sudo umount /mnt/backups
Expected output:
(no output on success)
Use case: Detach a backup disk after a backup window.
Verify the mount is gone
findmnt -T /mnt/backups
Expected output:
(no output / no matching mount)
Use case: Confirm your backup job is not writing to an unmounted path.
Unmount by device name
sudo umount /dev/sdb1
Expected output:
(no output on success)
Use case: Useful when you only know the device name.
Handle "target is busy" (find who is using it)
sudo umount /mnt/backups
Expected output:
umount: /mnt/backups: target is busy.
Find processes:
sudo lsof +f -- /mnt/backups
Expected output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 12345 root cwd DIR 8,17 4096 2 /mnt/backups
Use case: Stop the job using the mount, then unmount cleanly.
If lsof is not installed, try fuser -vm /mnt/backups (from the psmisc package).
Lazy unmount (detach now, cleanup later)
sudo umount -l /mnt/backups
Expected output:
(no output on success)
Use case: When a mount is stuck and you need to detach it, but you still plan to investigate why it was busy.
Lazy unmount can mask underlying problems (stuck processes, misbehaving services). Prefer a clean unmount when possible.
Force unmount (typically for unreachable NFS)
sudo umount -f /mnt/backups
Expected output:
(no output on success)
Use case: Only when the filesystem is remote and unreachable (e.g., NFS).
WordPress VPS Use Cases
| Situation | What you are unmounting | Command | Why it matters |
|---|---|---|---|
| Detach backup storage | /mnt/backups | sudo umount /mnt/backups | Prevent accidental writes when disk is removed |
| Change mount options | Root/backup mount | sudo umount /mnt/backups then mount -o ... | Apply new options safely |
| Fix a stale mount | Backup or network mount | sudo umount -l TARGET | Recover from stuck mounts (investigate afterward) |
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
target is busy | Processes still using the mount | Use lsof/fuser, stop the process, retry |
not mounted | Already unmounted or wrong target | Verify with findmnt -T TARGET |
| Unmount fails repeatedly | Open files or nested mounts | Use findmnt -R TARGET and unmount submounts |
Best Practices
- Unmount by mount point (
/mnt/backups) rather than guessing device names. - Verify with
findmntbefore and after unmounting. - Avoid
-ffor local disks.
Cheat Sheet
findmnt -T /mnt/backups
sudo umount /mnt/backups
sudo umount /dev/sdb1
sudo umount -v /mnt/backups
sudo umount -l /mnt/backups
sudo umount -R /mnt
sudo lsof +f -- /mnt/backups