Skip to main content

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.

Quick Summary

Use sudo umount /mnt/backups to unmount a backup volume, then verify it is gone with findmnt -T /mnt/backups.

warning

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

unmount-mental-model.txt
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:

verify-mount-before-umount.sh
findmnt -T /mnt/backups

Core Syntax

umount-syntax.sh
umount [OPTIONS] <mountpoint>
umount [OPTIONS] <device>

In most operational workflows, unmount by mount point:

  • sudo umount /mnt/backups

Key Options

OptionWhat it doesExampleWhen to use
-vVerbosesudo umount -v /mnt/backupsSee what is being done
-lLazy unmountsudo umount -l /mnt/backupsDetach now, cleanup later (use with care)
-fForce unmountsudo umount -f /mnt/backupsUnreachable NFS mounts (not typical for local disks)
-rRemount read-only if unmount failssudo umount -r /mnt/backupsSafer fallback on failure
-RRecursive unmountsudo umount -R /mntUnmount a target and its submounts
--fakeDry run (no syscall)sudo umount --fake /mnt/backupsSee what would happen

Examples (Commands + Expected Output)

Output varies

On success, umount often prints no output. Verify results with findmnt.

Unmount a filesystem by mount point

umount-backups-by-mountpoint.sh
sudo umount /mnt/backups

Expected output:

example-output-umount-success.txt
(no output on success)

Use case: Detach a backup disk after a backup window.

Verify the mount is gone

verify-umount.sh
findmnt -T /mnt/backups

Expected output:

example-output-findmnt-not-mounted.txt
(no output / no matching mount)

Use case: Confirm your backup job is not writing to an unmounted path.

Unmount by device name

umount-by-device.sh
sudo umount /dev/sdb1

Expected output:

example-output-umount-by-device.txt
(no output on success)

Use case: Useful when you only know the device name.

Handle "target is busy" (find who is using it)

umount-busy-example.sh
sudo umount /mnt/backups

Expected output:

example-output-umount-busy.txt
umount: /mnt/backups: target is busy.

Find processes:

find-open-files-on-mount.sh
sudo lsof +f -- /mnt/backups

Expected output:

example-output-lsof-mount.txt
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.

tip

If lsof is not installed, try fuser -vm /mnt/backups (from the psmisc package).

Lazy unmount (detach now, cleanup later)

umount-lazy.sh
sudo umount -l /mnt/backups

Expected output:

example-output-umount-lazy.txt
(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.

caution

Lazy unmount can mask underlying problems (stuck processes, misbehaving services). Prefer a clean unmount when possible.

Force unmount (typically for unreachable NFS)

umount-force-nfs.sh
sudo umount -f /mnt/backups

Expected output:

example-output-umount-force.txt
(no output on success)

Use case: Only when the filesystem is remote and unreachable (e.g., NFS).

WordPress VPS Use Cases

SituationWhat you are unmountingCommandWhy it matters
Detach backup storage/mnt/backupssudo umount /mnt/backupsPrevent accidental writes when disk is removed
Change mount optionsRoot/backup mountsudo umount /mnt/backups then mount -o ...Apply new options safely
Fix a stale mountBackup or network mountsudo umount -l TARGETRecover from stuck mounts (investigate afterward)

Troubleshooting

ProblemLikely causeFix
target is busyProcesses still using the mountUse lsof/fuser, stop the process, retry
not mountedAlready unmounted or wrong targetVerify with findmnt -T TARGET
Unmount fails repeatedlyOpen files or nested mountsUse findmnt -R TARGET and unmount submounts

Best Practices

  • Unmount by mount point (/mnt/backups) rather than guessing device names.
  • Verify with findmnt before and after unmounting.
  • Avoid -f for local disks.
Cheat Sheet
umount-cheat-sheet.sh
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

What's Next