On debian 8. I have a cifs share drive mounted via systemd:
$ 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
However when the remote machine is rebooted (eg. due to a power failure),
systemd does not remount the drive, even though it shows the status as failed:
$ 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: mount error(115): Operation now in progress Apr 13 04:12:16 bob mount: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) Apr 13 04:12:16 bob systemd: external_dir.mount mount process exited, code=exited status=32 Apr 13 04:12:16 bob systemd: Failed to mount cifs mount script for /external_dir/. Apr 13 04:12:16 bob systemd: Unit external_dir.mount entered failed state.
If I restart the service manually (
sudo systemctl restart external_dir.mount) then it comes back up just fine though.
How can I get systemd to remount the cifs drive when it becomes available again? Note that sometimes the remote machine is down for hours as the power goes out at night and we do not switch it back on until morning.