Attaching a Samba Share at Startup / fstab
July 5, 2016
Posted by on
Working through the efforts to install my Raspberry Pi (RPi) with camera and pi-timolo, I ran across a problem getting attached to the SAMBA share on the PiNAS, before the application starts up and then tries to send pictures to the share. Remember that the base instructions show how to set the program to start on boot ( init.d & update-rc.d setup ), but I was finding I had a failure to write due to the fact that the NAS share was not in my mounted devices list.
I found several sources on the web where people were updating their fstab to mount the drive on boot. But when I rebooted the RPi, then queried with ‘df -h’, my NAS share would not show up. I could force a manual mount (‘sudo mount -a) and it worked. I researched through google, and found several pieces of advice, but nothing seemed to work for my specific situation. Then I came across this page mount through fstab which had the information that matched my environment exactly.
So, I edit /etc/fstab (make sure you make a backup first!!!)
Adding this line (change to match your environment):
//10.0.0.15/Data/Pictures/motion2 /home/pi/pi-timolo/MyNAS cifs guest,_netdev
cifs is the notation the refers to a Samba share; guest in my case is the credentials for a share that is completely open (not recommenced) and the key component that fixed my problem: ‘_netdev‘, which tells the system to wait for the network binding to connect before trying to attach to the NAS.
This worked for me, your mileage may vary!