Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to force a Linux client to reconnect to a NFS server after it has lost its connection? The client eventually notices the server is back and resumes working just fine. I'm just wondering if there is a way to speed up this re-connection.

share|improve this question

2 Answers 2

You could look into Autofs (ArchWiki link). If you setup the NFS to automount, the client should try to (re)connect to the NFS drive every time you try to use it. This would ensure that if you try to access the NFS drive from the client and the server is up, then the NFS drive will attach.

share|improve this answer
    
Thanks for the answer. This doesn't help in this, case the share is already mounted and the client is already talking to the server. Sometimes, I kill the connection (it is only between a couple of my personal systems), and when I reestablish the link I'd like to kill the timeout period. Autofs wouldn't help in this, or if it would speed up the re-connection, it would be nice to know how it did as I'd like to do that manually. –  MJD Jul 18 '13 at 21:30
    
could you give an example of trying to reattach and it not working? maybe with mount -a? –  bkanuka Jul 19 '13 at 13:37
    
I think you misunderstanding what I'm doing. I don't unmount the nfs volume between before disconnecting the networks. In this case it is fine, as it is just between my personal stuff, and I rather have the processes reading files off the NFS mount point to sleep then fail. When I reconncet the network, there is a timeout period before the client re-finds the server. That timeout period is what I want to kill, since I know the server is back. The timeout isn't too bad, but it is a little annoying. –  MJD Jul 19 '13 at 19:58
    
hmm. I am misunderstanding something. Now I'm imagining you have a laptop and a home server, and sometimes you like to just grab the laptop and go. When you return, you reconnect to your home network...and then wait...and finally your NFS shares attach again. Am I right? –  bkanuka Jul 21 '13 at 12:35
    
Well, sort of. Except the laptop is the NFS server, and a Desktop is the client. And if I'm leaving with my laptop, I don't care if half the desktop freezes over the lost of its server (and it does ...). Since half the desktop if frozen, I'd like to speed up that reconnection. I have a feeling I'm abusing NFS, so I figured there is no way to help me. Since its just an annoyance, I'm not concerned. –  MJD Jul 23 '13 at 21:16

Perhaps you can tweak the timeo and retrans options of the NFS mounts to achieve the desired behavior. See this man page for more information.

share|improve this answer

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.