Wednesday, November 23, 2011

How to unmount when the device is busy

Sometimes you end up with an error while running umount.

# umount /mnt/mydisk
umount: /mnt/mydisk: device is busy
umount: /mnt/mydisk: device is busy

You have to be out out /mnt/mydisk directory when you try to unmount. If that doesn't do the trick then you have to find out what process is using the /mnt/mydisk mount point. Here is how to:

Lets suppose the /mnt/mydisk is mounted from /dev/sdb2.

# fuser -m /dev/sdb2

You will get a number which is the process number you have to stop or kill.

# ps -ef | grep process_number

You can kill this process by using

# kill -9 process_number

but if you can stop the application which uses that process then the better.

Anyway, you can do the unmount command after that.