Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Samba, error(101): Network is unreachable
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 170
Location: Ancient Rome

PostPosted: Tue Jan 02, 2018 8:18 pm    Post subject: [SOLVED] Samba, error(101): Network is unreachable Reply with quote

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
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Tue Jan 02, 2018 9:19 pm    Post subject: Reply with quote

See the comments in /etc/conf.d/netmount and configure it appropriately.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21586

PostPosted: Wed Jan 03, 2018 12:15 am    Post subject: Reply with quote

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
View user's profile Send private message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 170
Location: Ancient Rome

PostPosted: Mon Jan 08, 2018 8:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 170
Location: Ancient Rome

PostPosted: Thu Jan 21, 2021 2:47 pm    Post subject: Reply with quote

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:
Code:
rc_need="dhcpcd"


/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
View user's profile Send private message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 170
Location: Ancient Rome

PostPosted: Thu Jan 28, 2021 6:07 pm    Post subject: Reply with quote

Ok, I kludged it, in /etc/init.d/netmount I added in depend():
Code:
after xdm

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
View user's profile Send private message
lekto
Apprentice
Apprentice


Joined: 20 Sep 2014
Posts: 170
Location: Ancient Rome

PostPosted: Mon Jun 21, 2021 1:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21586

PostPosted: Mon Jun 21, 2021 6:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum