<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Test if there is a filesystem mounted in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066903#M438003</link>
    <description>&amp;gt;VK2COT: Here is a little snippet for /bin/sh&lt;BR /&gt;&lt;BR /&gt;I had a little trouble interpreting your script.  First of all, you should have used bdf and not df, otherwise it won't work.&lt;BR /&gt;&lt;BR /&gt;I don't understand why you want to exclude "awk"?  ! /awk/ &lt;BR /&gt;&lt;BR /&gt;Also, you might want to use awk -v instead of something hard to understand with your stuttering quoting:&lt;BR /&gt;&lt;BR /&gt;M=$(bdf $fsname | awk -v fsname=$fsname '! /Mounted on/ { if ($NF == fsname) print}')&lt;BR /&gt;if [ "$M" ]; then&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 06 Sep 2007 01:15:47 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-09-06T01:15:47Z</dc:date>
    <item>
      <title>Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066897#M437997</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;How can I test in a shell script if a filesystem is mounted on directory?&lt;BR /&gt;&lt;BR /&gt;Thks,&lt;BR /&gt;&lt;BR /&gt;Pedro</description>
      <pubDate>Tue, 04 Sep 2007 05:51:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066897#M437997</guid>
      <dc:creator>Pedro Cirne</dc:creator>
      <dc:date>2007-09-04T05:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066898#M437998</link>
      <description>grep $dir /etc/mnttab&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;    echo mounted&lt;BR /&gt;fi</description>
      <pubDate>Tue, 04 Sep 2007 05:54:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066898#M437998</guid>
      <dc:creator>Luk Vandenbussche</dc:creator>
      <dc:date>2007-09-04T05:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066899#M437999</link>
      <description>Thks</description>
      <pubDate>Tue, 04 Sep 2007 05:59:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066899#M437999</guid>
      <dc:creator>Pedro Cirne</dc:creator>
      <dc:date>2007-09-04T05:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066900#M438000</link>
      <description>I know you've already closed this, but I like to make commands shorter if I can!&lt;BR /&gt;&lt;BR /&gt;if grep $dir /etc/mnttab&lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;Mark Syder (like the drink but spelt different)</description>
      <pubDate>Tue, 04 Sep 2007 07:28:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066900#M438000</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2007-09-04T07:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066901#M438001</link>
      <description>&amp;gt;Mark Syder: I like to make commands shorter&lt;BR /&gt;&lt;BR /&gt;You should also use grep -q:&lt;BR /&gt;if grep -q $dir /etc/mnttab; then</description>
      <pubDate>Tue, 04 Sep 2007 12:08:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066901#M438001</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-04T12:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066902#M438002</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Note that /etc/mnttab can get corrupt or&lt;BR /&gt;have missing record for a specific file system.&lt;BR /&gt;&lt;BR /&gt;Do not rely on /etc/mnttab exclusively.&lt;BR /&gt;&lt;BR /&gt;Here is a little snippet for /bin/sh and /bin/bash script:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;fsname="/opt"&lt;BR /&gt;&lt;BR /&gt;if [ "`df $fsname | awk '! /awk/ &amp;amp;&amp;amp; ! /Mounted on/ { if ( $NF == "'$fsname'" ) {print}}'`" ]&lt;BR /&gt;then&lt;BR /&gt;    echo "PASS: $fsname mounted"&lt;BR /&gt;else&lt;BR /&gt;    echo "FAIL: $fsname not mounted"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT&lt;BR /&gt;&lt;BR /&gt;PS. The thread is closed so do not worry about assigning points.</description>
      <pubDate>Tue, 04 Sep 2007 17:10:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066902#M438002</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2007-09-04T17:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066903#M438003</link>
      <description>&amp;gt;VK2COT: Here is a little snippet for /bin/sh&lt;BR /&gt;&lt;BR /&gt;I had a little trouble interpreting your script.  First of all, you should have used bdf and not df, otherwise it won't work.&lt;BR /&gt;&lt;BR /&gt;I don't understand why you want to exclude "awk"?  ! /awk/ &lt;BR /&gt;&lt;BR /&gt;Also, you might want to use awk -v instead of something hard to understand with your stuttering quoting:&lt;BR /&gt;&lt;BR /&gt;M=$(bdf $fsname | awk -v fsname=$fsname '! /Mounted on/ { if ($NF == fsname) print}')&lt;BR /&gt;if [ "$M" ]; then&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Sep 2007 01:15:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066903#M438003</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-06T01:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066904#M438004</link>
      <description>I forgot to mention in my reply to VK2COT that using bdf to see if something is mounted may be expensive.  Doing bdf on a NFS directory may take some time.  It may be better to just trust mnttab and use syncer(1M) to keep it up to date, 30 seconds seems ok?</description>
      <pubDate>Thu, 06 Sep 2007 03:44:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066904#M438004</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-06T03:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Test if there is a filesystem mounted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066905#M438005</link>
      <description>Hello again,&lt;BR /&gt;&lt;BR /&gt;Dennis, thanks for the comments.&lt;BR /&gt;I used df(1) as I cut-and-pasted from&lt;BR /&gt;my home Linux server :)&lt;BR /&gt;&lt;BR /&gt;Of course, bdf(1) is more suitable&lt;BR /&gt;for HP-UX.&lt;BR /&gt;&lt;BR /&gt;As far as NFS slowdown is concerned,&lt;BR /&gt;one can avoid checking it by using:&lt;BR /&gt;&lt;BR /&gt;bdf -t vxfs&lt;BR /&gt;bdf -t hfs&lt;BR /&gt;and similar&lt;BR /&gt;&lt;BR /&gt;If NFS is really a problem, then the&lt;BR /&gt;server is unresponsive anyway, so the&lt;BR /&gt;file system is acting almost like&lt;BR /&gt;being unmounted...&lt;BR /&gt;&lt;BR /&gt;Alas, if /etc/mnttab is corrupt,&lt;BR /&gt;and if one has bad luck,&lt;BR /&gt;waiting 30 seconds for syncer(1) to&lt;BR /&gt;update the file can be too long.&lt;BR /&gt;&lt;BR /&gt;# uname -a&lt;BR /&gt;HP-UX myserv B.11.11 U 9000/800 1448733058 unlimited-user license&lt;BR /&gt;&lt;BR /&gt;# cat /etc/mnttab&lt;BR /&gt;&lt;BR /&gt;# df -k&lt;BR /&gt;&lt;BR /&gt;# bdf&lt;BR /&gt;Filesystem          kbytes    used   avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol3     212992  137904   74560   65% /&lt;BR /&gt;/dev/vg00/lvol1     298928   56768  212264   21% /stand&lt;BR /&gt;/dev/vg00/lvol8    2621440 1416088 1198128   54% /var&lt;BR /&gt;/dev/vg00/lvol10   1048576    3388  981331    0% /var/tmp&lt;BR /&gt;/dev/vg00/lvol11   1048576   91944  896903    9% /var/opt/perf&lt;BR /&gt;/dev/vg00/lvignite 46612480 33730800 12781064   73% /var/opt/ignite&lt;BR /&gt;/dev/vg00/lvol12   1048576  160045  833055   16% /var/opt/OV&lt;BR /&gt;/dev/vg00/lvol9    4194304 1012790 2982812   25% /var/adm/crash&lt;BR /&gt;/dev/vg00/lvol7    2244608 1401872  836176   63% /usr&lt;BR /&gt;/dev/vg00/lvol4     524288   93240  427736   18% /tmp&lt;BR /&gt;/dev/vg00/lvol6    3276800 2529776  741224   77% /opt&lt;BR /&gt;/dev/vg00/lvol5     524288    5968  514592    1% /home&lt;BR /&gt;&lt;BR /&gt;In other words, one might face a race &lt;BR /&gt;condition when tests fail because&lt;BR /&gt;/etc/mnttab is empty or corrupt.&lt;BR /&gt;&lt;BR /&gt;Commands bdf(1), and mount(1) update&lt;BR /&gt;/etc/mnttab on HP-UX, but df(1) does not.&lt;BR /&gt;See real-life example above.&lt;BR /&gt;&lt;BR /&gt;My point was not to trust single commands.&lt;BR /&gt;If something is critical double-check.&lt;BR /&gt;&lt;BR /&gt;In my Perl OAT script, for example,&lt;BR /&gt;I check file systems in many ways. Once,&lt;BR /&gt;I found a very weird server that had&lt;BR /&gt;/stand unmounted. II was aksed to come to a specific customer and upgrade their server.&lt;BR /&gt;It was the first time ever I saw an HP-UX server running happily without /stand.&lt;BR /&gt;&lt;BR /&gt;It is easy to replicate it (I just did it&lt;BR /&gt;on one server):&lt;BR /&gt;&lt;BR /&gt;# umount /stand&lt;BR /&gt;&lt;BR /&gt;# dmesg&lt;BR /&gt;&lt;BR /&gt;Sep  6 21:13&lt;BR /&gt;Can't get kernel namelist&lt;BR /&gt;&lt;BR /&gt;That is how I knew something was wrong :)&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Thu, 06 Sep 2007 06:17:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-if-there-is-a-filesystem-mounted/m-p/5066905#M438005</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2007-09-06T06:17:34Z</dc:date>
    </item>
  </channel>
</rss>

