失败后 systemd 重新挂载 cifs 驱动器

失败后 systemd 重新挂载 cifs 驱动器

在 debian 8 上。我有一个通过 systemd 安装的 cifs 共享驱动器:

$ cat /etc/systemd/system/external_dir.mount
[Unit]
Description=cifs mount script for /external_dir/
Requires=network-online.target
After=network-online.service

[Mount]
What=***
Where=***
Options=username=***,password=***
Type=cifs
Restart=on-failure

[Install]
WantedBy=multi-user.target

但是,当远程计算机重新启动(例如由于电源故障)时,systemd不会重新安装驱动器,即使它显示状态为失败:

$ sudo systemctl status external_dir.mount
● external_dir.mount - cifs mount script for /external_dir/
   Loaded: loaded (/etc/systemd/system/external_dir.mount; enabled)
   Active: failed (Result: exit-code) since Thu 2017-04-13 04:12:16 ACST; 6h ago
    Where: /external_dir
     What: ***
  Process: 413 ExecMount=/bin/mount -n *** /external_dir -t cifs -o username=***,password=*** (code=exited, status=32)

Apr 13 04:12:16 bob mount[413]: mount error(115): Operation now in progress
Apr 13 04:12:16 bob mount[413]: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Apr 13 04:12:16 bob systemd[1]: external_dir.mount mount process exited, code=exited status=32
Apr 13 04:12:16 bob systemd[1]: Failed to mount cifs mount script for /external_dir/.
Apr 13 04:12:16 bob systemd[1]: Unit external_dir.mount entered failed state.

如果我手动重新启动服务(sudo systemctl restart external_dir.mount),那么它就会恢复正常。

当 cifs 驱动器再次可用时,如何让 systemd 重新安装它?请注意,有时远程计算机会停机数小时,因为晚上断电,我们直到早上才将其重新打开。

相关内容