How to fix the error “umount target is busy”

Attaching and removing storage devices from your system is a crucial part of data transfer in any computer. In Linux, the mount and unmount keywords are provided, which will add or remove certain storage components or even file systems. These commands can help to switch between various storage devices. For example, you can unmount a certain storage device and mount another one to use it. Oftentimes, while attempting to unmount a device, the “umount target is busy” problem can be invoked.

This article will guide you on why this problem arises and how it can be dealt with easily.

How to Resolve the “umount target is busy” Issue?

The reasons behind this problem can relate to the working of this command. This section will not only elaborate on why this error occurs but will also help you resolve it.

Reason: The Device is in Use

There are many different processes that have enough permissions to be able to access any storage device at any time. Due to this, the device is accessed the majority of the time. If a device is being accessed and the user tries to unmount the device, it will prompt the error mentioned above. This happens because if the device is unmounted during its use, there is a chance of some data being lost. To prevent that from happening, the error will be invoked, and the device will not be unmounted.

Let’s have a look at how this issue can be fixed.

Solution 1: Unmount Forcefully

The first solution is to try to unmount the device forcefully. It needs to be noted that this method should only be applied when there is no sensitive data on the device because this process has a chance of causing data loss. To unmount the device forcefully, run the following command:

$ umount -f /device-path

Where “-f” is used to force the unmount, and the “device-path” is the directory path of the device.

Solution 2: Stop the Active Process

As discussed above, an active process may be causing the error “unmount target is busy”. We simply need to stop the active process occupying the device to fix it. Use the command below to access the process list of the device:

$ sudo lsof /device-path

Running this command will return all the processes surrounding that device.

The next step is to note down their process ID. The snippet below shows sample PIDs:

Note down the process-id and terminate the process using the command shown below:

$ sudo kill -9 [PID]

Using this command, you can terminate all the processes that are attached to the device. After this, the error will not occur, and you can successfully unmount the device.

Solution 3: Lazy Unmount

It is a combination of both the methods mentioned above and is effective among all. In lazy unmount, the system will forcefully unmount the device but in a methodical way. Using this way, the system will slowly remove all the processes attached to the device that is not in use. To achieve this, use the following command:

$ umount -l /device-path

The “l” represents the lazy unmount in the device.

Using any of these methods, the problem “umount target is busy” can be fixed easily.

Conclusion

The “umount target is busy” issue occurs due to the device being in use by various processes at the time of unmounting. The problem can be resolved in 3 ways. The first is to forcefully unmount the device, which risks the loss of data. The second way is to find and eliminate each process individually. The third way is to do a lazy unmount, which will automatically remove all ideal processes and then unmount the device. This article has provided a detailed guide on the reasons behind this error and has proposed a list of solutions as well.