在建立线保护连接后,我正在尝试安装 SMB 共享。因此我做了以下事情:
- 创建了一个wireguard配置
- 使 systemd 在启动时启动连接
systemctl enable [email protected]
- 将以下条目添加到 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
重新启动后,网络共享未挂载。知道 fstab 中的每个条目都转换为 systemd-unit 后,我检查了 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.
查看dmesg
提供了以下信息:
[ 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
基于关于stackoverflow 的以下问题,我假设 115 表示“进行中”。如果wireguard vpn连接没有启动,我也看到了同样的行为。
查看生成的单元文件:
# 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
如果我mount -a
在登录后运行,一切都会按预期进行。所以我认为这是单位之间的时间问题。因此,我还创建了一个自己的 systemd 单元并从 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
将其移至/etc/systemd/system/mnt-smb.mount
并通过 激活它systemctl enable mnt-smb.mount
。这适用于一次重新启动,但在下次重新启动后停止工作。
问题:
- 如何解决这个时间问题?
- 可以在单元文件或 fstab 中使用哪些 systemd 选项?
我怀疑wireguard的接口设置还没有准备好只是因为服务启动了。您的问题可能与此有关,在这种情况下,解决方案是等待虚拟设备。