I'm trying to get davfs2
to mount a WebDAV folder automatically on debian stretch at boot.
It seems that systemd
attempts to mount the folder with mount.davfs
before the DHCP client has an IP address (which of course fails), even with the _netdev
mount option in /etc/fstab
. (Without _netdev
, mounting also fails but so does the entire boot process and I'm dropped into a root shell during boot.)
What magic can I give davfs
so that it only tries to mount after we've gotten an IP address with DHCP? (And why isn't this the default...)
As can be seen from the journalctl
output below, davfs2
attempts to mount before the DHCPACK and NFS mounts successfully after the DHCPACK. So NFS behaves, but davfs2
fails.
> grep davfs /etc/fstab
https://example.com/remote.php/webdav/ /home/peter/pmorch davfs user,rw,auto,_netdev 0 0
> sudo journalctl --since 13:20:48 | grep -P 'davfs|pmorch|DHCP|ISO'
Jan 18 13:20:49 snowden dhclient[669]: Internet Systems Consortium DHCP Client 4.3.5
Jan 18 13:20:49 snowden sh[657]: Internet Systems Consortium DHCP Client 4.3.5
Jan 18 13:20:49 snowden sh[657]: DHCPDISCOVER on ens18 to 255.255.255.255 port 67 interval 3
Jan 18 13:20:49 snowden dhclient[669]: DHCPDISCOVER on ens18 to 255.255.255.255 port 67 interval 3
Jan 18 13:20:49 snowden systemd[1]: Mounting /mnt/ISO-Dev...
Jan 18 13:20:49 snowden systemd[1]: Mounting /home/peter/pmorch...
Jan 18 13:20:49 snowden systemd[1]: Mounting /mnt/ISO...
Jan 18 13:20:49 snowden mount.davfs[751]: davfs2 1.5.4
Jan 18 13:20:49 snowden systemd[1]: home-peter-pmorch.mount: Mount process exited, code=exited status=1
Jan 18 13:20:49 snowden systemd[1]: Failed to mount /home/peter/pmorch.
Jan 18 13:20:49 snowden systemd[1]: home-peter-pmorch.mount: Unit entered failed state.
Jan 18 13:20:50 snowden dhclient[669]: DHCPREQUEST of 172.22.216.172 on ens18 to 255.255.255.255 port 67
Jan 18 13:20:50 snowden sh[657]: DHCPREQUEST of 172.22.216.172 on ens18 to 255.255.255.255 port 67
Jan 18 13:20:50 snowden sh[657]: DHCPOFFER of 172.22.216.172 from 172.22.216.251
Jan 18 13:20:50 snowden dhclient[669]: DHCPOFFER of 172.22.216.172 from 172.22.216.251
Jan 18 13:20:50 snowden dhclient[669]: DHCPACK of 172.22.216.172 from 172.22.216.251
Jan 18 13:20:50 snowden sh[657]: DHCPACK of 172.22.216.172 from 172.22.216.251
Jan 18 13:20:52 snowden systemd[1]: Mounted /mnt/ISO-Dev.
Jan 18 13:20:52 snowden systemd[1]: Mounted /mnt/ISO.