2

I am trying to set up my pi3 running raspbian as an NFS server. I've followed these instructions: http://www.htpcguides.com/configure-nfs-server-and-nfs-client-raspberry-pi/

In /etc/exports I have the line:

/mnt/Shared 192.168.1.0/24 *(rw,sync)

Which I hope means that the folder at /mnt/Shared (which is a directory on an external hard drive) is available for reading and writing by all machines using a local IP address. Then I do exportfs:

$ sudo exportfs
/mnt/Shared    192.168.1.0/24
/mnt/Shared    <world>

Then, on my laptop, which is running Ubuntu, I follow the client side instructions from the same site, but the mount command fails after a long wait:

$ sudo mount 192.168.1.105:/mnt/Shared /mnt/nfs
mount.nfs: Connection timed out

If I try that verbose it looks like this:

sudo mount -v 192.168.1.105:/mnt/Shared /mnt/nfs/
mount.nfs: timeout set for Sat Feb 18 21:52:14 2017
mount.nfs: trying text-based options 'vers=4,addr=192.168.1.105,clientaddr=192.168.1.109'
mount.nfs: mount(2): Connection refused
mount.nfs: trying text-based options 'vers=4,addr=192.168.1.105,clientaddr=192.168.1.109'
mount.nfs: mount(2): Connection refused
...
<repeated several times>
...
mount.nfs: Connection timed out

Has anyone any ideas of how to make it work? I don't think the problem is with the external hard drive, it appears to be mounted correctly, and I had the same issues trying to share a local directory.

2
  • I've got it to work! A commenter on this question (raspberrypi.stackexchange.com/questions/48091/…) suggested trying "sudo systemctl restart nfs-kernel-server" after each reboot of the system, and since I've done that it seems to work. I need to figure out how to make that happen automatically after each reboot. Once I've done that I'll add it as an answer, unless someone has a better solution in the mean time.
    – EddyTheB
    Feb 19, 2017 at 11:15
  • 1
    I'm not sure the result of the exportfs is remembered across boots. Try putting the exportfs data in /etc/exports or under /etc/exports.d. There should be no need to restart nfs-kernel-server if the nfs configuration files are correct. Feb 23, 2017 at 19:17

3 Answers 3

0

First I would make the following bash script and call it delay:

#!/bin/bash
# $1:delay time(s)
# $2:command
# example:
#    delay 10 "conky -d"

sleep $1
exec $2

Then I would make it executable

chmod a+x delay

You could put the command from your comments:

delay 60 "sudo systemctl restart nfs-kernel-server"

at the end of the rc.local file in /etc/init.d/ to have it run 60 seconds after every time the Pi boots up

3
  • Thanks for the tip, but I'm afraid it doesn't seem to be working. After a reboot the drives still wont mount until I run the command myself through ssh.
    – EddyTheB
    Feb 20, 2017 at 7:13
  • @eddytheb I've made an edit to my answer can you please try it now? Feb 20, 2017 at 15:47
  • Thanks again, but I'm afraid it still doesn't seem to be working. Your delay script works, but when I reboot the pi I still have to ssh in and run the restart command myself before the folder becomes visible (even after waiting much longer than a minute).
    – EddyTheB
    Feb 20, 2017 at 18:15
0

On the RPi NFS Server (The Media Server)

sudo /etc/init.d/rpcbind restart
sudo /etc/init.d/nfs-kernel-server restart

On the RPi NFS Client (My Plex Server)

sudo mount 192.168.1.105:/mnt/Shared /mnt/nfs

This worked for me.

And I had to mount my drives including the uid/gid in /etc/fstap because in my case chown does not work when the drive is mounted by root. Maybe someone can give me a tip for that.

0

Tell reboot to wait for the network to be available. It’s on raspi-config in the advanced section iirc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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