LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can't get a CIFS network drive to mount on boot (https://www.linuxquestions.org/questions/linux-newbie-8/cant-get-a-cifs-network-drive-to-mount-on-boot-4175550771/)

gooner47 08-14-2015 12:57 PM

Can't get a CIFS network drive to mount on boot
 
I have added a share in fstab to access a network drive with all my files on... fstab looks like:

Code:

proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
//192.168.1.73/disk1 /media/disk1 cifs username=pi,password=raspberry,_netdev,uid=1000,gid=1000,iocharset=utf8, 0 0
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that

When I run sudo mount -a the network drive mounts successfully and I can do cd /media/disk1 then ls which correctly gives me a list of all the folders on said network drive.

However, after rebooting the pi when I cd to that location and run ls again, nothing is there. I have to manually run sudo mount -a again, which then mounts the drive.

I have seen this reported many times, and the consensus seems to be that the mounts in fstab are happening too early - before the network has been established. I've tried to implement the things I understand - but to be honest a lot of it is way over my head. I've added _netdev to the line in fstab, I've added rootdelay=10 into /boot/cmdline.txt, I've installed networkmanager... none of this has helped.

And so I turn to you, about ready to throw the pi out the window - followed by myself. Any help, much appreciated.

ferrari 08-14-2015 08:12 PM

The '_netdev' option is not always sufficient for slow networks. In particular, if Network Manager is involved, and systemd there can be problems. So, you might want to tell us the OS and version. Are you using Network Manager? There are solutions for coping with that situation.

There are a number of possible options (depending on answers to the above). Anyway, 2 to start with...

1. You could try adding the 'noauto' option, so that the samba mounting does not occur at boot, but later on. For example, add the mount via /etc/rc.local
Code:

mount /media/disk1
exit 0

2. I recall an old openSUSE thread where it was suggested to remount via crontab.

Ztcoracat 08-14-2015 08:16 PM

Hi & Welcome to Linux Questions.

Sorry you have to keep running the mount -a cmd over and over again.

I'm sure there is a way to make this permanent but I don't have experience with that. I think you need udev.
http://linuxconfig.org/automatically...ve-with-autofs

Don't throw your pi out the window and most certainly don't even think of jumping out yourself.
-::-Hang in there gooner47 until a member with more experience can chime in to help you.-::-

*You might want to include what distribution you are using and post the output of lsusb to see if the device is showing up.*

In the meantime look here.
https://wiki.archlinux.org/index.php...torage_devices

ferrari 08-14-2015 08:24 PM

@Ztcoracat: The NAS is not a usb device, it's on the network. The network isn't available when the fstab mounting takes place, so it must be delayed.

Ztcoracat 08-14-2015 08:36 PM

Quote:

Originally Posted by ferrari (Post 5405972)
@Ztcoracat: The NAS is not a usb device, it's on the network. The network isn't available when the fstab mounting takes place, so it must be delayed.

Ok, thanks-

How do you delay the process?

ferrari 08-14-2015 08:50 PM

That can depend on the init system and the network manager in use. The crontab approach (mentioned above) does work for some. Others use auofs to do the mounting.

Where systemd is employed, it is possible to use the x-systemd.automount option

http://www.freedesktop.org/software/...emd.mount.html
https://wiki.archlinux.org/index.php....2Fetc.2Ffstab

For those using system and Network Manager, there is the NetworkManager-wait-online.service freedesktop

http://www.freedesktop.org/wiki/Soft...NetworkTarget/
https://wiki.archlinux.org/index.php...er_Wait_Online

Although I have no experience (or need) with using this.

ferrari 08-14-2015 09:02 PM

Similar thread here

http://raspberrypi.stackexchange.com...as-drive-fails

where a script runs 'mount -a' later in the boot process.

If necessary, an additional delay can be included using the sleep command eg 'sleep 10'

Ztcoracat 08-14-2015 09:15 PM

Good links ferrari; thanks.

Quote:

Although I have no experience (or need) with using this.
Ditto:-

If I'm not mistaken systemd has some control over the start and stop services so it may not be a walk in the park to make the delay happen. I'll re-read the links you posted.:)

Ztcoracat 08-14-2015 09:24 PM

It looks like it boils down to this:
Code:

If you use NetworkManager you can do this by enabling NetworkManager-wait-online.service:

systemctl enable NetworkManager-wait-online.service

If you use systemd-networkd you can do this by enabling systemd-networkd-wait-online.service:

systemctl enable systemd-networkd-wait-online.service

Sorry gooner47 I'm not good with NAS and the process by which you'd have to set up to make it work.

gooner47 08-25-2015 03:01 PM

Firstly apologies for the time taken to respond to this thread, I've literally only just had time to sit down and have a play around with this again.

Secondly thanks for all your input and help.

In the end, I followed some very clear instructions provided in a response to another post I made elsewhere:

http://raspberrypi.stackexchange.com...-mount-on-boot

Thanks again for all your help.

ferrari 08-25-2015 04:04 PM

Very good.... that uses the crontab method to re-mount as I suggested in post #2. :)


All times are GMT -5. The time now is 02:41 AM.