This question has been in my mind for a while and I can't figure out the fastest and most efficient way to do it. So let's say you have a dir call /data. The box is public, users can ssh into the box and go into the dir /data no problem. /data is also a nfs share.
So let's say you want to unmount /data
you know for a fact a user either by ssh or nfs is accessing /data.
umount /data umount: /data: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
How can you locate the ip of the machine and the user who is accessing it?
I tried the following but it doesn't' seem to give me any hints on who is accessing what.
[root@AAA]# lsof | grep "nfs" rpc.idmap 975 root mem REG 9,127 11408 67213331 /usr/lib64/libnfsidmap/nsswitch.so rpc.idmap 975 root mem REG 9,127 32448 202486038 /usr/lib64/libnfsidmap.so.0.3.0 rpc.idmap 975 root 7u REG 0,3 0 4026532353 /proc/975/net/rpc/nfs4.nametoid/channel rpc.idmap 975 root 8u REG 0,3 0 4026532349 /proc/975/net/rpc/nfs4.idtoname/channel rpc.idmap 975 root 9r DIR 0,36 0 103 /var/lib/nfs/rpc_pipefs/nfs rpc.statd 1777 rpcuser cwd DIR 9,127 40 68141723 /var/lib/nfs/statd rpc.mount 1999 root cwd DIR 9,127 4096 201530540 /var/lib/nfs rpc.mount 1999 root 4u REG 0,3 0 4026532341 /proc/1726/net/rpc/nfsd.export/channel rpc.mount 1999 root 5u REG 0,3 0 4026532345 /proc/1726/net/rpc/nfsd.fh/channel rpc.mount 1999 root 12r REG 9,127 216 201530567 /var/lib/nfs/etab nfsd4 2091 root cwd DIR 9,127 4096 128 / nfsd4 2091 root rtd DIR 9,127 4096 128 / nfsd4 2091 root txt unknown /proc/2091/exe nfsd4_cal 2092 root cwd DIR 9,127 4096 128 / nfsd4_cal 2092 root rtd DIR 9,127 4096 128 / nfsd4_cal 2092 root txt unknown /proc/2092/exe nfsd 2212 root cwd DIR 9,127 4096 128 / nfsd 2212 root rtd DIR 9,127 4096 128 / nfsd 2212 root txt unknown /proc/2212/exe nfsd 2213 root cwd DIR 9,127 4096 128 / nfsd 2213 root rtd DIR 9,127 4096 128 / nfsd 2213 root txt unknown /proc/2213/exe nfsd 2215 root cwd DIR 9,127 4096 128 / nfsd 2215 root rtd DIR 9,127 4096 128 / nfsd 2215 root txt unknown /proc/2215/exe nfsd 2217 root cwd DIR 9,127 4096 128 / nfsd 2217 root rtd DIR 9,127 4096 128 / nfsd 2217 root txt unknown /proc/2217/exe nfsd 2219 root cwd DIR 9,127 4096 128 / nfsd 2219 root rtd DIR 9,127 4096 128 / nfsd 2219 root txt unknown /proc/2219/exe nfsd 2220 root cwd DIR 9,127 4096 128 / nfsd 2220 root rtd DIR 9,127 4096 128 / nfsd 2220 root txt unknown /proc/2220/exe nfsd 2221 root cwd DIR 9,127 4096 128 / nfsd 2221 root rtd DIR 9,127 4096 128 / nfsd 2221 root txt unknown /proc/2221/exe nfsd 2222 root cwd DIR 9,127 4096 128 / nfsd 2222 root rtd DIR 9,127 4096 128 / nfsd 2222 root txt unknown /proc/2222/exe [root@AAA]# lsof | grep "btrfs" btrfs-wor 10666 root cwd DIR 9,127 4096 128 / btrfs-wor 10666 root rtd DIR 9,127 4096 128 / btrfs-wor 10666 root txt unknown /proc/10666/exe btrfs-wor 10670 root cwd DIR 9,127 4096 128 / btrfs-wor 10670 root rtd DIR 9,127 4096 128 / btrfs-wor 10670 root txt unknown /proc/10670/exe btrfs-del 10671 root cwd DIR 9,127 4096 128 / btrfs-del 10671 root rtd DIR 9,127 4096 128 / btrfs-del 10671 root txt unknown /proc/10671/exe btrfs-flu 10672 root cwd DIR 9,127 4096 128 / btrfs-flu 10672 root rtd DIR 9,127 4096 128 / btrfs-flu 10672 root txt unknown /proc/10672/exe btrfs-cac 10673 root cwd DIR 9,127 4096 128 / btrfs-cac 10673 root rtd DIR 9,127 4096 128 / btrfs-cac 10673 root txt unknown /proc/10673/exe btrfs-sub 10674 root cwd DIR 9,127 4096 128 / btrfs-sub 10674 root rtd DIR 9,127 4096 128 / btrfs-sub 10674 root txt unknown /proc/10674/exe btrfs-fix 10675 root cwd DIR 9,127 4096 128 / btrfs-fix 10675 root rtd DIR 9,127 4096 128 / btrfs-fix 10675 root txt unknown /proc/10675/exe btrfs-end 10676 root cwd DIR 9,127 4096 128 / btrfs-end 10676 root rtd DIR 9,127 4096 128 / btrfs-end 10676 root txt unknown /proc/10676/exe btrfs-end 10677 root cwd DIR 9,127 4096 128 / btrfs-end 10677 root rtd DIR 9,127 4096 128 / btrfs-end 10677 root txt unknown /proc/10677/exe btrfs-end 10678 root cwd DIR 9,127 4096 128 / btrfs-end 10678 root rtd DIR 9,127 4096 128 / btrfs-end 10678 root txt unknown /proc/10678/exe btrfs-end 10679 root cwd DIR 9,127 4096 128 / btrfs-end 10679 root rtd DIR 9,127 4096 128 / btrfs-end 10679 root txt unknown /proc/10679/exe btrfs-end 10680 root cwd DIR 9,127 4096 128 / btrfs-end 10680 root rtd DIR 9,127 4096 128 / btrfs-end 10680 root txt unknown /proc/10680/exe btrfs-rmw 10681 root cwd DIR 9,127 4096 128 / btrfs-rmw 10681 root rtd DIR 9,127 4096 128 / btrfs-rmw 10681 root txt unknown /proc/10681/exe btrfs-end 10682 root cwd DIR 9,127 4096 128 / btrfs-end 10682 root rtd DIR 9,127 4096 128 / btrfs-end 10682 root txt unknown /proc/10682/exe btrfs-fre 10683 root cwd DIR 9,127 4096 128 / btrfs-fre 10683 root rtd DIR 9,127 4096 128 / btrfs-fre 10683 root txt unknown /proc/10683/exe btrfs-del 10684 root cwd DIR 9,127 4096 128 / btrfs-del 10684 root rtd DIR 9,127 4096 128 / btrfs-del 10684 root txt unknown /proc/10684/exe btrfs-rea 10685 root cwd DIR 9,127 4096 128 / btrfs-rea 10685 root rtd DIR 9,127 4096 128 / btrfs-rea 10685 root txt unknown /proc/10685/exe btrfs-qgr 10686 root cwd DIR 9,127 4096 128 / btrfs-qgr 10686 root rtd DIR 9,127 4096 128 / btrfs-qgr 10686 root txt unknown /proc/10686/exe btrfs-ext 10687 root cwd DIR 9,127 4096 128 / btrfs-ext 10687 root rtd DIR 9,127 4096 128 / btrfs-ext 10687 root txt unknown /proc/10687/exe btrfs-cle 10688 root cwd DIR 9,127 4096 128 / btrfs-cle 10688 root rtd DIR 9,127 4096 128 / btrfs-cle 10688 root txt unknown /proc/10688/exe btrfs-tra 10689 root cwd DIR 9,127 4096 128 / btrfs-tra 10689 root rtd DIR 9,127 4096 128 / btrfs-tra 10689 root txt unknown /proc/10689/exe [root@AAA]# lsof | grep "/data" [root@AAA]# fuser -c /data [root@AAA]#
[link] [comments]