using /proc/mounts would be the most accurate on a Linux system, since it gives the most up-to-date information even in a ro remount situation. There is a catch though, since modern Linux distributions mount by uuid for example and then that would no longer fly.
$? would be 0 if grep finds otherwise 1 if it doesn't find.
This is only because in all your cited examples "grep" is the last part of the pipeline and on most systems you get the exit status of the last executed program as the exit status of the pipeline. If your list would be very long and you would execute:
you would get the exit status of "more" instead of the exit status of "grep". This is exactly what i told you: for every program you will have to look up the meaning of its various exit statuses in its man page. This is true for "grep" as well as "more" as for any other program.
Quote:
Originally Posted by Chubler_XL
Not true, a shell has it's on internal commands, and these can be used to process information.
ahh, yes: wake me up when you find an internal shell command for listing mounts.
Quote:
Originally Posted by Chubler_XL
For example the following bash script will check if a filesystem is mounted, by reading the /proc/mounts list:
I am so sorry, I want to apologize: i want to apologize for not recognizing that the thread opener has a Linux system despite he never said so, so that your argument gains any value.
I want to apologize for saying something which is only true "in general" and maybe not for some obscure derivate of Unix. The script you provided as example is based on the existence of a "/proc" file system, which is simply not there in many Unix variants. It is also based on the existence of "/proc/mounts", which doesn't exist in almost any Unix derivate.
I foremost want to apologize for having confused the vast world of some specific Linux distribution (for which your code will probably work) and kernel version with the narrow, almost non-existent and certainly negligeable niche of all the other Unix products (in which your code won't work at all).
Hi
I have the following piece of code, running on a solaris 10 O.S., that is not working for NFS file systems:
for vol in `grep -E 'vxfs|ufs|nfs' /etc/vfstab | egrep -v '^#' | awk '{ print $3 }'`
do
if df -k $vol | grep $vol > /dev/null
then
outputOK "Filesystem: $vol mounted"
else... (1 Reply)
Hi
I need to have a piece of code that check if all file systems are mounted or not.
I have to pieces of information like the output of the bdfcommand, and the file /etc/fstab.
The first is:
bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 2097152 266656... (3 Replies)
Hi there,
I am able to check which parition from Storage > Disk Management
How is it possible to check if the folder is mounted on which partition. (1 Reply)
I'd like to make a wrapper bash script that will make sure that an nfs mount is mounted before launching a program that depends on the mount being active. Basically:
1) Check to see if the mount is active
2) If it's not active, try to mount it
3) If it won't mount because the nfs server is... (3 Replies)
Dear All
Anyone can help me what is the problem of swap partition? swap partition is showing mounted in df -h command output.
Regards
prakash (1 Reply)
How can I check which partition /usr are mounted on ? Usually this is mounted on root (/). If I want to move /usr to another partition, how do I do this ?
BR Ludwig (1 Reply)
Hello ,
I 've got a problem with the root partition on my SCO 5.0.5 .
When I check the disk with df or mount , I can 't see the root filesystem .
# mount
/stand on /dev/boot read only on Tue Sep 05 16:13:51 2006
/home on /dev/home read/write on Tue Sep 05 16:14:41 2006
But , if I try... (3 Replies)