This works really well for mounted file systems as well...
If you are trying to unmount a partition and you get the message that it can't unmount, you can use
fuser to figure out (then kill) all processes that have items opened on that partition.
Here is an example for a partiton mounted at
/mnt/server1/archive ... which is a Windows file server I have mounted via smbfs...
I need to unmount the partition so I can reboot the file server ... so I issue the command:
umount /mnt/server1/archiveand the results are:
umount: /mnt/server1/archive: device is busyyikes ! - I have something using that share ... and if I don't figure out what it is, I can corrupt the open resource by rebooting....so we can use the
fuser command with the
-m switch to figure out the processes are using that mount.... the command would be:
QUOTE
fuser -m /mnt/server1/archive
The result is:
/mnt/server1/archive: 9170c9170 is the process ID ... and the
c means that something is using that location as it's
current directory (see
man fuser for more on what c, e, f, r, and m mean after a PID while using fuser).
The command:
QUOTE
ps -ef | grep 9170
returns this information:
root 9170 9168 0 09:45 pts/1 00:00:00 bashwhich means that the user
root has the program
bash open ... and the
c from above means that the program
bash's current directory is
/mnt/server1/archive. Sure enough, I had a bash terminal window open, and it was setting with /mnt/server1/archive as it's current directory.
After I change the directory to /root in that terminal, the command:
umount /mnt/server1/archiveworks great....