For those running wifi, sometimes that connection takes a little bit more time to actively connect on boot.
If you have a external NAS setup in /etc/fstab to automount, it may sporadically do so because of the slightly delayed wifi connections.
Since rc.local.service is now handled through systemd, you can manually create a delay script by creating a rc.local file in the /etc directory. By additionally making this file executable, it will be pulled automatically into the multi-user.target service. Systemd will handle execution of the rc.local delay script.
In a terminal window…
printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local
sudo reboot
After a reboot, return to terminal and…
sudo gedit /etc/rc.local
Go ahead and paste the paste the following script in that file, then save…
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
#GS notes: a *minimum* of sleep 10 is required for the mount below to work on the Pi 3; it failed with sleep 5, but worked with sleep 10, sleep 15, and sleep 30
sleep 10
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
mount -a #GS: mount all drives in /etc/fstab
fi
exit 0
You shouldn’t need to change any info, other than tailor the sleep time to your preference. This should create an automount delay of a time period of your choice, so that there are consistently automounted drives (fstab) while using wifi.
Links to the original articles…
https://askubuntu.com/questions/886620/how-can-i-execute-command-on-startup-rc-local-alternative-on-ubuntu-16-10
https://askubuntu.com/questions/399643/cifs-mount-through-fstab-not-mounting-at-boot
GM