umount
detach a disk safelyumount — spelt without the first n — detaches a filesystem. Before letting go it writes everything still held in memory to the disk, which is why a drive must be unmounted before it is unplugged.
"Safely remove" on a desktop is umount with a friendlier name.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
A program has a file open there, or a shell is standing in the directory. Nothing was detached.
lsof lists the processes with something open on that filesystem. Here a shell’s current directory — cwd — is inside it.
Once nothing is using the filesystem, umount succeeds silently.
The mount point remains, but the disk’s files are no longer reachable. Now it is safe to unplug.
Switches
A switch changes how the command behaves. These are the ones used day to day; man umount lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-l- Lazy: detach now, clean up when no longer in use.
-f- Force, for an unreachable network filesystem.
-R- Recursive: unmount everything mounted beneath as well.
-a- Unmount all filesystems.
-v- Verbose.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
sudo umount /dev/sdb1Unmounts by device name instead of directory.
sudo umount -l /mnt/nfsLazy: detaches now and cleans up when it stops being used. For a hung network share.
syncWrites all pending data to disk without unmounting.
udisksctl power-off -b /dev/sdbPowers down a USB drive after unmounting, ready for removal.
In cybersecurity
An unclean removal loses data that the system had already told you was saved.
A copy that has "finished" may still be in memory. Pulling the drive before umount returns can leave files truncated or the filesystem damaged.
-f and -l get past a busy mount but do not make it safe. Find and stop whatever is using it instead.
While an encrypted volume is mounted its contents are readable. Unmounting and closing it is what puts the protection back.