{"id":56,"date":"2013-07-02T01:30:23","date_gmt":"2013-07-02T01:30:23","guid":{"rendered":"http:\/\/www.linuxauthority.com\/wordpress\/?p=56"},"modified":"2013-07-03T00:13:33","modified_gmt":"2013-07-03T00:13:33","slug":"making-sure-what-is-configured-to-mount-is-mounted","status":"publish","type":"post","link":"https:\/\/www.linuxauthority.com\/wordpress\/?p=56","title":{"rendered":"Making sure what is configured to mount is mounted"},"content":{"rendered":"\n<!-- ALL ADSENSE ADS DISABLED -->\n<p>Here is a script that uses some advanced awk commands to check that what is configured to be mounted in \/etc\/fstab is actually mounted.<\/p>\n<div>#!\/bin\/ksh<\/div>\n<div>#########################################################################<\/div>\n<div># fsrootreserve<\/div>\n<div><\/div>\n<div>#HPUX_SCRIPTS=\/opt\/depots\/scripts\/system_build\/HPUX<\/div>\n<div>#COMMON=\/opt\/depots\/scripts\/system_build\/COMMON<\/div>\n<div># Load common environment<\/div>\n<div>. \/opt\/scripts\/env\/.scriptenv.linux<\/div>\n<div># set total variable for reserve blocks<\/div>\n<div>tot=0<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 echo &#8220;. Checking mount status of all filesystems defined in \/etc\/fstab&#8221;<\/div>\n<div><\/div>\n<div>if [ &#8220;$1&#8221; = &#8220;-y&#8221; ];then<\/div>\n<div>CHANGES=1<\/div>\n<div>fi<\/div>\n<div><\/div>\n<div>function fixmount {<\/div>\n<div>\u00a0 mtname=$1<\/div>\n<div>\u00a0 mount $mtname<\/div>\n<div>\u00a0 rc=$?<\/div>\n<div>\u00a0 if [ $rc -eq 0 ]<\/div>\n<div>\u00a0 then<\/div>\n<div>\u00a0 \u00a0 \u00a0 echo &#8221; \u00a0 \u00a0 \u00a0pass &#8211; ${mpn} is defined in \/etc\/fstab and currently mounted&#8221;<\/div>\n<div>\u00a0 else<\/div>\n<div>\u00a0 \u00a0 \u00a0 echo &#8221; FAIL &#8211; Remediate manually. The script can not mount ${mpn}.&#8221;<\/div>\n<div># \u00a0 \u00a0 \u00a0echo &#8221; I&#8217;m sorry Dave I am afraid I can&#8217;t do that. HAL-9000.&#8221;<\/div>\n<div>\u00a0 fi<\/div>\n<div><\/div>\n<div>}<\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div># The next line removes blank lines lines beginning with hash and some faux filesystems from the analysis. This is more efficient than piping to grep -v<\/div>\n<div>awk &#8216;\/.\/ &amp;&amp; !\/#\/ &amp;&amp; !\/\\\/tmpfs\/ &amp;&amp; !\/tmpfs\/ &amp;&amp; !\/\\\/sys\/ &amp;&amp; !\/swap\/ &amp;&amp; !\/\\\/proc\/ { print $2 }&#8217; \/etc\/fstab \u00a0| while read -r mpn<\/div>\n<div>do<\/div>\n<div>echo &#8220;checking filesystem $mpn&#8221;<\/div>\n<div>mt=$(grep &#8220;$mpn &#8221; \/proc\/mounts |awk &#8216;!\/rootfs\/ {print $1}&#8217; | wc -l);<\/div>\n<div><\/div>\n<div><\/div>\n<div>if (($mt != 1 ));then<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 if (($CHANGES));then<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fixmount $mpn<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 else<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 echo &#8221; FAIL \u00a0 \u00a0 \u00a0&#8211; file system ${mpn} is defined in \/etc\/fstab and NOT mounted. (-y will attempt to mount).&#8221;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fi<\/div>\n<div>else<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 echo &#8221; \u00a0 \u00a0 \u00a0pass &#8211; ${mpn} is defined in \/etc\/fstab and currently mounted&#8221;<\/div>\n<div>fi<\/div>\n<div>done<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a script that uses some advanced awk commands to check that what is configured to be mounted in \/etc\/fstab is actually mounted. #!\/bin\/ksh ######################################################################### # fsrootreserve #HPUX_SCRIPTS=\/opt\/depots\/scripts\/system_build\/HPUX #COMMON=\/opt\/depots\/scripts\/system_build\/COMMON # Load common environment . \/opt\/scripts\/env\/.scriptenv.linux # set total variable for reserve blocks tot=0 \u00a0 \u00a0 \u00a0 \u00a0 echo &#8220;. Checking mount status of all [&hellip;]<\/p>\n<a role=\"link\" class=\"rtp-readmore\" title=\"Read more on Making sure what is configured to mount is mounted\" href=\"https:\/\/www.linuxauthority.com\/wordpress\/?p=56\" rel=\"nofollow\">Read More &rarr;<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","hentry","category-scripting-2"],"_links":{"self":[{"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/56"}],"collection":[{"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":58,"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/58"}],"wp:attachment":[{"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxauthority.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}