LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-06-2016, 11:24 AM   #1
JackDinn
Member
 
Registered: May 2015
Posts: 236

Rep: Reputation: Disabled
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.

Last edited by JackDinn; 11-06-2016 at 12:07 PM.
 
Old 11-06-2016, 12:35 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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).
 
Old 11-06-2016, 12:58 PM   #3
JackDinn
Member
 
Registered: May 2015
Posts: 236

Original Poster
Rep: Reputation: Disabled
sorry but how do i do that ? im pretty sure i am using networkmanager though.

Last edited by JackDinn; 11-06-2016 at 01:18 PM.
 
Old 11-06-2016, 01:12 PM   #4
JackDinn
Member
 
Registered: May 2015
Posts: 236

Original Poster
Rep: Reputation: Disabled
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

Last edited by JackDinn; 11-06-2016 at 01:25 PM. Reason: update
 
Old 11-06-2016, 03:05 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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).

Last edited by jpollard; 11-06-2016 at 03:07 PM.
 
Old 11-06-2016, 03:11 PM   #6
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,330

Rep: Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579Reputation: 1579
try adding this to fstab: x-systemd.requires=network-online.target
 
Old 11-06-2016, 03:17 PM   #7
JackDinn
Member
 
Registered: May 2015
Posts: 236

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-06-2016, 04:26 PM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by JackDinn View Post
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.
 
Old 11-06-2016, 04:37 PM   #9
JackDinn
Member
 
Registered: May 2015
Posts: 236

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-06-2016, 05:07 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
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
 
Old 11-06-2016, 05:12 PM   #11
JackDinn
Member
 
Registered: May 2015
Posts: 236

Original Poster
Rep: Reputation: Disabled
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
 
Old 11-06-2016, 06:14 PM   #12
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by JackDinn View Post
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.
 
Old 11-06-2016, 06:32 PM   #13
JackDinn
Member
 
Registered: May 2015
Posts: 236

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-06-2016, 06:50 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
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.
 
Old 11-06-2016, 07:27 PM   #15
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by michaelk View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fstab doesnot mount NAS at boot (Not Solved) miros84 Linux - Software 8 01-17-2013 01:27 PM
NFS share in fstab fails to mount, but where is the log? gumpish Linux - Software 7 08-19-2009 07:22 PM
Why unable to mount my nas in fstab get "mount error(5) Input/output error fi5ban Linux - Networking 0 04-01-2009 10:42 AM
fstab problem: mount: can't find dvd in /etc/fstab or /etc/mtab Nikon01 Slackware 5 11-17-2006 06:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration