How to test is a drive is mounted in a shell script?
I am writing a shell script and have been searching for a reliable method of testing whether or not a drive is mounted.
Any ideas? |
hi,
Code:
cat /etc/mtab | grep /dev/hda6 >/dev/null cheers, --cyberjun |
Quote:
Code:
#!/bin/bash Code:
./chkmount hda3 |
I think I'd rather check the mount command to make sure it hasn't been unmounted somewhere along the line.
Code:
#!/bin/bash |
You guys are great:) Thanks a lot for teaching me how to do that!
|
Quote:
|
Either way is fine for me, I thing it's a question of what the script is going to be used for. In my situation I am testing 4 static drives so it doesn't need to take any arguments, but since I am running the same test 4 times for different drives it would probably be better to turn it into a function which would take an argument.
|
reverse check?
What about writing this shell script to check the mount point rather than the mount device? I imagine it would only take a small change, but I am not certain how to go about doing it.
Theoretical model: if /mount/media == has_something_mounted { echo "something is mounted"; else; echo "nothing is mounted"; }; (my plan is to use this for a script to mount and quickly swap iso images) |
All times are GMT -5. The time now is 06:07 PM. |