Publication date: 2024-06-08
I have many containers that use bind mounts to the host for their persistent storage. This looks as follows in the lxc container config:
mp0: /home/containers/dh-test,mp=/home
However, with such bind mounts it is no longer possible to create snapshots for the storage of such containers. The Proxmox UI shows: "The current guest configuration does not support taking new snapshots".
This is quite annoying to me since snapshots are a very helpful feature.
Instead of using mpX: ...
, one can use lxc directives directly as follows:
lxc.mount.entry: /directory/on/host directory/in/container none bind,rw 0 0
Note the missing leading slash in the second argument. That is important.
Example:
#mp0: /home/containers/dh-test,mp=/home
#can be replaced by:
lxc.mount.entry: /home/containers/dh-test home none bind,rw 0 0
The directory to mount to within the container must already exist. To be tolerant on that, one can add create=dir
:
lxc.mount.entry: /home/containers/dh-test home none bind,rw,create=dir 0 0
Using lxc.mount directly allows for more powerful options, e.g. for including submounts as well (using rbind
):
lxc.mount.entry: /vault vault none rbind,rw,create=dir,optional 0 0