0

Here's the problem: I wanted to create a file share between my laptop and my pc at home so that I have access to my files from both machines. The laptop is the server (as I might need the files when on the move) and the pc is the client.

Here's my attempt at a solution: having linux (debian) on both machines, I decided to use NFS. Everything worked fine until I rebooted both machines and I ran into a catch-22. Ideally, I wanted the server to automatically mount the NFS, so I added a line in /etc/fstab. Although, after rebooting the server, I noticed that I had to re-run exportfs -a to re-load my /etc/exports, which looks like this:

/nfs     pc(rw,sync,no_subtree_check)

In order to do this, though, pc had to be reachable, otherwise I got this error upon

exportfs: failed to resolve pc

So, if pc had to be reachable before laptop was on, it defies the point of having a /etc/fstab for pc, unless I expected very few re-boots of laptop, which is not my case.

In short: pc wants laptop to be reachable to mount the NFS automatically via fstab, while laptop wants pc to be reachable in order to assign the correct permissions in exports. Is there a way to run exportfs -a at startup for laptop without having to have pc on?

2 Answers 2

1

The server shouldn't care if the client is reachable or not. It's just making a share available... whether it's used or not.

The error you are getting "exportfs: failed to resolve pc", isn't saying it can't "reach" pc. It's saying it cant "resolve" pc. The problem is that you are referencing a specific client by hostname, but the system can't resolve the hostname into an IP address.

Apparently, this is a known bug in the way exportfs works. I haven't' looked too deep into it, but in the cases I saw (simply google for the error message), it's a timing problem between when nfs starts and when dns services are available. There are also problems with DHCP defined clients and DNS not being updated fast enough.

Anyway, your problem is a name-resolution one. If "pc" has a static IP address, you could use the address in /etc/exports, or add "pc" to your /etc/hosts file. If either hosts are DHCP, you may be out of luck.

On the client side ("pc"), you might want to look into using automounter (autofs) to mount the remote filesystem instead of using /etc/fstab. Automounter will only mount the filesystem when you need it, so it's unlikely to hang on a system boot if the NFS server isn't available.

Some references to the problems with exportfs and name resolution: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860264 https://forums.centos.org/viewtopic.php?t=69981 Lot's more out there showing similar problem.

1
  • Great tips, thanks
    – Pepino
    Sep 8, 2020 at 10:06
0

I had the same problem and tried to solve it with the nfs-server.service unit but did not succeed.
So I finally ended up to put a script into crontab, like

#crontab -e
@reboot /usr/local/bin/exportNFS

and

#cat /usr/local/bin/exportNFS
sleep 5
/usr/sbin/exportfs -r

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .