Tuesday 29 November 2011

Check if a file system is local or remote

I want to check whether there is any nfs file system mounted on my solaris or linux machine:
Here is the code snippet to do that :
 # Take the FS entry (static) snapshot

                        fs_string=`df -k $fs | grep -v "Filesystem" | head -1`

                        # Next is true if $fs_string contains ":" as the separator for the "node" field

                        if [[ `echo $fs_string | cut -f1 -d":"` = `echo $fs_string` ]]
                        then
                                # No ":" in the df-returned string: this is a local FS
                                fs_node=""
                        else
                                # The df-returned string contains a ":" (i.e.) a node name: this is a remote FS
                                fs_node=`df -k $fs | grep -v "Filesystem" | head -1 | cut -f1 -d":"`
                        fi



No comments:

Post a Comment

Tweets by @sriramperumalla