2

Problem: Server boots 3 minutes, Raspberry Pi boots 30 seconds. After a power outage, RPi boots faster and does not mount the NAS disk.

This particular RPi needs disk to be able to record to it. Hence without the (external) disk mounted, RPi is useless. I was using RPi autostart.sh to:

mount -t nfs 192.168.1.5:/Public/Video/TV /storage/nas -o nolock;

when I realised this problem. So, I created a loop in RPi's autostart.sh where I mount NAS. During normal operation (once the mount is achieved) this problem can not occur any more: should only one of them reboot, RPi mount will work OK (I think).

Would this be a good solution (executed only at RPi startup) and could it be done better or more elegantly?

until mountpoint -q /storage/nas || mount -t nfs 192.168.1.5:/Public/Video/TV /storage/nas -o nolock; do sleep 30; done

This should not try to mount if allready mounted, and otherwise - mount. Plus, wait for a retry until mounted. Seems to work as intended, except that RPi will boot (not WAIT for mount) but this RPi (actually Kodi) will be frozen until NAS is mounted.

Only thing I can see colud be added here is: send WOL to NAS prior to sleep.

Clarification: This is OPENelec RPi instllation, and there is fstab not used, but the method desribed above.

3

You can try adding the bg mount option for nfs, if you have it. man 5 nfs:

If the bg option is specified, a timeout or failure causes the mount(8) command to fork a child which continues to attempt to mount the export. The parent immediately returns with a zero exit code. This is known as a "background" mount.

  • No man on RPi, but seems like better solution than mine. Mine works, but I would prefer it done elegantly. – Pila May 20 '16 at 18:27
0

Are you really using a shell script and not fstab to mount your drives at boot ?

Read up on /etc/fstab (run the command man fstab) and in particular, look at the _netdev option, so you end up with something like.

10.10.10.10:/srv/share /mnt/mymnt   nfs4    defaults,noexec,nosuid,_netdev,auto     0       0

Disclaimer: Do not copy paste the above without first reading up on fstab !

P.S. Depending on your OS, nobootwait may also be worth exploring as an option.

P.S.P.S. See also mount options in nfs(5)

  • This is supposed to be a correct (old fashioned) way for Raspberry. But, I will check your suggestion. Hmm, # man fstab prints out: -sh: man: not found – Pila May 20 '16 at 18:17
  • Interesting... just checked on a "toy" Pi I've got here, /etc/fstab exists and man fstab returns the expected output ? – Little Code May 20 '16 at 18:28
  • According to mount(8) _netdev just prevents the system from booting until networking has been enabled. If the NFS server takes longer to boot than the client, there's a good chance the client will enable networking before the NFS server is up. – Henrik May 20 '16 at 18:28
  • @Henrik, my man page says of _netdev "used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system" – Little Code May 20 '16 at 18:30
  • @LittleCode Mine says the same, but my point is that it might not be enough, because "network has been enabled on the system" is in no way correlated to "NFS server being up". – Henrik May 20 '16 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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