It is not difficult to fix umount target is busy error. But what it means? While transferring data in any computer, if you unmount a USB flash driver/Data storage from your system while it is still busy on it, you face the error ”device is currently in use” and asks you to close programs first. While unmounting a device/portion on Linux, the same error occurs after running the umount command. Fix umount target is busy error in Linux is what you will learn in this article. It is not a complicated error and even helps to not lose your data but unless you solve it you cannot unmount your device.
After buying Linux VPS, you can access all the mounted filesystems. But if the accessed filesystems would not unmount, the ‘’device is busy’’ error does not let you continue. You are highly recommended to not unmount your device forcefully since it endangers your data or disrupts some running processes. So, join us with this guide to review all four methods you can use to pass this issue.
What is the ”Umount Target is Busy” error and why occur?
This error is simply saying that your device is still in use. In other words, a user or a process has an open file on that file system. Any process with sufficient permissions can access a device’s filesystem after you mount it in your system. An active process is actively accessing a file or directory on the device when the error “target is busy” appears. The Linux kernel will therefore prevent you from unmounting the device while it is being accessed in order to prevent data loss.
However, if you still need to unmount the target device, let’s learn how to fix umount target is busy error. Stay with us to review different methods to troubleshoot this error and in the end, you can decide which one is easier for you to use.
Tutorial Fix ”Umount Target is Busy” Error
Generally, the cause of umount target 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. According to different situations, one of the following methods would be helpful. In this part, you will learn all the best solutions to fix umount target is busy error.
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 force unmount 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 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 which 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 target is busy error.
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.
Which method is recommended?
The first-mentioned solution, ''using lsof command to find and kill active processes'' , is recommended as the best way to unmount the target.
When to use the ''force unmount'' method?
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.
Which technique is less harmful please?
The Lazy unmount is less harmful since it does not kill the process unexpectedly.
In this article, you learned how to Fix Umount Target is Busy Error in Linux. Now, you know the reason of occurring this error. Four different techniques such as detaching busy device by finding and killing the processes (lsof command), force unmount, using fuser command, and finally, lazy mount were explained. Keep in mind to run both lsof and fuser commands as root to have unlimited outputs. Using any of these methods helps you to troubleshoot this error. Based on your system and situation choose the best way to fix umount target is busy error.
Please do not hesitate to contact us if you encounter any problems. Our technical support team will try their best to solve your problems.