fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

NFS Server not loading after reboot

Mon Mar 16, 2020 2:08 pm

I've scoured the forums to find a fix to my issue. However, it seems what was a fix a while ago is no longer a fix, so nothing seems to be working at the moment.

I successfully got my Pi 3B set up as a NAS server using nfs-kernel-server service with an external harddrive with the 3.2 January 2020 release of Raspbian.

The issue is nfs-kernel-server fails to load on reboot as it thinks the harddrive hasn't yet mounted. I can successfully load from command line.

I've tried multiple solutions including putting a 60 second sleep in a .conf file in /etc/systemd/system/nfs-kernel-server.service.d and adding "After" and "Requires" units to the same conf file.

What I find interesting...
When I have the sleep in the .conf file (and other items commented out), the sleep works when I start the service at the command line, but it does not sleep when the system is booting - i.e. it seems to be ignoring it. I know this because I set the time to 180 to test. As soon, as the system boots, I check the service status and it's already failed to load, although it should still be sleeping.

Any idea what's going wrong here?

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 12:24 am

25 views and no suggestions?

ronnih
Posts: 32
Joined: Wed Nov 29, 2017 8:59 am
Location: Matrix Network
Contact: Website

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 7:02 am

how looks your /etc/fstab ?
https://techguru.lima-city.de

ejolson
Posts: 6003
Joined: Tue Mar 18, 2014 11:47 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 7:17 am

fganter wrote:
Tue Mar 17, 2020 12:24 am
25 views and no suggestions?
I'm sorry. It seems like systemd is so complicated and does such astonishing things that nobody knows how to fix simple problems that come up in every non-default usage case. I would suggest adding something like

(
sleep 15;
/etc/init.d/nfs-kernel-server start
) &

to your rc.local file and avoid spending any more time to debug systemd. Sorry I can't be of more help.

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:05 am

ronnih wrote:
Tue Mar 17, 2020 7:02 am
how looks your /etc/fstab ?
like this...

proc /proc proc defaults 0 0
/dev/mmcblk0p6 /boot vfat defaults 0 2
/dev/mmcblk0p7 / ext4 defaults,noatime 0 1

The instructions I followed at https://pimylifeup.com/raspberry-pi-nfs/ didn't say anything about fstab.

epoch1970
Posts: 5727
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:20 am

Where is the external HDD? in a .mount file?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:23 am

ejolson wrote:
Tue Mar 17, 2020 7:17 am
I'm sorry. It seems like systemd is so complicated and does such astonishing things that nobody knows how to fix simple problems that come up in every non-default usage case. I would suggest adding something like

(
sleep 15;
/etc/init.d/nfs-kernel-server start
) &

to your rc.local file and avoid spending any more time to debug systemd. Sorry I can't be of more help.
no joy. :(

I tried sleep 180 just to be sure.

I've seen some posts that such rc.local is flaky since the systemd implementation.

Thanks for the suggestion though. You would think this is pretty straight-forward.

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:26 am

As I am using a drop file, is the following warning appropriate when I run "service nfs-kernel-server status" after rebooting?

Warning: The unit file, source configuration file or drop-ins of nfs-server.service changed on disk. Run 'systemctl daemon-reload' to reload units.

I successfully ran "systemctl daemon-reload" before I rebooted.

epoch1970
Posts: 5727
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:34 am

Mhh.
Does it look something like this?
viewtopic.php?t=201912#p1256033
Last edited by epoch1970 on Tue Mar 17, 2020 10:39 am, edited 2 times in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:38 am

epoch1970 wrote:
Tue Mar 17, 2020 10:20 am
Where is the external HDD? in a .mount file?
yes - media-pi-FreeAgentDrive.mount

Why do you ask?

Incidentally, I tried waiting for that mount by adding the following to an nfs-server.service.d drop file

[Unit]
Requires=media-pi-FreeAgentDrive.mount
After=media-pi-FreeAgentDrive.mount

epoch1970
Posts: 5727
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 10:39 am

TBH systemd usually succeeds at mounting local volumes it reads from fstab.
Perhaps you could use the tried and true fstab file and let systemd run its magical mount unit generator on its own...
In raspi-config the option to wait for network at boot (?) is generally helpful.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 11:00 am

epoch1970 wrote:
Tue Mar 17, 2020 10:34 am
Mhh.
Does it look something like this?
viewtopic.php?t=201912#p1256033
I'm not sure what "it" you are referring to.

systemd is already mounting the drive. The problem is that it doesn't mount before nfs service starts up.

Am I missing something in that article maybe?

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 11:04 am

epoch1970 wrote:
Tue Mar 17, 2020 10:39 am
TBH systemd usually succeeds at mounting local volumes it reads from fstab.
Perhaps you could use the tried and true fstab file and let systemd run its magical mount unit generator on its own...
In raspi-config the option to wait for network at boot (?) is generally helpful.
Yes, wait for network is already configured.

What specifically would you like me to do with fstab?

epoch1970
Posts: 5727
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 11:14 am

Try removing your .mount unit file and adding a line in fstab that mounts your usb volume to the local filesystem.
Be sure to include options nofail,defaults,auto in the mount point specification.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Tue Mar 17, 2020 12:16 pm

epoch1970 wrote:
Tue Mar 17, 2020 11:14 am
Try removing your .mount unit file and adding a line in fstab that mounts your usb volume to the local filesystem.
Be sure to include options nofail,defaults,auto in the mount point specification.
I apologize for my ignorance, as it's been a long time since I've worked with linux.

Would you be able to help me understand how to specifically do that with raspbian?

ronnih
Posts: 32
Joined: Wed Nov 29, 2017 8:59 am
Location: Matrix Network
Contact: Website

Re: NFS Server not loading after reboot

Thu Mar 19, 2020 9:13 am

adding a line in the file /etc/fstab by using a text editor like nano. You need superuser power so you need the sudo command.

Code: Select all

sudo nano /etc/fstab
or another more easy way without commandline you can on the raspbian Desktop use the key Alt + F2 and enter

sudo leafpad /etc/fstab

then you musst add a new line for you NFS share. On the follwoing link you will find a simillar post.

viewtopic.php?f=66&t=222880
https://techguru.lima-city.de

fganter
Posts: 19
Joined: Sun Jan 24, 2016 2:05 am

Re: NFS Server not loading after reboot

Thu Mar 19, 2020 11:29 pm

Since it doesn't appear systemd is functioning the way it should, I went the easy route and created a batch file to run after boot - starts the nfs service after a 60 second delay. That seems to be working.

If I get time, I try the fstab stuff later.

Thanks everyone for your help.

DimoJ
Posts: 2
Joined: Sat May 23, 2020 6:10 pm

Re: NFS Server not loading after reboot

Sun Jun 21, 2020 9:23 am

fganter wrote:
Thu Mar 19, 2020 11:29 pm
Since it doesn't appear systemd is functioning the way it should, I went the easy route and created a batch file to run after boot - starts the nfs service after a 60 second delay. That seems to be working.

If I get time, I try the fstab stuff later.

Thanks everyone for your help.
Please... Can you say more about it since I'm beginner and I struggle with same problem.
What is the name of that file?
What is the content of the file?
Where did you put that file?
How do you call that file to be executed after boot?

Return to “Raspberry Pi OS”