View previous topic :: View next topic |
Author |
Message |
lekto Apprentice
Joined: 20 Sep 2014 Posts: 170 Location: Ancient Rome
|
Posted: Tue Jan 02, 2018 8:18 pm Post subject: [SOLVED] Samba, error(101): Network is unreachable |
|
|
Hi, I have issue with auto mounting samba shares. Shares aren't mounted on boot, but I can mount them manually by run "mount -a". It's possible that openrc try to mount shares before connecting to network?
/etc/fstab
Code: | //dedyk/transmission /media/lekto/transmission cifs vers=3.0,credentials=/root/.credentials 0 0
//dedyk/backup /media/lekto/backup cifs vers=3.0,credentials=/root/.credentials 0 0 |
/var/log/rc.log
Code: | * Mounting network filesystems ...
mount error(101): Network is unreachable
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mount error(101): Network is unreachable
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
* Could not mount all network filesystems |
dmesg
Code: | [ 30.887392] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 30.986346] CIFS VFS: Error connecting to socket. Aborting operation.
[ 30.986349] CIFS VFS: cifs_mount failed w/return code = -101
[ 30.988093] CIFS VFS: Error connecting to socket. Aborting operation.
[ 30.988095] CIFS VFS: cifs_mount failed w/return code = -101
(…)
[ 33.854946] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready |
Last edited by lekto on Mon Jan 08, 2018 8:25 pm; edited 1 time in total |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Tue Jan 02, 2018 9:19 pm Post subject: |
|
|
See the comments in /etc/conf.d/netmount and configure it appropriately. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21431
|
Posted: Wed Jan 03, 2018 12:15 am Post subject: |
|
|
Those shares are (attempted to) mount on boot, which is your problem. You did not mark them as _netdev, so localmount attempts to mount them, which fails because localmount runs before the network is started. You should mark them as _netdev to prevent mounting them before the network starts. You may also need to follow Ant P.'s instructions to get them to mount once network is available. |
|
Back to top |
|
|
lekto Apprentice
Joined: 20 Sep 2014 Posts: 170 Location: Ancient Rome
|
Posted: Mon Jan 08, 2018 8:25 pm Post subject: |
|
|
I edited netmount and added _netdev, but it sometimes worked and sometimes not. Then I haved realized I forgot to run net.eth0 and after fix it samba shares work well. |
|
Back to top |
|
|
lekto Apprentice
Joined: 20 Sep 2014 Posts: 170 Location: Ancient Rome
|
Posted: Thu Jan 21, 2021 2:47 pm Post subject: |
|
|
I'm writing here because this doesn't work anymore for me after switching network management to dhcpcd [1]. I had problem with dhcpcd that it was taking too long to get network configuration, which was delaying start of xdm. Now there is no delay during boot, but network starts working few seconds after start of xfce and samba shares are not mounted.
I got this in dmesg:
Code: | [ 22.517890] CIFS: Attempting to mount //dedyk/transmission
[ 22.517920] CIFS: VFS: Error connecting to socket. Aborting operation.
[ 22.517922] CIFS: VFS: cifs_mount failed w/return code = -101
[ 22.518849] CIFS: Attempting to mount //dedyk/backup
[ 22.518879] CIFS: VFS: Error connecting to socket. Aborting operation.
[ 22.518880] CIFS: VFS: cifs_mount failed w/return code = -101
[ 25.517359] igb 0000:05:00.0 eth0: igb: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX |
/etc/conf.d/netmount:
/etc/fstab:
Code: | //dedyk/transmission /media/lekto/transmission cifs vers=3.0,_netdev,credentials=/root/.credentials 0 0
//dedyk/backup /media/lekto/backup cifs vers=3.0,_netdev,credentials=/root/.credentials 0 0 |
[1] https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD |
|
Back to top |
|
|
lekto Apprentice
Joined: 20 Sep 2014 Posts: 170 Location: Ancient Rome
|
Posted: Thu Jan 28, 2021 6:07 pm Post subject: |
|
|
Ok, I kludged it, in /etc/init.d/netmount I added in depend():
and in start():
Code: | ebegin "Waiting for network connection"
for i in `seq 30`; do
echo -n "."
sleep 1
ping -c1 192.168.0.1 &>> /dev/null
if [ "$?" == "0" ]; then
ebegin "Network seems to work"
break
fi
done |
|
|
Back to top |
|
|
lekto Apprentice
Joined: 20 Sep 2014 Posts: 170 Location: Ancient Rome
|
Posted: Mon Jun 21, 2021 1:02 pm Post subject: |
|
|
Well, sometime after my last post that method stopped working. Recently I came up with this:
Code: | #!/bin/sh
function loop {
local program_name="delayed-mounter"
for i in $(awk '/cifs/ {print $2}' /etc/fstab); do
echo $program_name: trying to mount $i > /dev/kmsg
while [ -z "$(mount | grep $i)" ]; do
mount $i
sleep 5
done
echo $program_name: $i is mounted, continue > /dev/kmsg
done
echo $program_name: everything was mounted, exiting > /dev/kmsg
}
loop&
|
To use it put it in /etc/local.d/delayed-mounter.start, give it execute permission and add local to default runlevel. This script is looking for line with cifs in /etc/fstab in second column and trying to mount it one by one until it was successfully mounted. There are some improvements that can be added:
- Ignoring lines that are comments (starts with "#"),
- It trying to mount share until it's mounted, so it can stuck. It could be fixed by creating separate thread for every mount,
- Checking it share was mounted properly could be better. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21431
|
Posted: Mon Jun 21, 2021 6:55 pm Post subject: |
|
|
That script will mount any line that has cifs anywhere in it: Code: | $ printf 'The scifs are here.\n' | awk '/cifs/ {print $2}'
scifs
$ printf 'Open the door; the scifs are here.\n' | awk '/cifs/ {print $2}'
the | Polling like that is generally bad. Why not use a dhcpcd hook to mount the filesystems after the network is up? Add noauto to the mount options. Create a dhcpcd hook in /lib/dhcpcd/dhcpcd-hooks. The example in /usr/share/dhcpcd/hooks/29-lookup-hostname looks like a good starting point. When the interface is brought up, bring up all the cifs filesystems, which you can more cleanly list using findmnt: Code: | findmnt --fstab -t cifs --output TARGET --noheadings |
|
|
Back to top |
|
|
|