{"id":15765,"date":"2015-12-25T16:53:57","date_gmt":"2015-12-25T22:53:57","guid":{"rendered":"http:\/\/bucktownbell.com\/?p=15765"},"modified":"2015-12-25T16:53:57","modified_gmt":"2015-12-25T22:53:57","slug":"whats-the-best-way-to-check-if-a-volume-is-mounted-in-a-bash-script","status":"publish","type":"post","link":"http:\/\/bucktownbell.com\/?p=15765","title":{"rendered":"What&#8217;s the best way to check if a volume is mounted in a Bash script?"},"content":{"rendered":"<blockquote><p>What&#8217;s the best way to check if a volume is mounted in a Bash script? What I&#8217;d really like is a method that I can use like this: if &lt;something is mounted at \/mnt\/foo&gt; then &lt;Do some<\/p><\/blockquote>\n<p>Source: <em><a href=\"http:\/\/serverfault.com\/questions\/50585\/whats-the-best-way-to-check-if-a-volume-is-mounted-in-a-bash-script\">What&#8217;s the best way to check if a volume is mounted in a Bash script?<\/a><\/em><\/p>\n<div class=\"post-text\">\n<blockquote><p>Avoid using <code>\/etc\/mtab<\/code> because it may be inconsistent.<\/p>\n<p>Avoid piping <code>mount<\/code> because it needn&#8217;t be that complicated.<\/p>\n<p>Simply:<\/p>\n<pre class=\"lang-sh prettyprint prettyprinted\"><code><span class=\"kwd\">if<\/span><span class=\"pln\"> grep <\/span><span class=\"pun\">-<\/span><span class=\"pln\">qs <\/span><span class=\"str\">'\/mnt\/foo'<\/span> <span class=\"pun\">\/<\/span><span class=\"pln\">proc<\/span><span class=\"pun\">\/<\/span><span class=\"pln\">mounts<\/span><span class=\"pun\">;<\/span> <span class=\"kwd\">then<\/span><span class=\"pln\">\r\n    echo <\/span><span class=\"str\">\"It's mounted.\"<\/span>\r\n<span class=\"kwd\">else<\/span><span class=\"pln\">\r\n    echo <\/span><span class=\"str\">\"It's not mounted.\"<\/span>\r\n<span class=\"kwd\">fi<\/span><\/code><\/pre>\n<\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What&#8217;s the best way to check if a volume is mounted in a Bash script? What I&#8217;d really like is a method that I can use like this: if &lt;something is mounted at \/mnt\/foo&gt; then &lt;Do some Source: What&#8217;s the &hellip; <a href=\"http:\/\/bucktownbell.com\/?p=15765\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[284],"tags":[1345,721,28,72],"class_list":["post-15765","post","type-post","status-publish","format-standard","hentry","category-servers","tag-bash-script","tag-linux-admin","tag-linux-command","tag-problem-solved"],"_links":{"self":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/15765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15765"}],"version-history":[{"count":2,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/15765\/revisions"}],"predecessor-version":[{"id":15791,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/15765\/revisions\/15791"}],"wp:attachment":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15765"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}