Wednesday, April 16, 2014

stale nfs mount discovery and unmounting

who is a naughty nfs mount?
 #!/bin/bash  
 while read _ _ mount _; do   
  read -t1 < <(stat -t "$mount") || lsof -b 2>/dev/null|grep "$mount";   
     if [ $? -eq 1 ]; then  
         echo $mount stale. umounting  
         umount -f -l "$mount"  
     fi  
     if [ $? -eq 0 ]; then  
         echo $mount fine.  
     fi  
 done < <(mount -t nfs)  

No comments: