Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Server A used to be a NFS server. Server B was mounting an export of that. Everything was fine. Then A died. Just switched off. Gone. Vanished.

However that folder is still mounted on B. I obviously can't cd into it or anything. However umount /mnt/myfolder just hangs and won't umount. Is there anyway to umount it without restarting B?

share|improve this question

7 Answers 7

up vote 24 down vote accepted

Assuming Linux:

umount -f -l /mnt/myfolder

Will sort of 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.)

-f also exists on Solaris and AIX.

share|improve this answer
    
yes both server and client are linux –  Rory Aug 20 '09 at 13:42
    
I had the same issue, googled and came here. Yes - the lazy flag really helped me here... -f on it's own wasn't doing it... –  wawawawa Jul 15 '10 at 17:27

It might be wise to add the intr option to any /etc/fstab entries that might end up hanging or crashing. If you don't use the soft or intr options, then when the server hosting the NFS files goes down, the server on which the files are mounted (the client) may hang when booting up.

According to man 5 nfs:

= = =

soft / hard
Determines the recovery behavior of the NFS client after an NFS request times out. If neither option is specified (or if the hard option is specified), NFS requests are retried indefinitely. If the soft option is specified, then the NFS client fails an NFS request after retrans retransmissions have been sent, causing the NFS client to return an error to the calling application.

= = =

... and then it goes on to say intr is preferred over soft, but it has the similar effect of preventing hanging.

share|improve this answer

I just noticed that forcing unmounts on kernel 3.2.0 hangs with NFSv4 mounts. NFSv3 unmounts work fine.

$ mount [...] -o nfsvers=3
share|improve this answer

Elaborating upon the hint given by David Pashley,

unless "umount -l" solves your problem, you can set up a fake server with the same address as the one that has gone away - but you don't actually have to set up a new sever or anything. The easiest way out of the blocking/hung umount situation is to set up a local alias IP interface, as follows:

ifconfig eth0:nfstmp 11.22.33.44 netmask 255.255.255.255
umount -l /mnt/deadnfsmount    # -l or -f or whichever that gets the job done
ifconfig eth0:nfstmp down

(obviously 11.22.33.44 being the (former) IP address of the (now dead) NFS server)

share|improve this answer
    
A clever workaround. I'll have to keep that one in mind. –  Kamil Kisiel Oct 19 '09 at 14:29
    
brilliant! just the solution I needed today! Thanks. –  Tim Kennedy Jan 4 '12 at 1:53

Just as an aside, using automount will handle unmounting NFS shares when they become unavaliable, which avoids getting stuck in this situatuion in future.

share|improve this answer
1  
Not necessarily. automount mounts can also hang in this condition, if you try to access the directory in any way the process will hang. –  Kamil Kisiel Oct 19 '09 at 14:29
    
Yeah, the automounter causes as many problems as it solves. –  pjc50 Nov 26 '09 at 16:45

I've never managed to get "umount -f" to work. A useful trick is to set up another server mounting the same export, give it the same IP address as the old server. Your NFS client should think everything is back as normal and processes will unblock. You can then unmount the mountpoint normally and remove the IP address from the temporary NFS server.

share|improve this answer
1  
the -l (lazy) is the key, as mentioned above –  Matt Simmons Aug 20 '09 at 13:56

umount -f /mnt/myfolder should solve this. See the umount manpage.

share|improve this answer
    
This doesn't quite do it with NFS and a dead server. You need the lazy flag too (or the trick with adding an IfAlias). lsof and fuser all hang and umount -f says "device busy". –  wawawawa Jul 15 '10 at 17:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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