我有一个 CIFS 安装,以前可以工作,但现在坏了。它仍然可以安装,sudo mount -a
但不会在启动时安装。CIFS 共享托管在 raspberry pi 4 上的 openmediavault 5 上。我没有在 OMV 日志中看到任何错误。
我的 fstab 条目如下所示:
//192.168.1.97/sharedrive /media/Nas cifs credentials=/home/brad/.smbcredentials,vers=3,_netdev,iocharset=utf8,auto,forceuid,forcegid,uid=1000,gid=5000,file_mode=0777,dir_mode=0777 0 0
DMESG 输出如下所示:
CIFS: Attempting to mount //192.168.1.97/sharedrive
CIFS VFS: Error connecting to socket. Aborting operation.
CIFS VFS: cifs_mount failed w/return code = -2
JOURNALCTL 输出如下所示:
systemd[1]: media-Nas.mount: Mount process exited, code=exited, status=32/n/a
systemd[1]: media-Nas.mount: Failed with result 'exit-code'.
systemd[1]: Failed to mount Mount CIFS Share.
任何帮助都将不胜感激。谢谢!
编辑:
输出systemctl status NetworkManager-wait-online.service
systemctl status NetworkManager-wait-online.service
● NetworkManager-wait-online.service - Network Manager Wait Online
Loaded: loaded (/lib/systemd/system/NetworkManager-wait-online.service; enabled; vendor preset: enabled)
Active: active (exited) since Fri 2021-01-29 17:42:32 EST; 43min ago
Docs: man:nm-online(1)
Process: 806 ExecStart=/usr/bin/nm-online -s -q --timeout=30 (code=exited, status=0/SUCCESS)
Main PID: 806 (code=exited, status=0/SUCCESS)
Jan 29 17:42:26 HP-Laptop systemd[1]: Starting Network Manager Wait Online...
Jan 29 17:42:32 HP-Laptop systemd[1]: Finished Network Manager Wait Online.
输出systemd-networkd-wait-online
systemctl status systemd-networkd-wait-online
● systemd-networkd-wait-online.service - Wait for Network to be Configured
Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-networkd-wait-online.service(8)
编辑2:
systemctl status systemd-networkd-wait-online
● systemd-networkd-wait-online.service - Wait for Network to be Configured
Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; enabled; vendor preset: enabled)
Active: active (exited) since Fri 2021-01-29 18:42:00 EST; 3min 54s ago
Docs: man:systemd-networkd-wait-online.service(8)
Process: 444 ExecStart=/lib/systemd/systemd-networkd-wait-online (code=exited, status=0/SUCCESS)
Main PID: 444 (code=exited, status=0/SUCCESS)
Jan 29 18:42:00 HP-Laptop systemd[1]: Starting Wait for Network to be Configured...
Jan 29 18:42:00 HP-Laptop systemd[1]: Finished Wait for Network to be Configured.
编辑3:
输出systemctl status networkd-dispatcher.service systemd-networkd.service
● networkd-dispatcher.service - Dispatcher daemon for systemd-networkd
Loaded: loaded (/lib/systemd/system/networkd-dispatcher.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-01-29 19:19:51 EST; 1min 20s ago
Main PID: 747 (networkd-dispat)
Tasks: 1 (limit: 9072)
Memory: 19.7M
CGroup: /system.slice/networkd-dispatcher.service
└─747 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
Jan 29 19:19:51 HP-Laptop systemd[1]: Starting Dispatcher daemon for systemd-networkd...
Jan 29 19:19:51 HP-Laptop systemd[1]: Started Dispatcher daemon for systemd-networkd.
Jan 29 19:19:57 HP-Laptop networkd-dispatcher[747]: WARNING:Unknown index 3 seen, reloading interface list
Jan 29 19:20:00 HP-Laptop networkd-dispatcher[747]: WARNING:Unknown index 5 seen, reloading interface list
Jan 29 19:20:00 HP-Laptop networkd-dispatcher[747]: WARNING:Unknown index 6 seen, reloading interface list
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-01-29 19:19:49 EST; 1min 22s ago
TriggeredBy: ● systemd-networkd.socket
Docs: man:systemd-networkd.service(8)
Main PID: 431 (systemd-network)
Status: "Processing requests..."
Tasks: 1 (limit: 9072)
Memory: 4.1M
CGroup: /system.slice/systemd-networkd.service
└─431 /lib/systemd/systemd-networkd
答案1
您的fstab
条目看起来不错并且应该可以正常工作。
然而,似乎在网络连接可用之前就尝试了挂载(systemd 的连接性)因此出现以下错误:
CIFS VFS:连接套接字时出错。中止操作。
和
systemd[1]: media-Nas.mount: 挂载进程已退出,代码=已退出,状态=32/n/a systemd[1]: media-Nas.mount: 失败,结果为“退出代码”。systemd[1]: 无法挂载 CIFS 共享。
这是因为该服务systemd-networkd-wait-online
已被禁用。
像这样启用服务:
sudo systemctl enable systemd-networkd-wait-online
这应该不会出现错误。
之后重启系统。你的网络共享现在应该会在启动时挂载。
如果共享仍未安装,请检查:
systemctl status networkd-dispatcher.service systemd-networkd.service
看看是否有服务被禁用,并启用它们。然后重新启动系统。
答案2
我也遇到了同样的问题。虽然我的情况是 CIFS 共享托管在带有 DD WRT 3.0 的 ASUS RT AC68U 上
以下是我解决问题的方法:
(1)启用这些服务(因为我过去已经禁用了这些服务):
sudo systemctl enable systemd-networkd-wait-online
sudo systemctl enable systemd-networkd.service
sudo systemctl enable NetworkManager-wait-online.service
注意:如果其中任何服务是masked
,那么您需要先unmask
,然后启用它。
您可以在这里找到有关如何正确操作的更多信息unmask
:[1]和[2]。
(2)我注释掉(删除)了fstab
CIFS 共享的条目,并systemd mount
为 cifs 共享创建了条目:
注意:在目录中创建一个新文件 media-admn-nas.mount /etc/systemd/system
。
文件名必须包含挂载点名称,其中斜杠替换为“减号”。挂载目录/media/admn/nas => media-admn-nas.mount
sudo nano /etc/systemd/system/media-admn-nas.mount
[Unit]
Description=CIFS Mount Service
Requires=network-online.target systemd-networkd.service
After=network-online.target network-online.service media-admn-1\x2d6TB.mount remote-fs.target
Wants=network-online.target NetworkManager-wait-online.service
[Mount]
What=//192.168.1.1/nas
Where=/media/admn/nas
Options=rw,_netdev,auto,cache=none,vers=3.11,credentials=/home/admn/.smbcredentials,forceuid,forcegid,uid=1000,gid=1000
Type=cifs
TimeoutSec=15
[Install]
WantedBy=multi-user.target
注 1:就我而言,media-admn-1\x2d6TB.mount
是一个安装了 cifs 共享的附加硬盘,因此我将其添加为After=
要求。
注 2:由于我仍然遇到错误,因此我添加了TimeoutSec=15
(3)启用挂载:
sudo systemctl enable media-admn-nas.mount
sudo systemctl daemon-reload
(4)重新启动:重新启动 15 秒后,CIFS 共享应该已挂载。
(5)检查状态:
$ systemctl status media-admn-nas.mount
● media-admn-nas.mount - CIFS Mount Service
Loaded: loaded (/etc/systemd/system/media-admn-nas.mount; enabled; vendor preset: enable>
Active: active (mounted) since Sun 2021-01-31 10:37:52 IST; 1h 58min ago
Where: /media/admn/nas
What: //192.168.1.1/nas
Tasks: 0 (limit: 19083)
Memory: 12.0K
CGroup: /system.slice/media-admn-nas.mount