Can't mount samba share on Clear Linux server

I have added what seems to be the needed bundle to get samba share mounted (swupd bundle-add storage-utils), and I have added an fstab file at /etc/fstab. The fstab record is being picked up at boot, but shows “failed” when I run “sudo systemctl list-units *.mount”. The fstab entry is the same as all my Ubuntu servers that mount the share just fine: “//192.xxx.xxx.xxx/X9-SAMBA /media/share cifs guest,uid=1000,iocharset=utf8, 0 0”

Any help greatly appreciated.

Should be more details available via systemctl status '*.mount' or journalctl -u '*.mount'.

1 Like

Thank you btwarden. journalctl -u ‘*.mount’ reveals:

Oct 01 16:33:20 X9DRI-ONE systemd[1]: Mounting /media/share...
Oct 01 16:33:20 X9DRI-ONE mount[683]: mount error(101): Network is unreachable
Oct 01 16:33:20 X9DRI-ONE mount[683]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Oct 01 16:33:20 X9DRI-ONE systemd[1]: media-share.mount: Mount process exited, code=exited, status=32/n/a
Oct 01 16:33:20 X9DRI-ONE systemd[1]: media-share.mount: Failed with result 'exit-code'.

OK. dmesg reveals that fstab appears to try mounting the share before the network is connected. Running ‘sudo mount -a’ mounts the drive fine after boot. I have added ‘x-systemd.after=network-online.target’ and ‘_netdev’ to the fstab entry, but it does not fix the problem.

I’m almost there but can’t find the Clear Linux way to resolve this.

I’ve encountered this issue twice. The first time it was solved, so I removed the workaround again. Recently the issue is back, so I did the workaround again.
Not sure if it is the best Clear Linux way to resolve it, but this worked

From my logs.

Mon 11 Nov 22:00:25 CET 2019
sudo systemctl disable NetworkManager
sudo systemctl enable NetworkManager
sudo cp /usr/lib/systemd/system/NetworkManager-wait-online.service /etc/systemd/system/
sudo vi /etc/systemd/system/NetworkManager-wait-online.service
change: ExecStart=/usr/bin/nm-online -s -q --timeout=30
into : ExecStart=/usr/bin/nm-online -q --timeout=30
(-s does not wait for IP address which I need for NAS connection)

Sat 7 Mar 23:49:54 CET 2020
removing change from Mon 11 Nov 22:00:25 CET 2019
rm /etc/systemd/system/NetworkManager-wait-online.service
also remove stuff that was generated due to that change at the first reboot:
rm -r network-online.target.wants/ dbus-org.freedesktop.nm-dispatcher.service
nas drives now mount again automatically

Tue 20 Sep 23:17:26 CEST 2022
NAS volumes do not mount automatically anymore so, again:
sudo cp /usr/lib/systemd/system/NetworkManager-wait-online.service /etc/systemd/system/
sudo vi /etc/systemd/system/NetworkManager-wait-online.service
change: ExecStart=/usr/bin/nm-online -s -q
into : ExecStart=/usr/bin/nm-online -q
(-s does not wait for IP address which I need for NAS connection)

2 Likes

@Tidda Thank you so much! This worked perfectly.

1 Like

As you can see, determining when the network is finally available is tricky.

You can use systemctl edit NetworkManager-wait-online.service or systemctl edit --full NetworkManager-wait-online.service to make this edit a little bit easier.

Note that with the first form (partial override), you just need to clear and redefine ExecStart like this (ref: systemd - ArchWiki):

[Service]
ExecStart=
ExecStart=/usr/bin/nm-online -q

With the second form, you get the entire original file in an editor and make the change directly, but this will mask any other changes we make to the original service file.

More on systemctl edit: systemctl

1 Like

Thanks for the further explanation Brett. I think I tried the “systemctl edit” on this back in 2019, but got confused as I didn’t use “–full” and probably tripped over the “clear first, then set a new value” method, so I went the old-school vi the config files way.

Anyway, I’ll correct my change to use partial override.

Edit: After doing the change I discovered why I didn’t use the “appropriate way”. It was the nano editor that kicked in when using “systemctl edit”. Resolved that with method 1 from here