You may get a device is busy error when you try to unmount a partition in Linux using the umount command:
umount: /mnt/sda2: device is busy
(In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
This device is currently in use by a running program and you cannot unmount it.
Use the following command to try to find the process that is using your device:
$ lsof +D | grep /dev/sda2
Or with fuser:
$ fuser -vm /dev/sda2
You will get a list of the PIDs of the processes that are currently using this disk. Kill these processes:
$ pkill target_process
Or by PID:
$ kill PID
Try to unmount the device again:
$ sudo umount /dev/sda2
If this does not help, you can force unmount such a partition or device (which may cause data loss in open files). There are two options for unmounting a device:
- Lazy unmount: in this mode, Linux will hide the mount point from the system and wait for all of the file descriptors on the specified device to be closed.
# umount -l /dev/sda2
- Force: forced unmount (often the only way to unmount an NFS drive which is no longer accessible).
# umount -f /dev/sda2