1

I'm trying to mount an SMB-share after a wireguard connection has been established. Therefore I did the following things:

  • created a wireguard config
  • made systemd start the connection on startup systemctl enable [email protected]
  • added the following entry to fstab
//192.168.0.10/home /mnt/smb cifs [email protected],credentials=/home/user/.smbcredentials,vers=3.0,uid=user,pid=user,users,_netdev 0 0

After rebooting the network share is not mounted. With the knowledge that every entry in fstab is converted into a systemd-unit I checked the status of the unit systemctl status mnt-smb.mount.

● mnt-smb.mount - /mnt/smb
   Loaded: loaded (/etc/fstab; generated; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2022-02-09 16:55:28 CET; 1min 17s ago
    Where: /mnt/smb
     What: //192.168.0.10/home
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 496 ExecMount=/bin/mount //192.168.0.10/home /mnt/smb -t cifs -o [email protected],credentials=/home/user/.smbcredentials,vers=3.0,uid=user,gid=user,users,_netdev (code=exited, status=32)

Feb 09 16:55:28 homeserver systemd[1]: Mounting /mnt/smb...
Feb 09 16:55:28 homeserver systemd[1]: mnt-smb.mount: Mount process exited, code=exited status=32
Feb 09 16:55:28 homeserver systemd[1]: Failed to mount /mnt/smb.
Feb 09 16:55:28 homeserver systemd[1]: mnt-smb.mount: Unit entered failed state.

A look into dmesg gave the following information:

[   17.612210] Key type cifs.spnego registered
[   17.612253] Key type cifs.idmap registered
[   17.758816] wireguard: loading out-of-tree module taints kernel.
[   17.775249] wireguard: WireGuard 0.0.20191206 loaded. See www.wireguard.com for information.
[   17.775273] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
[   27.752548] CIFS VFS: Error connecting to socket. Aborting operation.
[   27.752576] CIFS VFS: cifs_mount failed w/return code = -115

Based on the following question on stackoverflow, i assume that 115 means "in progress". I have seen the same behaviour if the wireguard vpn connection was not up.

Having a look into the generated unit file:

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=remote-fs.target

[Mount]
What=//192.168.0.10/home
Where=/mnt/smb
Type=cifs
[email protected],credentials=/home/user/.smbcredentials,vers=3.0,uid=user,gid=user,users,_netdev

If I run mount -a after login, everything works as expected. So I think it is a timing issue between the units. Therefore I also created an own systemd unit and removed the entry from fstab:

[Unit]
Description=Homeserver SMB
Before=remote-fs.target
[email protected]
[email protected]

[Mount]
Type=cifs
What=//192.168.0.10/home
Where=/mnt/smb
Options=credentials=/home/user/.smbcredentials,vers=3.0,uid=user,gid=user,users

[Install]
WantedBy=multi-user.target

Moved it to /etc/systemd/system/mnt-smb.mount and activated it via systemctl enable mnt-smb.mount. This worked for one reboot, but stopped working after the next reboot.

Questions:

  • How could this timing issue be resolved?
  • What systemd options could be used in the unit file or in fstab?
0

1 Answer 1

3

I suspect the interface setup by wireguard isn't ready just because the service started. Your issue may be related to this in which case the solution is to wait for the virtual device.

After=network.target [email protected]
Requires=sys-devices-virtual-net-wg0.device
5
  • Thank you for the hint - this made it working! One more, related quesion - how could the same be accomplished without wireguard? The target network-online.target doesn't seem to work for that.
    – nioerd
    Feb 12, 2022 at 18:26
  • @nioerd See if this helps.
    – A. Que
    Feb 12, 2022 at 21:40
  • Thanks for the link. I already tried systemctl enable systemd-networkd-wait-online.service but it does not seem to change anything. Could this be caused by using dhcpcd for setting a static IP?
    – nioerd
    Feb 13, 2022 at 12:25
  • @nioerd That should have done it. Maybe try reading through this.
    – A. Que
    Feb 13, 2022 at 20:06
  • I got it working. The target network-online.target only worked for me after setting up systemd to configure the network interfaces. A good tutorial could be found here: https://raspberrypi.stackexchange.com/questions/108592
    – nioerd
    Feb 17, 2022 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .