Fix Umount Target is Busy Error in Linux

Fix “Umount Target is Busy” Error in Linux

While transferring data in any computer, if you unmount a USB flash driver/Data storage while it is still busy on it, you face the error ”device is currently in use”

While unmounting a device/portion on Linux, the same error occurs after running the umount command.

Umount Target is Busy Error in Linux, simply saying that your device is still in use.

The Linux kernel prevents you from unmounting the device while it is being accessed to prevent data loss.

To fix the ”Unmount Target is Busy” error, any of the below solutions are used commonly:

  • Find and Kill Active Processes.
  • Unmount Forcefully.
  • Find and Kill Processes Accessing the File.
  • Lazy Unmount.

After buying Linux VPS, you can access all the mounted filesystems.

If the accessed filesystems would not unmount, the ‘’device is busy’’ error does not let you continue.

Tutorial Fix ”Umount Target is Busy” Error

Generally, the cause of the umount device is busy error is an active process in your Linux system.

When you have to unmount your drive, you need to find a solution to do this without data loss.

Note: You are highly recommended to not unmount your device forcefully since it endangers your data or disrupts some running processes

Let’s find the best solutions to fix the umount target is busy error according to your system preferences:

Technique 1. Find and Kill Active Processes

Since the reason behind the ”umount target is busy” error is an active process, you must find and kill it.

The lsof command views a list of open files to let you know what processes are associated with them.

Run the following command to find the process id (PID) first and then kill it.

sudo lsof /Path/to/target

The above command lists all the processes using the mount point and does fix umount target is busy error.

When the PID is displayed, it is time to terminate all running processes.

sudo kill -9 [PID]

For example, if the output is saying that a process with PID 4255 is using the device, you need to run the command below to kill that process.

kill -9 4255

You might find more than one process accessing a file, make sure that you have terminated all of them.

In this way, all the processes that are attached to the device would be stopped, and you will be able to unmount the device.

Technique 2. Unmount Forcefully

While unmounting an NFS (Network File System), you might face the discussed error in this article.

In this way, you can use the umount force as a solution to detach your busy device.

Since this method causes data loss, choose it when you have no valuable and sensitive data.

Run the command below to fix the Linux force umount target is busy error and unmount the device forcefully:

sudo umount -f /Path/to/target

Technique 3. Find and Kill Processes Accessing the File

The lsof command displays all open files on the mount point, but the fuser command shows all the processes accessing the mount point.

Since the Open (possibly deleted) socket is one of the reasons for the ”target is busy” error, the fuser command enables you to find the processes that are accessing sockets or files on filesystems.

The -m option lists all the processes accessing the files. Also, you can add -v option for verbose.

Run the command below to use this method and fix umount: target is busy error.

fuser -mv /Path/to/target

Once the processes that are using the file on the mounted filesystem are displayed, use the kill command to stop them all.

If you add -k option, processes will be killed at once. To achieve this, run:

fuser -kmv /Path/to/target

Technique 4. Lazy Unmount

To fix umount target is busy error, a methodical way is the Lazy unmount. It unmounts the mount point from the Linux filesystem.

To remove all the processes attached to the device (that are not in use) slowly, you can use this solution.

Since the Lazy unmount removes all references to the detached file system, it will detach the file system when there is no more process accessing the unmounted file system.

So, if the last suggested method is your choice, type:

sudo umount -l /Path/to/target

In this way, all ideal processes will be automatically removed and the device will be unmounted.

According to your used case, all the recent solutions can be chosen to fix umount: /mnt: target is busy error.

How do I use umount command in Linux?

The basic syntax of the unmount command in Linux is:

umount [options] <mount_point>

In which the path where the file system or device is presently mounted should be substituted for <mount_point>.

For example, to unmount a specific partition, you need to run:

sudo umount /dev/sdb13

Notes to use unmount command:

  • Indicate the drive name and mount point location that you want to unmount.
  • Use lsblk to verify that the drive is unmounted. Consider that the mount points of identified devices are listed in the last column of the lsblk output.
  • If no mount points are listed, the device is unmounted.

What if none of the methods works?

I guess you are using ClearCase.

If yes, you are recommended to check /Vobs/Myvob since it might be the current working directory on a client host when unmounting.

If the current directory sends target busy error, you can make sure that it is the current directory.

To solve this failure, you must turn ClearCase off since when unmounting, it should not be the working directory on a host client.

How to fix the error unmounting /dev/sda2 target is busy?

When you try to unmount a device or partition on Linux when it’s still being used by another process, you get the error message “umount: target is busy.”

Try the below solutions to fix the error:

  • Kill the Process.
  • Lazy Unmount.
  • Force Unmount.

Why is Target busy in Linux?

It indicates that the target device is still being used.

Any process that has sufficient permissions may be using the drive you wish to unmount, but the kernel won’t let you protect your data.

How do I unmount a busy partition in Linux?

Once you identify the busy partition (Using the mount command), you need to check for active processes.

To view all the current processes using the partition, type:

sudo lsof /path/to/partition

Keep in mind to replace /path/to/partition with the actual mount point of your partition.

To terminate all the listed processes, run:

sudo kill -9 <PID>

Do not forget to replace <PID> with the actual process ID.

Then, unmount the partition again by running:

sudo umount /path/to/partition

What is the command to unmount forcefully in Linux?

When you have no valuable data on your system, you can use the below command (-f option) to unmount forcefully:

sudo umount -f /Path/to/target

Note: The umount command may give an error in some situations where a file system is in operation. You can use the -l (lazy) option to force unmount.

How do I force unmount a filesystem in Linux?

  • Using the -l ( –lazy) option (It unmounts a busy file as soon as it is no longer busy)
  • Using the -f ( –force) option (Not recommended since It could harm the file system’s data)

How do I unmount a driver in Linux?

The unmount command is used to unmount a drive in Linux.

  • If you know the drive is mounted in which directory, use the command below (as an example) to unmount by mount point:
sudo umount /path/to/mountpoint
  • If you know the specific drive name, run (as an example):
sudo umount /dev/sdx1

Replace /dev/sdx1 with the actual device name.

What is the umount command in Ubuntu?

To detach the mounted file system on Ubuntu safely, the unmount command is used.

Does unmount mean delete?

No. Unmounting a file system does not mean deleting since unmounting an SD card doesn’t erase data.

The card can be securely removed after unmounting it, which only disconnects/detaches it from the device.

So, on the storage device, the data included in the file system is unaltered.

FAQ

Users who are working with Network File Systems usually prefer to use this method. So, it will not give ideal results on local file systems. Also, it is helpful when the error is caused by an unreachable resource such as a network resource.

The Lazy unmount is less harmful since it does not kill the process unexpectedly.

Conclusion

4 different solutions are fully explained to fix error unmounting target is busy in Linux:

  • Detaching busy device by finding and killing the processes (lsof command)
  • Umount force.
  • Using fuser command.
  • lazy mount.

Keep in mind to run both lsof and fuser commands as root to have unlimited outputs to fix failed to unmount device or resource busy error.

Based on your system and situation, choose the best way to fix umount: /: target is busy error.

Leave a Reply

Your email address will not be published. Required fields are marked.