I have seen multiple questions on this but none that specifically related to mine. I am creating a shell script and i want to test certain drives to see if they are already mounted. I am looking to test if cdrive
is mounted. The code i have used to mount this is mount /dev/sda1 media/cdrive
I am looking to create a piece of code that will echo out to the terminal if the drive has already mounted. Any help is appreciated.
Asked
Active
Viewed 673 times
-1

Feng
- 1
- 1
- 2
1 Answers
0
If wanna check both that /dev/sda1
is mounted on /media/cdrive
:
grep -q '^/dev/sda1 /media/cdrive ' /proc/mounts && echo "mounted" || echo "not mounted"
If wanna check if something is mounted on /media/cdrive
:
grep -q ' /media/cdrive ' /proc/mounts && echo "mounted" || echo "not mounted"

Kubator
- 1,373
- 4
- 13