Solved

Check if NFS Filesystem is mounted

Posted on 1998-11-23
4
1,422 Views
Last Modified: 2008-03-04
I have an NT Share that is NFS exported and being mounted on an AIX 4.2.1 system. Before I write anything to that mounted NFS volume, I want to make sure that it is in fact mounted otherwise I want to error out. How can I check if the filesystem is mounted?

Angel
0
Comment
Question by:aleyva
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 1206519
open (FID , "df -k |") || die "df failed: !$";
@text = <FID>;
foreach (@text) { print "$_" if m/^hostname/;}

0
 

Author Comment

by:aleyva
ID: 1206520
I tried working with your sparse response, but couldn't make it work. Before I reject the answer, can you explain how to use your information. If I do a `df -k` with the filesystem unmounted, I get the listing for the filesystem that the mount point is created on, if the system is mounted, then I get the information for the NFS filesystem. How can I tell the difference without simply looking for key words like:

/dev/images_staging     2097152   1985636    6%      444     1% /images_staging
parsas001:d:\agtout    39596000   7281912   82%       70     1% /images_staging/outgoing/PAR

Angel
0
 

Author Comment

by:aleyva
ID: 1206521
I think I got it now.

Thanx
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206522
> If I do a `df -k` with the filesystem unmounted, I get the listing for the filesystem that the mount point is on

NO, when it is not mounted, df doesn't list it.
But you may have a mounted filesystem which is not available, UNIX calls this a
"stale NFS handle"; in this case df will list it, but usually hangs at this point :-(

If my answer was to short, probably following is more what you like:
   open (FID , "df -k |") || die "df failed: !$";
   @text = <FID>;
   close FID;
   foreach (@text) { if (m/^hostname:/ {$is_mounted=1; last;} }
and there are a couple of ways to write it  in perl ..

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now