Removing a USB drive from Linux without unmounting is like yanking a hard disk out of a running Windows machine. Best case, data in the write buffer is lost. Worst case, the filesystem corrupts and requires fsck on the next mount. Proper unmounting flushes all cached data to disk before the device is released.
How Mounting Works and Why It Needs to Be Undone
Linux does not work with devices directly by name. Any disk, partition, or network share is attached to the filesystem tree through a mount point — an ordinary directory. After that, /mnt/usb becomes the entry point into the device filesystem.
During unmounting: the kernel flushes buffered writes to the device, closes file descriptors, frees kernel data structures, and detaches the mount point. After this, physically removing the device is safe.
The Basic Command: umount
sudo umount /mnt/usb
Either the mount point or the device name works:
sudo umount /dev/sdb1
Check mounted disks first:
lsblk
mount | grep /dev/sdb
Error: target is busy
The most common problem:
umount: /mnt/usb: target is busy.
A process is holding an open file on the device, or its working directory is on it. Find the offender:
sudo fuser -mv /mnt/usb
sudo lsof /mnt/usb
fuser shows PIDs and access types. lsof gives full process name, user, file type, and path.
Kill all processes using the disk:
sudo fuser -km /mnt/usb
Use carefully — important background services may be among them.
Common causes: terminal open in a directory on the disk (cd ~ and retry), text editor holding a file open, backup job writing to the disk.
Force Unmounting: -f and -l
Force flag — mainly for network filesystems (NFS, CIFS) when the server is unreachable:
sudo umount -f /mnt/usb
Lazy unmount — detaches the mount point immediately, but keeps the device accessible to processes already holding files open. When the last descriptor closes, the device unmounts automatically:
sudo umount -l /mnt/usb
Lazy is safer than force for local disks: new processes cannot open files, existing ones finish cleanly.
Unmount All Disks at Once
sudo umount -a
Iterates through /etc/mtab and unmounts everything except filesystems marked noumount. System partitions (/, /proc, /sys) are protected.
Safely Eject USB via udisksctl
udisksctl unmount -b /dev/sdb1
udisksctl power-off -b /dev/sdb
power-off cuts USB power after unmounting. Used by GNOME and KDE file managers under the hood when clicking Eject.
Verify the Disk Is Unmounted
mount | grep sdb # empty = not mounted
lsblk # MOUNTPOINTS column will be empty
Quick Reference
| Task | Command |
|---|---|
| Unmount by mount point | sudo umount /mnt/usb |
| Unmount by device name | sudo umount /dev/sdb1 |
| Find processes using disk | sudo fuser -mv /mnt/usb |
| Detailed open file list | sudo lsof /mnt/usb |
| Kill all processes on disk | sudo fuser -km /mnt/usb |
| Force unmount | sudo umount -f /mnt/usb |
| Lazy unmount | sudo umount -l /mnt/usb |
| Unmount all | sudo umount -a |
| Safe USB eject | udisksctl unmount -b /dev/sdb1 && udisksctl power-off -b /dev/sdb |
| Check mounted disks | lsblk |