How To Unmount a Drive in Linux in 4 Easy Steps 

unmount a drive in linux

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

Unmounting a drive in Linux is one of the most important tasks when you safely want to remove external storage devices, disconnect network drives, or perform filesystem maintenance. By using the right unmounting methods, you avoid the risk of data loss, file corruption, and potential system errors. 

Linux offers a few simple commands that allow you to unmount a drive in Linux with little to no errors. In this guide, we will walk through a few easy steps to check, unmount, and troubleshoot drives in Linux. 

When and Why You Should Unmount a Drive in Linux

To unmount a drive in Linux, make sure that all the pending read and write operations are completed before you disconnect the device. This is mainly crucial because removing a device without unmounting it first can lead to complications, such as: 

  • Data loss – unsaved data might get lost in translation. 
  • File Corruption – the drive might repair itself before reuse. 
  • System errors – Linux might get confused and think that the drive is still in use, which can cause processing issues. 

Here is when it is absolutely essential to unmount a drive in Linux

  • Disconnecting a USB drive or any other external hard disk. 
  • Before formatting or repartitioning a disk 
  • Removing network shares 
  • Preparing the drive for a safe physical removal or transport. 

Checking Mounted Drives in Linux

Before you unmount drive in Linux, you need to first make sure that you identify the drives that are actually mounted. You can do so by running the following commands: 

  1. To display all the block devices and their mount points, run lsblk.
  2. To display all the mounted filesystems with a disk usage in a human-readable format, run df -h.
  3. If you want a list of all the mounted files and their respective mount points, run mount | grep /dev/
  4. To display the detailed mount information directly from the filesystem, run cat /proc/mounts. 

Related Article: Oracle Linux Explained: A Complete Guide For 2025

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

How to Unmount a Drive in Linux

To unmount drive in Linux, users usually use the unmount command. This command requires you to either input the mount point or the device name of the drive. You must also ensure that no processes are actively running on the said device, else the operation might fail. 

Using the umount Command

The basic syntax is:

sudo umount [mount_point_or_device]

  • mount_point_or_device — The location where the drive is mounted or its device path.
  • Always use sudo if you get permission errors.

Examples:

  1. sudo umount /mnt/usb
  2. sudo umount /dev/sdb1

Using the Drive’s Mount Point

If you already know where the drive is mounted, then you can unmount it by using the specific mount point: 

sudo umount /media/username/USB

Using the Drive’s Device Name

You can also unmount drive in Linux by using the device’s name (e.g., /dev/sdb1):

sudo umount /dev/sdb1

To find the device name, run: lsblk

Look for the device that matches your drive’s size and mount point.

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

Forcibly Unmounting a Drive in Linux

Sometimes, you might get an error message saying the device is currently busy when you try to unmount it. If this happens, most probably some or the other processes are using the said drive. In such cases, you can forcibly unmount the drive by running: 

sudo umount -f /mount/point

If this also fails, you can also employ the lazy unmount option, this would detach the filesystem immediately and clean up the processes that were stopping the unmounting. 

sudo umount -l /mount/point

Unmounting Network Drives

For network-mounted drives like the NFS or SMB/CIFS, the unmounting process is pretty similar, you can run: 

sudo umount /mnt/network_share

However, if the internet connection is unstable or lost, you can also force the operation: 

sudo umount -f /mnt/network_share

To avoid unmounting issues, make sure that no applications are accessing files from the network share before unmounting. 

Common Errors When Unmounting and How to Fix Them

Error MessageCauseSolution
umount: target is busyFiles or processes still using the driveUse lsof /mount/point or fuser -m /mount/point to identify processes, then close them or use umount -l
umount: not mountedThe drive is already unmounted or mount point is incorrectCheck with mount or lsblk for correct mount point
permission deniedUser lacks required privilegesUse sudo umount …
wrong fs type, bad option, bad superblockFilesystem issues or wrong unmount syntaxCheck filesystem type with lsblk -f, and ensure correct syntax

Best Practices for Unmounting Drives in Linux

Here are some best practices to follow while unmounting drives in Linux to avoid data loss and other complications: 

  • Always close all files and applications that are running on the drive before unmounting. 
  • Use lsblk or df -h to confirm if you are using the respective mount points or device names. 
  • Avoid using force unmounts until it is absolutely necessary and there is no other option. 
  • For USB drives, unmount the drive before physically removing them to prevent data loss or corruption. 
  • Regularly check the filesystems health report using the fsck command to avoid unmount issues.

Conclusion

Unmounting the drives in Linux is a simple everyday task that ensures data safety and integrity. So no matter what process you are using, knowing the right commands will help you avoid mistakes. Keep this cheat sheet handy for safe mounting! 

FAQs

Is unmounting the same as ejecting a drive?

Unmounting makes the file system safe for removal, but ejecting (like for a CD/DVD) physically releases the media from the drive.

How do I unmount a network drive in Linux?

Use umount /mount/point for NFS or Samba shares. Make sure no processes are accessing the share before unmounting.

Can I remount a drive after unmounting it?

Yes, use the mount command with the device path and mount point to remount.

Marium Fahim
Hi! I am Marium, and I am a full-time content marketer fueled by an iced coffee. I mainly write about tech, and I absolutely love doing opinion-based pieces. Hit me up at [email protected].
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!