Lets say we have one server with lxc installed, and a lxc container used for as a base img /var/lib/lxc/ubuntu_base
. For simplicity let's forget the config changes after copying the base img.
some people suggest using subvolumes and snapshots for making new containers, but one could easily do cp --reflink with simmilar results.
So what is the propper way (or which is better) for managing multiple containers?
- snapshots
This way seems best, but commands like lxc-destroy won't work since it won't be able to delete the directory.
btrfs subvolume snapshot /var/lib/lxc/ubuntu_base /var/lib/lxc/container_1
- cp with reflink
I am not sure if there is any performance difference between this or snapshots
cp --reflink=always /var/lib/lxc/ubuntu_base /var/lib/lxc/container_1
- or Is there any other better way of doing this that I am not aware of.
edit:
One thing I've seen with the reflink option is, that you can't delete the base container if others are running, because the /proc
and /dev
are mounted and never changed, se the reference is always the same. But shutting down all the coppied containers seems to help.