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` ]]
                                # No ":" in the df-returned string: this is a local FS
                                # 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":"`

No comments:

Post a Comment

Tweets by @sriramperumalla