{"id":349,"date":"2010-02-18T02:54:22","date_gmt":"2010-02-18T07:54:22","guid":{"rendered":"http:\/\/yourlinuxguy.com\/?p=349"},"modified":"2010-02-18T06:36:31","modified_gmt":"2010-02-18T11:36:31","slug":"why-cant-i-unmount-my-mount","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=349","title":{"rendered":"Why can&#8217;t I unmount my mount?"},"content":{"rendered":"<p>This basic (re-worded) question came in from Jeff: &#8220;<em>Why won&#8217;t my remote filesystem mount unmount when I try the <code>umount<\/code> command?<\/em>&#8221;<\/p>\n<p>It&#8217;s very true:\u00a0 If you try to <code>umount<\/code> (unmount) a filesystem that is currently being accessed, it will not let you do it.\u00a0 And it will tell you something like, &#8220;<code>umount: \/media\/ncp: device is busy<\/code>&#8220;.\u00a0 What causes this?\u00a0 Well, it&#8217;s likely to be one of two things:<\/p>\n<ol>\n<li>You have (or someone else has) <code>cd<\/code>&#8216;d onto the remote filesystem and are currently at or below the mount point root<\/li>\n<li>You are running an application that has a file open on that mount point<\/li>\n<\/ol>\n<p>To mitigate item #1 above (if you are the guilty party, not someone else), just <code>cd<\/code> to the filesystem root (like <code>cd \/<\/code>), or some other place you know is not on the mount point (like <code>cd \/tmp<\/code>).\u00a0 Then you can run your <code>umount<\/code> command.<\/p>\n<p>Solving item #2 above is perhaps a tad more tricky.\u00a0 Of course, if you have a suspicion or direct knowledge of the guilty app, then you can just stop it.\u00a0 Sometimes doing this:<\/p>\n<p><code>ps -ef | grep <\/code><br \/>\n&#8230;or&#8230;<br \/>\n<code>ps aux |grep <\/code><\/p>\n<p>&#8230;will show the process and any files it accessed by the startup command.<\/p>\n<p>Either way, my favorite way to check for both item #1 and #2 above is to use <code>lsof<\/code>.\u00a0 This utility will list *every* file that the system has a hold on.\u00a0 And this is essential because after all, we know that Linux is nothing but a bunch of files, right?<\/p>\n<p>So here&#8217;s what I like to do, for example:<\/p>\n<p><code>lsof| grep \"\/media\"<\/code><\/p>\n<p>&#8230; this will show you if anyone or anything is currently sitting on the mountpoint (of course, change your mountpoint to suit, be it <code>\/media<\/code>, <code>\/mnt<\/code>, <code>\/export<\/code>, whatever).\u00a0 If it shows anything, you can see who or what is at fault, and tell them to get off it, or kill them (I mean the app, jeez&#8230;).\u00a0 If you really need to see the headers of the columns, you can do a double-run for cosmetic purposes that will run once for just the header, then again to grab your detail, like this:<\/p>\n<p><code>lsof |head -1;lsof| grep \"\/media\"<\/code><\/p>\n<p>Another way is to use the <code>fuser<\/code> command, referencing your mount point.  Here&#8217;s my favorite set of flags in an example:<\/p>\n<p><code>fuser -uv \/media\/ncp<\/code><\/p>\n<p>I hope that helps!<\/p>\n<p>8)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This basic (re-worded) question came in from Jeff: &#8220;Why won&#8217;t my remote filesystem mount unmount when I try the umount command?&#8221; It&#8217;s very true:\u00a0 If you try to umount (unmount) a filesystem that is currently being accessed, it will not&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=349\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,47,81],"tags":[],"class_list":["post-349","post","type-post","status-publish","format-standard","hentry","category-intermediate","category-linuxgeneral","category-lsof"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-5D","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=349"}],"version-history":[{"count":15,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/349\/revisions"}],"predecessor-version":[{"id":351,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/349\/revisions\/351"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}