Unmounting a drive in Linux is essential to safely remove storage devices and prevent data corruption. Linux doesn’t automatically unmount drives when you disconnect them, so knowing how to do this manually through the terminal is crucial, especially when working on servers or remote systems without a graphical interface.
Unmounting a Drive Using the umount Command
The most straightforward and effective method to unmount a drive in Linux is by using the umount command. This command detaches the specified drive or partition from the Linux file system, ensuring no data loss or corruption occurs.
lsblk command to list all mounted drives and their mount points:lsblk
This command shows a list of block devices and their mount points. For instance, a USB drive could appear as /dev/sdb1 mounted at /media/usb.
umount command to unmount the drive:sudo umount /media/usb
Alternatively, you can specify the device directly:
sudo umount /dev/sdb1
After executing this command, the drive is safely unmounted, and you can remove it from your system without risking data loss.
Join readers who trust AllThings.How
Add us as a preferred source on Google so our practical guides show up first next time you search.
Add to Google Preferences →Force Unmounting a Busy Drive
Sometimes, you might encounter an error stating “target is busy” when you attempt to unmount a drive. This usually happens when files or processes are still actively using the drive.
sudo lsof | grep /media/usb
This command lists all processes accessing files on the drive mounted at /media/usb.
sudo umount -f /media/usb
Lazy Unmounting
Another safe alternative to force unmounting is lazy unmounting. This method waits until the drive is no longer in use before fully unmounting it.
sudo umount -l /media/usb
This command detaches the drive from the file system immediately, but the actual unmount occurs once all processes have finished using the drive. This method is safer than force unmounting and is recommended if you’re unsure whether files are currently being accessed.
Using the Disk Utility (GUI Method)
If you’re working on a Linux desktop environment and prefer a graphical method, you can use the built-in Disk Utility.
With these methods, you can effectively and safely unmount drives in Linux, preventing data loss and ensuring your devices remain in good condition. Always remember to unmount drives before physically removing them from your system.






