Help with code to check if file systems are mounted
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:
and
I am trying the following:
The stuff in for vol in stuff is a list of strings. And, the 2nd string in:
is | which is a shell keyword that would need to be escaped if you wanted it to be treated as a string instead of a keyword. But, I would guess you wanted something more like;
where expression (which you omitted) probably should be something like '^#'.
In addition to that, your do is missing a matching done. And, we have no idea what the outputOK and outputW commands are that you are calling in your script. Both rdrtx1 and I assumed that both of those commands are just printing the strings given to them. The script rdrtx1 suggested invokes awk once and invokes both bdf and grep once for each filesystem listed in /etc/fstab. Both rdrtx1's suggestion and your code can falsely report that a filesystem is mounted if one filesystem name is a subset of another filesystem name (for example, if /data1 and /data10 are two filesystems listed in /etc/fstab and /data10 is mounted but /data1 is not, your code will incorrectly report that /data1 is mounted).
The following alternative only invokes awk once and bdf once, and will not report false positives:
Although written and tested with a Korn shell, this will work with any shell that accepts Bourne shell syntax.
As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
With the sample data you provided, it produces the output:
This User Gave Thanks to Don Cragun For This Post:
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 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)
Hi All,
In Solaris 10, how can I check back who is login to the systems by telnet, ssh and ftp in success or failed.
I already check on /var/adm/messages but no details for all this.
Hope your can help.
Thanks. (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)
hi,
I posted a thread before on that subject, but with a wrong focus...
here's my problem: I want to check if a file exists in a windows shared folder mounted using:
sudo mount -t cifs -o username=xxx,password=xxx,uid=xxx,gid=xxx //192.168.0.92/public /media/92_shared
I tried
if
... (2 Replies)
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)
We have 6 hard disks attached to the hardware. Of this 2 hard disks are of 9 GB each.
Now I want combine both the same in such a way that i see a combined entry in the output of df -k .
The steps I follow are
1. Create partition on hard disks (Using format partition)
2. Run newfs -v for... (6 Replies)