umount system
yes it's umount, not unmount. blame the 70s.
The umount man page is 300 lines long. You need one command and the discipline to use it before yanking out the cable.
You’re done with the USB drive. The files are copied. So you pull it out. The kernel screams. Data is corrupted. Or worse — it was still writing when you pulled the plug, so half a file is on the drive and the other half is in a write buffer that no longer exists. You lost data because you couldn’t type seven characters before removing the hardware.
Also — yes, it’s umount, not unmount. There’s no ’n’. This was a character limit decision from the 1970s when Unix filenames were kept short. Ken Thompson once said the missing ’n’ was the biggest mistake in Unix. Or maybe he was joking. With Ken Thompson you never know. Either way, you’ll type unmount at least once. It won’t work. Now you know why.
Unless you’re running Windows then wtf none of this applies to you. But hey, come to the dark side, go install WSL2 and you can follow along. We’ll wait. Impatiently.
If you’re lazy like me (all sysadmins are!) then click here for the umount cheat sheet.
Unmount a filesystem
sudo umount /mnt/usb
That’s it. The filesystem at /mnt/usb is detached. Any buffered writes are flushed to disk. It’s now safe to remove the physical device.
You can also specify the device instead of the mount point:
sudo umount /dev/sdb1
Same result. Use whichever you remember.
“Target is busy”
sudo umount /mnt/usb
umount: /mnt/usb: target is busy
Something is using the filesystem. A shell has cd’d into it. A process has a file open. A background job is writing to it. umount refuses to detach a filesystem that’s in use because doing so would corrupt data.
Find what’s using it
lsof +f -- /mnt/usb
Lists every process with an open file on that mount point. Find the offender, close it, and try again.
fuser -vm /mnt/usb
Similar but more concise — shows PIDs, users, and how each process is accessing the mount.
The nuclear option
sudo umount -l /mnt/usb
-l is “lazy unmount.” Detaches the filesystem from the directory tree immediately but only actually unmounts it when all references are closed. The mount point disappears, new processes can’t access it, but existing processes finish their work. This is the polite nuclear option.
sudo umount -f /mnt/nfs
-f is “force unmount.” Mainly useful for stuck NFS mounts where the server has gone away and every file operation hangs. Doesn’t work well for local filesystems — use -l instead.
Unmount everything from fstab
sudo umount -a
Unmounts everything that was mounted via fstab (except the root filesystem). You’ll almost never do this manually — it’s part of the shutdown process. But it exists.
Flush writes without unmounting
sync
Forces all buffered writes to disk without unmounting. Useful when you want to make sure data is physically written but you’re not done with the filesystem yet. Run this before unplugging a USB drive if you’re too lazy to unmount. It’s not as safe as a proper unmount, but it’s better than nothing.
Safely remove a USB drive (the full process)
sync # flush any buffered writes
sudo umount /mnt/usb # detach the filesystem
sudo eject /dev/sdb # (optional) eject the device
eject spins down the drive and signals it for safe removal. Optional for USB drives (unmount is usually sufficient), but satisfying.
The flags that actually matter
| Flag | What it does |
|---|---|
-l |
Lazy unmount — detach now, clean up when references close. |
-f |
Force unmount — for stuck NFS mounts. |
-a |
Unmount all (except root). |
-R |
Recursive — unmount a mount point and all mounts beneath it. |
“But I just—”
Of course.
“I just pull out the USB drive.” And the kernel writes angry messages to syslog, the filesystem might need repair next time you plug it in, and if data was being written you’ve lost it. umount flushes buffers and ensures consistency. It takes two seconds. Your data is worth two seconds.
“Windows lets me just eject from the taskbar.” That taskbar eject does the same thing as umount — it flushes writes and detaches the filesystem. You’re just clicking a button instead of typing a command. And when the eject fails because something is “still using the device,” you get a vague error with no way to find out what. At least lsof tells you exactly what’s holding it.
“I’ve never had data corruption from not unmounting.” That you know of. Write buffering means data can sit in memory for seconds before being written to disk. Silent corruption is silent. You don’t see it until you open the file on another machine and it’s truncated. Unmount. Every time.
umount cheat sheet
You made it. Or you skipped straight here. Either way, no judgment. Copy and paste these. Pin them. Tattoo them on your forearm. Whatever works.
| What you’re doing | Command |
|---|---|
| Unmount a filesystem | sudo umount /mnt/point |
| Unmount by device | sudo umount /dev/sdb1 |
| Find what’s using a mount | lsof +f -- /mnt/point |
| Find PIDs using a mount | fuser -vm /mnt/point |
| Lazy unmount (detach immediately) | sudo umount -l /mnt/point |
| Force unmount (stuck NFS) | sudo umount -f /mnt/nfs |
| Flush writes to disk | sync |
| Safe USB removal | sync && sudo umount /mnt/usb |
The one rule: Always
umountbefore removing a drive. Always. The two seconds it takes are cheaper than the data you’ll lose when you don’t.