Check if device is mounted in a bash script
Writing a bash script and I need to check if a known HD partition is mounted or not. I do not think /etc/mtab is the place to check. Would /proc/mounts always work? To make it simple like this :
cat /proc/mounts | grep /dev/sdb2 Is there a better way? Thanks inadvance. |
You could grep through the output of "mount", /etc/mtab, or /proc/mounts. Any of those would give you the desired result rather easily.
|
Quote:
|
Why don't you try performing a simple file operation on the desired mountpoint? If it fails you'll get an error.
|
check df output string is easier.
|
This is a helper script I wrote for some backup software, it lists the device node,mount point and volume label I'm sure you can adapt it to your needs:
Code:
#!/bin/bash Code:
listdevs youradminpassword |
All times are GMT -5. The time now is 05:39 PM. |