I have been all over the web looking for an answer for this. Essentially, I have a network drive mounted via /etc/fstab and works pretty well via 'mount -a'. However, I won't mount after restart.
This seems to be a common issue that has to do with fstab doing the mount before the network is available. Tried this putting this script on init.d as suggested in one of the post in stackexchange:
------------------------------
#! /bin/sh
# /etc/init.d/mountscript
### BEGIN INIT INFO
# Provides: Mounting of all drives
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to mount drives at boot
# Description: Added 30jan 2014
### END INIT INFO
#Now mount all drives
sudo mount -a
echo "All drives mounted"
----------------------------------------------------------------
Tested it with the following which works fine:
sudo /etc/init.d/mountscript start
...and finalled registered the script to be run at start-up:
sudo update-rc.d mountscript defaults
Everything seems to check well until I did a restart and the drive is not yet mounted. Starting the script manually mounted back the drive. This one seems to work fro most people but does not seem to work for me. I am running on Raspbian Jessie 4,1 with the latest updates,
Would appreciate some wisdom,
Thanks!
Erik
- DougieLawson
- Posts: 42155
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Network drive on fstab does not mount on start-up
Have you added to the lines in /etc/fstab? Try that and you won't need your script running at boot time.
Code: Select all
,x-systemd.automount
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Network drive on fstab does not mount on start-up
Thanks for the reply. I disabled the script and modified /etc/fstab as follows. but still does not mount in startup:
----------------------------------
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
//thisisoffline/seagate\040backup\040plus\040drive /media/networkshare/seagatedrive cifs guest 0 0 ,x-systemd.automount
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
---------------------------------------------------------
----------------------------------
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
//thisisoffline/seagate\040backup\040plus\040drive /media/networkshare/seagatedrive cifs guest 0 0 ,x-systemd.automount
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
---------------------------------------------------------
Re: Network drive on fstab does not mount on start-up
It just needs a little re-arranging to get everything in the right column.
Code: Select all
//thisisoffline/seagate\040backup\040plus\040drive /media/networkshare/seagatedrive cifs guest,x-systemd.automount 0 0
-
- Posts: 20
- Joined: Tue Aug 13, 2013 2:52 pm
Re: Network drive on fstab does not mount on start-up
I had the same problem with a recent project; network drives would not mount from fstab. Even in a script started at startup (init.d) they wouldn't. Running the script manually (after boot up) worked. As did, as you say, mount -a (when I had the mount in the fstab) Searching the web suggested what was called a 'race condition' - basically the Pi boots more quickly than the network is recognised.
The way I got around it was to code a simple 'sleep 10' into my script. Not ideal but it worked.
I noted that in the recent Raspbian Jessie image, the rasp-config utility has the option to have the Pi boot process wait for network. Maybe it's always been there, I don't know, but it's worth a look.
The way I got around it was to code a simple 'sleep 10' into my script. Not ideal but it worked.
I noted that in the recent Raspbian Jessie image, the rasp-config utility has the option to have the Pi boot process wait for network. Maybe it's always been there, I don't know, but it's worth a look.
- rubikwizard
- Posts: 95
- Joined: Tue Jan 10, 2012 10:37 pm
- Location: West Yorkshire
Re: Network drive on fstab does not mount on start-up
This works really well, and worth a try.I noted that in the recent Raspbian Jessie image, the rasp-config utility has the option to have the Pi boot process wait for network.
Re: Network drive on fstab does not mount on start-up
Code: Select all
//thisisoffline/seagate\040backup\040plus\040drive /media/networkshare/seagatedrive cifs guest,x-systemd.automount 0 0
Thanks to all!
Cheers!
Erik
Re: Network drive on fstab does not mount on start-up
Hello,
sorry to late reply, but i had the same problem and this is how i solve it:
first give permission to your mount point:
then, write the line below in the fstab:
username and password parameters are credentials of you network drive, in my case, its a FTP from my router (a USB pendrive)
pay attention on the sec=ntlm parameter, this make all the difference for me
this is it, reboot your raspberry and see it works =]
sorry to late reply, but i had the same problem and this is how i solve it:
first give permission to your mount point:
Code: Select all
sudo chown -R pi:pi /mnt/HD1
sudo chmod -R 775 /mnt/HD1
sudo setfacl -Rdm g:pi:rwx /mnt/HD1
sudo setfacl -Rm g:pi:rwx /mnt/HD1
Code: Select all
//192.168.0.111/myNetworkFolder /mnt/HD1 cifs username=MyUsr,password=MyPass,sec=ntlm,uid=pi,gid=pi,_netdev,xsystemd.automount 0 0
pay attention on the sec=ntlm parameter, this make all the difference for me
this is it, reboot your raspberry and see it works =]