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 firstname.lastname@example.org
- added the following entry to fstab
//192.168.0.10/home /mnt/smb cifs email@example.com,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 firstname.lastname@example.org,credentials=/home/user/.smbcredentials,vers=3.0,uid=user,gid=user,users,_netdev (code=exited, status=32) Feb 09 16:55:28 homeserver systemd: Mounting /mnt/smb... Feb 09 16:55:28 homeserver systemd: mnt-smb.mount: Mount process exited, code=exited status=32 Feb 09 16:55:28 homeserver systemd: Failed to mount /mnt/smb. Feb 09 16:55:28 homeserver systemd: 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 <Jason@zx2c4.com>. 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 Optionsemail@example.com,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 Afterfirstname.lastname@example.org Requiresemail@example.com [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.
- How could this timing issue be resolved?
- What systemd options could be used in the unit file or in fstab?