0

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[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.

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.

  • You must be referring to the remote pc by name, and for some reason name resolution failed. Once DNS is properly started, then it works. Try referring to the host share by IP address, you will see it works. If confirmed, just make sure you mount the remote share after DNS is working properly. (Is this a server?) – MariusMatutiae Apr 13 '17 at 6:26
  • Hmm ... the external cifs drive is on the same server that hosts the DNS for that LAN. However, I don't think this is the issue because running the sudo systemctl restart external_dir.mount command did mount the drive, whereas systemd did not mount it by itself before then even though the remote server had been up for over an hour. – mulllhausen Apr 13 '17 at 9:05
  • For service units, you could set StartLimitInterval = 0 to have indefinite restart attempts (with a wise RestartSec setting). However, mount units seem to lack the StartLimitInterval setting under jessie, and even also Restart for some reason, so you probably can't do this directly. But try using an automount unit instead, or configure a timer unit to restart your mount unit periodically. – Ferenc Wágner Apr 13 '17 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.