失敗後 systemd 重新掛載 cifs 驅動器

失敗後 systemd 重新掛載 cifs 驅動器

在 debian 8 上。

$ 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 重新安裝它?請注意,有時遠端電腦會停機數小時,因為晚上斷電,我們直到早上才將其重新打開。

相關內容