LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   fstab fails to mount NAS (https://www.linuxquestions.org/questions/linux-networking-3/fstab-fails-to-mount-nas-4175593036/)

JackDinn 11-06-2016 11:24 AM

fstab fails to mount NAS
 
How do i delay fstab until the network is connected ?

Im trying to mount my NAS at boot. Iv added the fstab line that works on my other comp (mint17.3 cinnamon) but on this comp (mint 18 kde) it does not.

mount[3059] mount error(101): Network is unreachable

I assume the network is not connected quickly enough but now im back to scratching my head.

I tried crontab:-
@reboot sleep 10;mount nas
that didn't work.

manually typing mount nas works fine once the network is up

whats the proper way please,
thx.

EDIT:- update

man mount says

_netdev
The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).

so i tried

//192.168.2.1/volume(sda1) /home/user/nas cifs _netdev,users,username=user,password=pass,iocharset=utf8,sec=ntlm 0 0

but that didn't work either.

jpollard 11-06-2016 12:35 PM

If your system is using NetworkManager, then make sure you have "NetworkManager-wait-online" enabled. Otherwise the system can try to do a network mount before the network is really usable (and no, network.target does not ensure that).

JackDinn 11-06-2016 12:58 PM

sorry but how do i do that ? im pretty sure i am using networkmanager though.

JackDinn 11-06-2016 01:12 PM

ok i run systemctl enable systemd-networkd-wait-online.service and reboot but still fails


Quote:

06/11/2016 19:08 greg-Inspiron-5767 systemd[1] Mounting /home/greg/nas...
06/11/2016 19:08 greg-Inspiron-5767 systemd[1] Started /etc/rc.local Compatibility.
06/11/2016 19:08 greg-Inspiron-5767 kernel [ 34.098833] FS-Cache: Loaded
06/11/2016 19:08 greg-Inspiron-5767 kernel [ 34.120358] FS-Cache: Netfs 'cifs' registered for caching
06/11/2016 19:08 greg-Inspiron-5767 kernel [ 34.120442] Key type cifs.spnego registered
06/11/2016 19:08 greg-Inspiron-5767 kernel [ 34.120449] Key type cifs.idmap registered
06/11/2016 19:08 greg-Inspiron-5767 mount[3046] mount error(101): Network is unreachable
06/11/2016 19:08 greg-Inspiron-5767 mount[3046] Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
06/11/2016 19:08 greg-Inspiron-5767 systemd[1] home-greg-nas.mount: Mount process exited, code=exited status=32
06/11/2016 19:08 greg-Inspiron-5767 systemd[1] Failed to mount /home/greg/nas.
06/11/2016 19:08 greg-Inspiron-5767 systemd[1] Dependency failed for Remote File Systems.
06/11/2016 19:08 greg-Inspiron-5767 kernel [ 34.133251] CIFS VFS: Error connecting to socket. Aborting operation.
06/11/2016 19:08 greg-Inspiron-5767 kernel [ 34.133300] CIFS VFS: cifs_mount failed w/return code = -101
06/11/2016 19:08 greg-Inspiron-5767 systemd[1] remote-fs.target: Job remote-fs.target/start failed with result 'dependency'.
06/11/2016 19:08 greg-Inspiron-5767 systemd[1] home-greg-nas.mount: Unit entered failed state.
check network services
Quote:

greg@greg-Inspiron-5767 ~ $ systemctl -l --type service --all | grep network
networking.service loaded active exited Raise network interfaces
systemd-networkd-resolvconf-update.service loaded inactive dead Update resolvconf for networkd DNS
systemd-networkd-wait-online.service loaded inactive dead Wait for Network to be Configured
systemd-networkd.service loaded inactive dead Network Service

jpollard 11-06-2016 03:05 PM

I didn't think the service was named "systemd-networkd-wait-online.service".

On my system (fedora) it is named "NetworkManager-wait-online.service".

