0
0
Linux-cliHow-ToBeginner · 3 min read

How to Unmount a Drive in Linux: Simple Commands

To unmount a drive in Linux, use the umount command followed by the drive's mount point or device name, like umount /mnt/usb. This safely disconnects the drive so you can remove it without data loss.
📐

Syntax

The basic syntax to unmount a drive in Linux is:

  • umount [options] <mount_point_or_device>

Here, umount is the command, and you specify either the mount point (folder where the drive is attached) or the device name (like /dev/sdb1).

Common options include:

  • -l: Lazy unmount, detaches immediately but cleans up later.
  • -f: Force unmount (use with caution).
bash
umount /mnt/usb
umount /dev/sdb1
💻

Example

This example shows how to unmount a USB drive mounted at /mnt/usb. First, check the mount point, then unmount it safely.

bash
mount | grep /mnt/usb
sudo umount /mnt/usb
mount | grep /mnt/usb
Output
/dev/sdb1 on /mnt/usb type vfat (rw,nosuid,nodev,uhelper=udisks2)
⚠️

Common Pitfalls

Common mistakes when unmounting drives include:

  • Trying to unmount a drive that is still in use by a program or terminal, causing an error.
  • Using the wrong device name or mount point.
  • Not having sufficient permissions (usually requires sudo).

To fix 'device is busy' errors, close programs using the drive or use lsof to find processes holding it.

bash
sudo umount /mnt/usb
# If error 'device is busy' occurs:
lsof /mnt/usb
# Close listed processes, then try again
sudo umount /mnt/usb
📊

Quick Reference

CommandDescription
umount /mnt/usbUnmount drive at mount point /mnt/usb
umount /dev/sdb1Unmount drive by device name
umount -l /mnt/usbLazy unmount drive
umount -f /mnt/usbForce unmount drive (use carefully)
lsof /mnt/usbList processes using the mount point

Key Takeaways

Use the umount command with the mount point or device name to unmount drives.
Ensure no programs are using the drive before unmounting to avoid errors.
Use sudo if you get permission denied errors.
Use lsof to find processes blocking unmounting.
Lazy (-l) and force (-f) options exist but use them carefully.