Help automount at boot NFS share external HDD

Hi OSMC,

I’ve updated today my old RPi1 that I use as a file server to stretch.

After that update, the external hdds physically connected on this RPi are not being mounted as a NFS share at boot.

here is the output.

systemctl status nfs-server.service

  • nfs-server.service - NFS server and services
    Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Thu 2018-01-11 21:05:49 -03; 1min 9s ago
    Process: 388 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)

Jan 11 21:05:49 osmc systemd[1]: Starting NFS server and services…
Jan 11 21:05:49 osmc exportfs[388]: exportfs: Failed to stat /media/hdd1: No such file or directory
Jan 11 21:05:49 osmc exportfs[388]: exportfs: Failed to stat /media/hdd2: No such file or directory
Jan 11 21:05:49 osmc systemd[1]: nfs-server.service: Control process exited, code=exited status=1
Jan 11 21:05:49 osmc systemd[1]: Failed to start NFS server and services.
Jan 11 21:05:50 osmc systemd[1]: nfs-server.service: Unit entered failed state.
Jan 11 21:05:50 osmc systemd[1]: nfs-server.service: Failed with result ‘exit-code’.

I can mount these hdd drivers by restarting the nfs-kernel-server.

I’m wondering what changed that is not working now?

Any help would be appreciated.

Thanks.

This are my exports:

/media/hdd1 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,insecure)
/media/hdd2 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,insecure)

it appears that at boot my external HDDs are not mounted.

Same problem happens to me with the latest OSMC upgrade (stretch).
It seems the nfs server can’t mount from /media on boot, probably because this is a temporary fs system.

thanks, for replying.

it appears that we’ll have to manually mount.

let’s hope that this issue will get the attention of the devs.

It was discussed here

Thanks for replying.

Is this a temporary issue or is it gonna be that way for now on?

Curiously this doesn’t seem to affect a samba share that I have on this same setup.

I assume it will stay this way

As it is a timing issue and the process is different that doesn’t surprise me

I will give it a try using /media

Hope it preserves the subdirectories inside.

Well would be recommended to move to /mnt as /media is only for automounts
You can use pathsubstitution if any problem with existing database

I am using the option 2 that was given. Using /media because it always exists.

/media 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,insecure)

I have encountered an issue already.

It automounted. But, I cannot go inside the HDDs. They appear as subdirectories. But I cannot go in.

At least using my RPi3 Kodi, adding a video source.

Might be a permission issue. Check ls -lah /media

ls -al /media/
total 20
drwxr-xr-x 4 root root 4096 Jan 11 22:53 .
drwxr-xr-x 23 root root 4096 Jan 11 17:07 …
-rw-r–r-- 1 root root 232 Nov 21 16:36 README
drwxrwxrwx 12 osmc osmc 4096 Jun 24 2017 hdd2
drwxrwxrwx 23 osmc osmc 4096 Jan 11 22:53 hdd1

I reversed. It is too much of a hassle.

For now, I will manually restart server every time it boots up.

please, @sam_nazarko, @fzinken, @ActionA I know it may not be up to you guys but I hope a fix comes in.

It worked perfectly on previous versions.

I can manually mount my external drive, and can manually restart the nfs-kernel-server successfully.
But it fails to mount on boot.

This is my fstab:
UUID=a1c124-8591-44124-b11b-421ifasq12e8c /mnt/usb ext4 defaults,noatim,eauto,nofail,x-systemd.mount-timeout=60 0 0

My exports:
/mnt/usb/remote *(rw,sync,no_root_squash,no_subtree_check)

service status:
    * nfs-server.service - NFS server and services
       Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Sat 2018-01-13 00:03:48 CST; 17min ago
      Process: 365 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)

    Jan 13 00:03:47 osmc systemd[1]: Starting NFS server and services...
    Jan 13 00:03:47 osmc exportfs[365]: exportfs: Failed to stat /mnt/usb/remote: No such file or directory
    Jan 13 00:03:47 osmc2 systemd[1]: nfs-server.service: Control process exited, code=exited status=1
    Jan 13 00:03:48 osmc systemd[1]: Failed to start NFS server and services.
    Jan 13 00:03:48 osmc systemd[1]: nfs-server.service: Unit entered failed state.
    Jan 13 00:03:48 osmc systemd[1]: nfs-server.service: Failed with result 'exit-code'.

Any ideas?
Thanks.

this is a typo ,noatim,eauto, should be ,noatime,auto,

I think that was a cut/paste mistake, it’s written well on my fstab file and it still fails. It works if I start it manually.

My setup is exactly like yours except I’m not trying to share a directory under the mount point. I share the mount point itself. I think that exists even before the disk has mounted, whereas your system has to wait for remote to exist before nfs can do its stuff.

That is, I’m using Option 1 of the post quoted above.

Perhaps adding our old friend noauto,x-systemd.automount to your /etc/fstab will help.

Here’s my /etc/exports:

/mnt/nfstest/testdir1 192.168.8.0/24(rw,no_root_squash,no_subtree_check)

Here’s the relevant /etc/fstab line:

UUID=bf6cd3a8-4c8d-4081-91b4-6a8d0f95093b /mnt/nfstest ext4 noatime,noauto,x-systemd.automount,x-systemd.mount-timeout=60 0 0

(I kept your x-systemd.mount-timeout)

Here’s what happened on reboot:

● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Fri 2018-01-12 17:34:57 GMT; 12min ago
  Process: 420 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 345 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 420 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

Jan 12 17:34:55 osmc systemd[1]: Starting NFS server and services...
Jan 12 17:34:57 osmc systemd[1]: Started NFS server and services.

Output from showmount:

Export list for osmc:
/mnt/nfstest/testdir1 192.168.8.0/24

Te device is just a USB pendrive. I tested with an export of the mount-point and with a subdirectory - and both worked.

1 Like

@dillthedog <- Thank you so much, this worked perfectly.

I hadn’t updated OSMC in a year, so I just did and now I’m getting this problem - NFS doesn’t work unless I manually start it once boot is completed.
I’ve tried everything I can find:

  • add “service nfs-kernel-server restart” to rc.local
  • add “@reboot service nfs-kernel-server restart” to sudo crontab
  • increased “sleep” in /etc/init.d/nfs-kernel-server
  • Add a /etc/systemd/system/nfs-kernel-server.service.d/10-dep.conf with “[Unit] requires=rpcbind.service After=rpcbind.service”

The only thing that I can get to work is logging in manually and running “sudo service nfs-kernel-server start”.

Note that I’m not actually mounting the NFS share as a drive, just using it as a source in the video library.

1 Like