Monday, April 25, 2016

Remount multiple NFS mount points on Client in one go

                                     Sometimes we may have number of mount points available on NFS clients and after making changes for any one of parameters, we have to remount all partitions. Doing umount and mount on multiple partitions will really be hectic job and there may be chances of human errors.
    We can do this using single command to achieve the same. Sharing some other commands as well, before moving to exact one :).

  • Get the list of all NFS mount points available on System:
                     Before moving ahead with changes, lets see how many partitions are their on system. Below command will do trick and give you all the nfs mount points without any header and headers.
    • Without headers -
                     #df -PF nfs | awk '{if(NR>1)print}'     # This command will suppress header line 

    • With headers-
                   #df -PF nfs 

  • Here goes the actual thing, where we need to mount and remount multiple nfs partitions after making changes to parameters.
                    #for M in $(mount | awk '/type nfs / {print $3;}'); do echo $M; sudo umount $M && sudo mount $M && echo "ok :)"; done

[Note: Execute at your own risk after doing testing on test environments ;) ]