Results 1 to 7 of 7
What is the best way to check if a device is mounted in a shell script?
Ideally it would check if the device is mounted to the correct mount point; ...
- 11-22-2009 #1
Best Way to Check if Device is Mounted
What is the best way to check if a device is mounted in a shell script?
Ideally it would check if the device is mounted to the correct mount point; I would prefer something as basic as possible.
Also, what happens when files are written to a directory that is a mount point while the device isn't mounted? Does the mounted device just replace those files while it is mounted, or do the files eventually get written to the device itself?Last edited by egan; 11-22-2009 at 09:43 PM.
- 11-22-2009 #2
just use command mount
it will show you everything
if you put something into a directory while it is not mounted, it will be stored on the parent mount point (usually /), it will not get put on that device automatically, and when the device is mounted the file will look like it has disappeared
in order to put it onto the mounted device, you will have to move it elsewhere, mount the device, then put it on the device
- 11-22-2009 #3
Thanks for clearing up my file question, but I suppose I was a bit unclear.
I want a simple algorithm that I use as a function in a bash script to return true if the prescribed directory has the prescribed device mounted to it, and false otherwise. I would prefer not to have the cut and sed out the information from the dump of human-readable information, but rather just a simple output if one exists.
- 11-24-2009 #4
Anyone have any suggestions? I could hack through ouput of mount but there has to be a more elegant way to do this!
- 11-25-2009 #5Just Joined!
- Join Date
- Aug 2005
- Posts
- 65
this is the logic the high level language use not the script way , i think
- 11-26-2009 #6
Use /bin/mountpoint!
Code:if ! mountpoint -q /mnt/backup; then mount /mnt/backup fi
- 11-26-2009 #7


Reply With Quote