As a verification, it should be able to be mounted manually with "mount /home/user/nas". This will verify that the mount actually works, and that the network is functioning (no firewall blocks and such).

colorpurple21859 11-06-2016 03:11 PM

try adding this to fstab: x-systemd.requires=network-online.target

JackDinn 11-06-2016 03:17 PM

yea think there are both but in my case i only have the one i used
https://www.freedesktop.org/wiki/Sof...NetworkTarget/

Ok i made a script to delay the command and stuck it in my auto-start and it actually works. No clue why the crontab does not.

linux drives me crazy but almost finished this new OS installation with everything working.

Thanks for the help and suggestions.

jpollard 11-06-2016 04:26 PM

Quote:

Originally Posted by JackDinn (Post 5627736)
yea think there are both but in my case i only have the one i used
https://www.freedesktop.org/wiki/Sof...NetworkTarget/

That is not sufficient. Systemd assumes the network is ready as soon as it starts NetworkManager, and it isn't started. That is what NetworkManager-wait-online service is for. It directs systemd to wait for a message from NetworkManager before assuming the network is actually usable.
Quote:

Ok i made a script to delay the command and stuck it in my auto-start and it actually works. No clue why the crontab does not.
The crontab doesn't work because you used the @reboot option. And since cron is being started BEFORE the network it can't work. Now if you put a delay of something like 5 minutes it might have worked.
Quote:

linux drives me crazy but almost finished this new OS installation with everything working.

Thanks for the help and suggestions.
Your problems are strictly due to the uncontrollable nature of systemd, with many interactions that are nearly invisible.

JackDinn 11-06-2016 04:37 PM

yep, exactly what i figured eventually.

iv been looking up how to run a script at login but after everything else has finished (well least the network connection), most help was saying .bash_profile, .bash_login, .profile etc but i think i need to look at the /etc/rc[0-6].d folders.

michaelk 11-06-2016 05:07 PM

Another option which will be easier then trying to write a unit file or lsb script is x-systemd.automount. It is similar to autofs where the share is automounted when accessed and unmounted after idle timeout has elapsed.

https://wiki.archlinux.org/index.php/Fstab

JackDinn 11-06-2016 05:12 PM

yea i have seen them "auto mounters/dismounters" on my travels but looked overly complicated at the time, now im looking at run levels and im thinking hmmmm

jpollard 11-06-2016 06:14 PM

Quote:

Originally Posted by JackDinn (Post 5627767)
yea i have seen them "auto mounters/dismounters" on my travels but looked overly complicated at the time, now im looking at run levels and im thinking hmmmm

Systemd doesn't have run levels.

JackDinn 11-06-2016 06:32 PM

o i wouldn't be surprised , so all this crap im trying to actually get a grasp on is obsolete as far as im concerned :( this is one of the many problems learning linux , all the changes and redundant forum posts. so i suppose RUNLEVELS is used with SysV init and im not using that im using systemd daemon.

well going to try write a script that can be started at boot but will check for my network to be connected before trying to mount. hoping it will just need a loop and a check for a connection by grep'ing something like ifconfig output, just thinking allowed.

because i really just want a permanent mount anyhow.

Cant believe there is no easy way to run a script after user login has finished loading everything, could be quite a few other things that this behavior could cause a problem with.

michaelk 11-06-2016 06:50 PM

Depends on the distribution but systemd is backwards compatible and will use the old init scripts but using unit files is the better approach.

systemd can run rc.local which is basically the last init script before the desktop starts. I would still go with x-systemd.automount.

jpollard 11-06-2016 07:27 PM

Quote:

Originally Posted by michaelk (Post 5627789)
Depends on the distribution but systemd is backwards compatible and will use the old init scripts but using unit files is the better approach.

systemd can run rc.local which is basically the last init script before the desktop starts. I would still go with x-systemd.automount.

systemd will run them... but not necessarily when they should be. THEIR order will be correct... but not necessarily in the proper order for the rest of the system. Things can get out of order.


All times are GMT -5. The time now is 03:06 AM.