Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, Can anyone teach me how to check whether NFS is mounted in a script? I am trying do a backup using NFS to another computer. In the script, I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2004
    Posts
    9

    HELP: Script to test NFS mount


    Hi,

    Can anyone teach me how to check whether NFS is mounted in a script?

    I am trying do a backup using NFS to another computer. In the script, I will be using rsync. However I would like to make sure that the NFS is mounted successful before proceeding to rsync.

    Any help will be appreciated.

    Cheers,

    Fruits

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    ***Moved to Linux Networking***
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Just Joined!
    Join Date
    Jun 2004
    Location
    London, UK
    Posts
    53
    Hi,

    Either do this by checking for a known file on the NFS-mount (perhaps a mount-check flag file you have created).
    Code:
    if [ -f /nfs/mount1/.tagfile ]; then
     echo "Yep, mounted!"
    else
     echo "No, not mounted!"
    fi
    Another option is to check the /proc/mount 'file' for the desired mount.
    Code:
    if grep "^server:/nfs/mount1" /proc/mounts >/dev/null; then
     echo "YEAH!"
    else
     echo "NO"
    fi
    Good luck with your backup script, rsync rocks

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Sep 2004
    Posts
    9
    Thanks !!!

    Use the first method. work fine for me, added a mail to my email address if inform me of backup server error.

    Appreciate it. you make my day

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •