I’d like to mount a remote filesystem via davfs2, however LXD / LXC doesn’t seem to provide an /etc/fstab file. I see discuissions about adding one using “lxc.mount”, but I’m concerned about affecting existing filesystems, and I’m not sure how to deal with /etc/davfs2/secrets. I’m using Canonical’s LXD, which I believe is equivalent to Incus.
Would I be correct in saying that I can add an fstab in the container YAML as follows:
lxc.mount = /etc/fstab
And can I then just add the new mount there as normal, or would it need to be adjusted? (Remove the leading slash on the path perhaps?) Will the /etc/davfs2/secrets file be read as normal?
It’s a Hetzner storage box, mounting to a Plesk server, and usually looks like this:
davfs2 is a FUSE filesystem, so you don’t want LXC to try to mount that for you as LXC can only handle full in-kernel filesystems.
Instead you should install the davfs2 package in the container and add the mount line to your container’s /etc/fstab inside the container. Containers are allowed to mount FUSE filesystems, so the rest should work fine.
Please read the post. You’re not helping by answering without reading it. I was very specific about what I’m trying to achieve and concerns about making changes there.
Would I be correct in saying that I can add an fstab in the container YAML as follows:
No, you would be completely incorrect.
And can I then just add the new mount there as normal, or would it need to be adjusted? (Remove the leading slash on the path perhaps?) Will the /etc/davfs2/secrets file be read as normal?
No, you can’t.
And just to be sure, to be sure, no existing mounts will be affected by this; i.e. I don’t need to add them into /etc/fstab?
If it was possible to do through lxc.mount, then no, you wouldn’t need something in your host’s /etc/fstab, but it’s not possible to use a FUSE filesystem in lxc.mount, nor is it possible to use lxc.mount from an Incus/LXD config, so that’s kinda moot.
Now for anyone who actually cares to make this work, as I mentioned, above, the way to do it is:
Install davfs2 in the container
Add your entry to the /etc/fstab inside the container (create it if it doesn’t exist)
root@c1:~# dpkg -l davfs2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-================================================
ii davfs2 1.7.1-1 amd64 mount a WebDAV resource as a regular file system
root@c1:~# cat /etc/fstab
https://xxx.your-storagebox.de /var/lib/psa/dumps davfs rw,uid=998,gid=1000,file_mode=0660,dir_mode=0770,_netdev 0 0
root@c1:~# mkdir -p /var/lib/psa/dumps
root@c1:~# mount /var/lib/psa/dumps
Please enter the username to authenticate with server
https://xxx.your-storagebox.de or hit enter for none.
Username:
Presumably a valid URL combined with the right secrets on disk would eliminate the prompt, then on system boot, systemd would generate the relevant mount unit and trigger the mount as it would on any other system.