# nfs hangs?

## thelee

So I just finished setting up my own NAS with a really minimal gentoo setup along with nfs.  I exported two directories (/nfs-share/videos and /nfs-share/music) and mounted them successfully on my desktop and have been transferring my vast array of tv shows and music via simple cp commands.

Problem is, after a while, something weird happens.  my cp process might hang with no feedback whatsoever, and a CTRL-C won't terminate it.  Even if it didn't hang, sometimes after it completes trying to do anythign remotely related to where I mounted the nfs folders (even just ls'ing in a folder above, like, if i mounted an nfs folder at ~/videos and did an ls while in ~/) results in an indefinite hang that I can't get out of. I can't kill the processes and trying to close the xterm window doesn't work.  I can logout and that'll terminate the axterm, but I still won't be able to remotely interact with the mounted nfs volumes.  In fact, if I try to reboot, I'll get to the "* unmounting filesystems..." step and my computer will start hanging indefinitely until I manually press the reset or power button.

Is there a log file somewhere (either on the client or the server machine) to see what's going on?  Is this a problem that's happened to other people?

----------

## carl.anderson

I've had this issue before.  I think I fixed it by changing the NFS mount from hard to soft.  I believe hard mount is on by default.  

I found this relevant link.

----------

## thelee

thanks.  hopefully this'll fix it...

----------

## bunder

i'm afflicted by this as well... does anyone know what causes it specifically?  regardless of soft or hard mount, the filesystem should be able to make multiple requests simultaneously to the same directory...   :Confused: 

----------

## carl.anderson

For me the problem was that the server was unreachable, not that there were multiple simultaneous requests.  Also, I think it hung for 10 minutes rather than forever.  Do you have NFS 3 or 4 support (or both) in the kernel?  Also, you might want to have your clocks synced.  Try making the mount interruptible too.

----------

## krinn

you might give people something to play with, emerge --info is a minimal, but considering nfs, anything related might help, fstab, export, rpcinfo...

no clues, no help, not a rule, just a fact  :Very Happy: 

you still might not getting help, but you'll raise your chances

----------

## i92guboj

 *bunder wrote:*   

> i'm afflicted by this as well... does anyone know what causes it specifically?  regardless of soft or hard mount, the filesystem should be able to make multiple requests simultaneously to the same directory...  

 

NFS is one of the most annoying (yet still necessary) things that there are around. The policy by default is to mount hard, which means that any program doing I/O on an NFS volume will wait forever, until the I/O is finished. This is annoying for a number of reasons. 

A very annoying one is how your local box will hang forever if you decide to turn it off and the server is not reachable for any reason. In my opinion, it's a design flaw. Security is ok, but such behavior is not secure either, because it forces a hard reboot, which is, by definition, a danger for any filesystem.

The solution is to mount soft everything NFS related.

I guess that one of the reasons why concurrent access might be problematic is when one client process takes all the bandwidth (specially if the process opens many threads) and another process accessing concurrently to the same share is starved for a given amount of time. If this second process can't handle that well and fails for some reason, then it might hang forever. It's just a guess  :Razz: 

----------

## krinn

 *i92guboj wrote:*   

> 
> 
> The solution is to mount soft everything NFS related.
> 
> 

 

 *man nfs wrote:*   

>        intr / nointr  Selects whether to allow signals to interrupt file oper-
> 
>                       ations  on this mount point. If neither option is speci-
> 
>                       fied (or if nointr is specified), signals do not  inter-
> ...

 

 :Very Happy: 

----------

## i92guboj

Ouch, nice one. I wasn't aware of that option. Many thanks, krinn  :Wink: 

----------

## krinn

i still consider that as brutal, and not a solution, but at least smarter *should* be better  :Wink: 

----------

## i92guboj

Yes. As I said, it's just one of the annoying things about NFS. I am always looking for alternatives, though. But I haven't found anything stable that is easy to setup and doesn't add an overhead (I find sshfs to be an overkill just for a home network, and it doesn't work the way I want either).

----------

## krinn

Staying brutal but will solve at least the reboot problem

```
umount.nfs /nfsmountpointonclient -f -v
```

usual disclaimers for data lost... comes here  :Very Happy: 

----------

