{"id":356,"date":"2012-02-25T01:39:50","date_gmt":"2012-02-25T01:39:50","guid":{"rendered":"http:\/\/joelinoff.com\/blog\/?p=356"},"modified":"2026-06-28T17:38:45","modified_gmt":"2026-06-29T00:38:45","slug":"how-to-fix-stale-nfs-mounts-on-linux-without-rebooting","status":"publish","type":"post","link":"https:\/\/joelinoff.com\/blog\/?p=356","title":{"rendered":"How to fix stale NFS mounts on linux without rebooting"},"content":{"rendered":"I have often noticed that some folks reboot systems to fix stale NFS mount problems which can be disruptive. \n\nFortunately, that often isn&#8217;t necessary. All you have to do is restart nfs and autofs services.  However that sometimes fails because user processes have files open on the stale partition or users are cd&#8217;ed to the stale partition. \n\nBoth conditions are easy to fix. The steps to fix stale mounts by addressing the previously described conditions are described below.\n<!--more-->\n<h1>Step 1. Kill process with open files on the partition<\/h1>\nUse <code>lsof <\/code> to find the processes that have files open on the partition and then kill those processes using <code>kill<\/code> or <code>pkill<\/code>.\n\n\n<pre class=\"wp-block-code language-bash\"><code class=\"language-bash\">% sudo su -\n\n% # Find the jobs that are accessing the state partition and kill them.\n% kill -9 $(lsof |\\\n    egrep '\/stale\/fs|\/export\/backup' |\\\n    awk '{print $2;}' |\\\n    sort -fu )\n\n% # Restart the NFS and AUTOFS services\n% service nfs stop\n% service autofs stop\n% service nfs start\n% service autofs start\n\n% # Check it\n% ls \/stale\/fs<\/code><\/pre>\n\nTypically this is sufficient but if it fails, you need to go to step 2.\n\n<h1>Step 2. Kill process that have cd&#8217;ed to the partition<\/h1>\nLook at the current working directory of all of the users. If any of them are on the partition, that process has to be killed. \n\n\n<pre class=\"wp-block-code language-bash\"><code class=\"language-bash\">% sudo su -\n\n% # List the users that are cd'ed to the stale partition and kill their jobs.\n% # NOTE: change \/stale\/fs to the path to your stale partition.\n% kill -9 $( for u in $( who | awk '{print $1;}' | sort -fu ) ; do \\\n    pwdx $(pgrep -u $u) |\\\n    grep '\/stale\/fs' |\\\n    awk -F: '{print $1;}' ; \\\ndone)\n\n% # umount the stale partition\n% umount -f \/state\/fs\n\n% # Restart the NFS and AUTOFS services\n% service nfs stop\n% service autofs stop\n% service nfs start\n% service autofs start\n\n% # Check it\n% ls \/stale\/fs<\/code><\/pre>\n\n\nIf that fails you have to kill all of the users.\n\n<h1>Step 3. Kill all of the users<\/h3>\nIf step 2 doesn&#8217;t work then there is something strange going on but killing all of the user processes will usually fix it. That is done as follows.\n\n\n<pre class=\"wp-block-code language-bash\"><code class=\"language-bash\">% sudo su -\n\n% # Kill all user processes.\n% for u in $( who | awk '{print $1;}' | sort -fu ) ; do \\\n    kill -9 $(pgrep -u $u) |\\\n    awk -F: '{print $1;}' ; \\\ndone\n\n% # umount the stale partition\n% umount -f \/state\/fs\n\n% # Restart the NFS and AUTOFS services\n% service nfs stop\n% service autofs stop\n% service nfs start\n% service autofs start\n\n% # Check it\n% ls \/stale\/fs<\/code><\/pre>\n\n\nAs you can see, it is basically the same as step 2 except that all user processes are killed.\n\nIf that doesn&#8217;t work you need to resort the nuclear option: rebooting.\n\n<h1>Step 4. Reboot<\/h1>\nThis is the option of last resort but it should always work.\n\nIf you know of any other tips for fix stale NFS mounts I would really like to hear about them.\n\nEnjoy!\n","protected":false},"excerpt":{"rendered":"<p>I have often noticed that some folks reboot systems to fix stale NFS mount problems which can be disruptive. Fortunately, that often isn&#8217;t necessary. All you have to do is restart nfs and autofs services. However that sometimes fails because user processes have files open on the stale partition or users are cd&#8217;ed to the &hellip; <a href=\"https:\/\/joelinoff.com\/blog\/?p=356\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to fix stale NFS mounts on linux without rebooting<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-356","post","type-post","status-publish","format-standard","hentry","category-bash"],"_links":{"self":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=356"}],"version-history":[{"count":13,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":1801,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/356\/revisions\/1801"}],"wp:attachment":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}