umount
Overview
umount detaches a mounted filesystem from the directory tree. Use it before safe device removal, before offline fsck/mkfs, or when tearing down bind/NFS mounts. Prefer the mountpoint path over the device node. If the target is busy, find holders with lsof/fuser/findmnt rather than forcing blindly.
Syntax
umount [options] <mountpoint|device>
umount -a [options]Common Options
| Option | Description |
|---|---|
-l |
Lazy unmount — detach now, cleanup when busy refs drop |
-f |
Force (mainly stale NFS); dangerous on local disks |
-r |
If unmount fails, try remount read-only |
-v |
Verbose |
-a |
Unmount all (respects filters; use carefully) |
-t type |
Limit by filesystem type (with -a) |
-R |
Recursive unmount of target and children (newer util-linux) |
Key Use Cases
- Clean detach of USB/data disks before unplug
- Unmount before
fsck, repartition, ormkfs - Clear busy or stale NFS mounts
- Tear down bind mounts in chroots/containers/scripts
Safety
- Do not unmount
/on a live system. - Prefer stopping writers (services, shells with cwd on the mount) over
-fon local media. - Lazy (
-l) hides problems; processes may still hold files until exit. - Unmounting active databases or VMs can corrupt data — shut them down first.
Examples with Explanations
Unmount by mountpoint (preferred)
sudo umount /mnt/dataMatches how you mounted it; unambiguous when one device has multiple mounts.
Unmount by device
sudo umount /dev/sdb1Works when you know the block device; fails if not mounted or still busy.
Confirm before and after
findmnt /mnt/data
lsblk -f /dev/sdb
sudo umount /mnt/data
findmnt /mnt/data || echo "unmounted"Busy mount diagnosis
findmnt /mnt/data
sudo lsof +f -- /mnt/data
sudo fuser -vm /mnt/data
# common causes: shell cwd on mount, open logs, NFS locks, container bind
cd / # if your shell is the culprit
sudo umount /mnt/data“Target is busy” almost always means open files or a process cwd under the tree.
Lazy unmount
sudo umount -l /mnt/dataDetaches from the namespace immediately; actual teardown when references drop. Use for stuck mounts when you understand leftover processes may still write until they exit.
Force NFS (last resort)
sudo umount -f /mnt/nfs
# or lazy: sudo umount -l /mnt/nfsFor stale NFS when the server is gone. Avoid -f as a habit on local ext4/xfs.
Remount read-only fallback
sudo umount -r /mnt/dataIf full unmount fails, try to freeze writes via remount-ro (util-linux behavior with -r).
Multiple mounts / bind trees
findmnt -R /mnt/data
sudo umount -R /mnt/data # if supported: recursive
# else unmount children first, then parentBinds and nested mounts must be torn down from the leaves upward if recursive umount is unavailable.
Before fsck
sudo umount /mnt/data
sudo fsck -n /dev/sdb1Never run repairing fsck on a read-write mounted filesystem.
Understanding Output
Success is silent (exit 0). Failures print to stderr:
| Message | Typical cause |
|---|---|
target is busy |
Open files / cwd / mounts beneath |
not mounted |
Wrong path or already unmounted |
must be superuser |
Need root for most system mounts |
Notes & Pitfalls
- Systemd may manage mounts as
*.mountunits —systemctl stop mnt-data.mountcan be cleaner than raw umount. - USB: unmount then wait for LED idle before unplug; otherwise risk corruption.
udisksctl unmount -b /dev/sdb1is the desktop-friendly path on Ubuntu workstations.- Open-but-deleted files on other filesystems don’t block this umount; busy means this mount’s tree.
- In containers, mounts may be shared/slave — unmount semantics follow mount propagation.
Additional Resources
man umountman findmnt