108

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?

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Produnis
  • 1,747

6 Answers6

215

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

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Mitch
  • 107,631
25

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

Stabledog
  • 981
7

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

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.

Max
  • 29
2

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

  • 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 06:09
1

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
smonff
  • 498
Tony
  • 11