Monitor mount points

Rick Stevens rstevens at vitalstream.com
Tue Jan 24 21:42:46 UTC 2006


On Tue, 2006-01-24 at 16:28 -0500, Devon Harding wrote:
> Is there a way I could monitor mount points & automatically remount
> them (mount -a) if its ever disconnected?

Uhm, yeah.  I do it.  Cheap and dirty way:

--------------------- CUT HERE ---------------------------------------
#!/bin/bash
MNTLIST="/mountpoint1 /mountpoint2 ..." # Build list of dirs to check
for MNT in $MNTLIST; do                 # For each directory...
    RES=`mount | grep $MNT`             # Perform the check
    if [ $? -ne 0 ]; then               # Did we get a failure?
        mount $MNT                      # Yes, remount the volume
    fi
done
--------------------- CUT HERE ---------------------------------------

Save that as a shell script, say "/usr/local/bin/chkmnt.sh", chown it
as root:root and chmod it to 755.  Finally, add an entry to root's
crontab:

	* * * * * /usr/local/bin/chkmnt.sh >/dev/null 2>&1

which will run it once a minute.  You could add things such as touching
a file on each directory to verify the thing is writable and such.  It's
up to you.

----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
- ...Had this been an actual emergency, we would have fled in terror -
-                      and you'd be on your own, pal!                -
----------------------------------------------------------------------




More information about the fedora-list mailing list