Skip to main content

Disk Management

umount Command in Linux

Learn some practical examples of using umount command to unmount the mounted disk partitions in Linux command line.

The umount command is used in Unix-like operating systems to unmount a mounted filesystem from the file hierarchy.

Even if you have a physically mounted drive, unmounting is recommended to eject the drive to save yourself from accidental data losses.

In other words, think of it as the command line equivalent of 'safely remove device'.

To get a better grasp of how you can unmount your drive using the umount command, I've divided this tutorial into the following parts:

  • The syntax and options of the umount command
  • Practical examples of the umount command

Let's start with the first one.

How to use umount command in Linux

To use any command to its maximum potential, it is recommended to learn the syntax and that is why I'm starting this tutorial with the syntax:

umount [options] [device|mount_point]


  • [options]: using available options (also known as flags), you can modify the default behaviour of the umount command. For example, you can use the -f flag to force unmount the drive.
  • [device|mount_point]: here's where you specify the device or the mount point of the targeted filesystem that you want to unmount.

Now, let's take a look at the common options for the umount command:

Option Description
-a Unmount all filesystems listed in /etc/fstab, except those marked as requiring separate unmount.
-f Force unmount, even if the device is busy.
-l Perform a lazy unmount, detaching the filesystem now and cleaning up later.
-n Unmount without writing to /etc/mtab.
-r If unmounting fails, try to remount the filesystem as read-only.
-t [fs-type] Specify the filesystem type to unmount.
-v Run in verbose mode, displaying detailed information.
You need to be root or use sudo to use the umount command.

Practical examples of the umount command

In this section, I will walk you through some practical examples of the umount command so you can have a better idea of how it can be used in practical scenarios.

1. Unmount an external drive or filesystem

If you want to unmount the mounted USB drive or a filesystem then it can be done by executing the umount command in the following manner:

sudo umount <device|mount_point>

For example, if I want to unmount the sda1 drive mounted at /media/kabir/Ventoy, then I can use either of the two ways:

To unmount the drive using the drive name

sudo umount /dev/sda1

Or you can specify the mount point:

sudo umount /media/kabir/Ventoy

There is no output for these commands unless there is an error like the one in the next section.

2. Unmount busy targets

Proceed with caution. Force unmounting may cause data loss or corrupt open files. And never execute the umount commands when you are inside the mounted path.

When you try unmounting the drive which is being utilised by another process, it will give you an error saying "target is busy":

target is busy error while unmounting drive

There are times when you have to unmount the drive immediately irrespective of whether it is busy or not and in that case, you can force unmount the drive using the -f flag as shown here:

sudo umount -f <device|mount_point>

In my case, the busy drive was mounted at /media/kabir/Ventoy, so I'll use the following command to force unmount it:

sudo umount -f /media/kabir/Ventoy
Force unmount drive using the umount command in Linux

3. Perform lazy unmount

You usually have two options for unmounting the drive. One is to directly unmount, which will throw an error if the drive is busy. The second is to force unmount, which may corrupt the drive if done during the ongoing process.

The sweet spot is to use the lazy unmount. When you use it, it checks whether the drive is busy. If it is, it will unmount the drive once the process is completed.

To perform lazy unmount, use the -l flag as shown here:

unmount -l <device|mount_point>

For example, if I want to lazy unmount the /dev/sda1 drive, then I'll be using the following command:

sudo umount -l /dev/sda1

Wrapping Up...

In this tutorial, I want through how you can unmount drive using the umount command in Linux including lazy and force unmounting techniques.

There is not much to it but you can always refer to its man page for more information.

I hope you will find this guide helpful and if you have any queries, feel free to leave us a comment.

Kabir Thapar