lsof Command to get PID

The lsof command is the fastest way to find out the command or PID of any tasks currently accessing the mounted drive (such as /dev/sdb2) or network file system at /media/nfs directory:

lsof +D /media/nfs

You can kill process with kill command and unmount /media/nfs. Or just do lazy (-l) and force (-f) unmount:

umount -l /media/nfs
umount -f /media/nfs
umount -fl /media/nfs

Advertisements