Bash script: effectively check if a filesystem is mounted
Whenever you want to check if a file system is mounted and perform some action in you script based on this, the simplest and most accurate way to do it in Linux is to check /proc/mounts:
if grep -qs ‘/mnt/sda2′ /proc/mounts; then
echo “fs mounted”
else
echo “fs not mounted”
fi
This entry was posted
on Tuesday, August 18th, 2009 at 10:39 pm and is filed under Tips and Tricks.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.