87

I am mounting a NFS-folder from a server to my laptop.

Unfortunately, the server goes off sometimes... The problem is, that I cannot unmount the "dead" NFS-folder. On the command-line, I get "device is busy", and via nautilus it crashes my current session.

Is there any way to unmount a NFS-folder when the server is off?

2
159

You can use umount -f -l /mnt/myfolder, and that will fix the problem.

  • -f – Force unmount (in case of an unreachable NFS system). (Requires kernel 2.1.116 or later.)

  • -l – Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)

Source:Linux Complete Command Reference

2
  • 1
    it took me 20 minutes trying until I've google it and found this
    – confiq
    Apr 9 '17 at 13:09
  • You save my life!
    – Yu Jiaao
    Apr 17 '18 at 1:48
18

try sudo umount -l {mountPoint} to do a "lazy unmount". Lets you move on with your life without waiting for the plumber to arrive.

1
  • 4
    Upvote for good life advice May 7 '18 at 9:36
6

In my case where umount -f did not work, umount -fr worked. -r argument remounts as read-only and then unmounts the folder.

2

In case umount -f -l /mnt/myfolder doesn't work service nfs restart (or it's equivalent on your linux) might.

1
  • 4
    The problem with this is if you have several nfs mounted paths from different servers and you don't want to drop other mount points which would affect other services.
    – Efren
    May 16 '16 at 6:09
2

For me, neither umount, nor service restart will work. Just reboot. Even with a new system, NFS implementation seems to still have that old issue. So, just reboot.

0

I noticed something when trying to unmount directories for NFS servers that go offline. My first instinct is to unmount lowest subdirectories first and then work my way up to the top of the directory tree. However, unmounting subdirectories by using --force and --lazy failed and resulted in a long timeout. What finally worked for me was when I used --force and --lazy at the top level, as in:

umount --lazy --force /net/machine

Don't first try to unmount the lower directories, such as:

umount --lazy --force /net/machine/subdir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.