2

I have a raspberry pi humming along happily. I'd like it to mount an NFS directory and so I've set up an /etc/fstab rule:

192.168.1.4:/media /mnt/media nfs rw,auto,hard,intr

The directory exists locally and remotely. sudo mount -a as the "pi" user mounts it with no fuss.

My problem is that the directory does not seem to mount automatically if I reboot the pi. I don't want to boot off this directory or anything, I just want it to come up when I do boot.

Any ideas what I'm doing wrong here or possibly any pointers of things I should be looking at?

  • 1
    The problem is almost certainly due to the fact that the network interface is not initialised at the time fstab is executed. Many other seem to have similar problems, particularly with WiFi network. I suggest you put in a script that runs at log on time. – Milliways Mar 3 '14 at 0:46
  • In my case, the network is ethernet, not WiFi. A login script won't work in my use case as I want a script at startup to be able to access the mount rather than a user logging in. I was unsure at what point the mount would be guaranteed available otherwise the startup script could handle this. I was worried that even if the startup script seemed to work, it may depend on a race condition that wouldn't always work. – Gregable Mar 4 '14 at 4:11
4

A quick and dirt hack would be to edit /etc/rc.local and add "mount /mnt/media". This will automatically be carried out on boot. The correct way, I think, would be to add the nfs-common init script to the default runlevel. This can be done by using the update-rc.d command.

sudo update-rc.d nfs-common enable
  • I tried your 'correct way' and it appears to do the trick. – Gregable Mar 4 '14 at 4:18
2

I had the same problem as you. In my case, running

sudo raspi-config

and selecting Wait for network at boot/Yes did the trick.

  • After doing what fred suggested and not having any joy I tried this and it worked! Thanks. – d347hm4n Feb 26 at 15:03
1

Another option (requiring a little more work) that you may want to look into is AutoFS. AutoFS will allow you to configure mount points such that they are mounted automatically when the mount point is accessed and unmounted after some time of inactivity. When using this with NFS it can help you reduce your network traffic by only keeping that connection open when it's needed.

http://greenfly.org/tips/autofs.html

http://linux.die.net/man/5/autofs

0

I had a similar problem. Try the following solution, the last step might be what you want,

Get the uuid of the external hard drive with following command

sudo blkid

Add the entry into fstab so that when you restart the raspberry device it is auto mounted every time

sudo nano /etc/fstab

UUID=0A423D084xxxxxx /mnt/data ntfs defaults,noatime,auto 0 0

Some explanation for above command - I mounted it to /mnt/data directory. ( You need to create it first if doesn't exist with sudo mkdir /mnt/data ) Mine was a NTFS format. You might try only the defaults option. I added noatime and auto to experiment a few things. You can check more details about it on internet.

Some Raspberry device ( including mine ) needs one more addition ( optional, try only if above doesn't work ), after above command, add a 5 seconds delay to loading the device as sometimes the Raspberry OS loads faster than external drive and external hard drive loads a little slower and need more time to start, in this case the external drive isn't auto mounted and it is skipped with an error at the start. Add the following property/value to the end of your cmdline.txt inside /boot folder

sudo nano /boot/cmdline.txt

Add

rootdelay=5

Hope it helps!

  • blkid is not applicable to mounting a remote filesystem via nfs. – Ghanima Oct 8 '18 at 22:38
0

I found an answer here:

https://discourse.osmc.tv/t/nfs-kernel-server-wont-start-on-boot/5936/18

From the user "mandelsoft"

Create this file: /etc/systemd/system/nfs-kernel-server.service.d/10-dep.conf

And within it:

[Unit]
Requires=rpcbind.service
After=rpcbind.service

I'm running on MATE for the pi. So other OSes may give you different results, but on my system at least, this fixes the problem reliably.

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.