Can I change the directory where lxc containers are initialized and kept? Now they are created under /var/cache/lxc, and I would like to have them in another directory, on another partition where I have more space. Changint the mounting point of the partition is not an option as it's already used for something else.
Yes you can. The /var/cache/lxc
prefix is hardcoded into every /usr/share/lxc/templates/
template. You can change the path over there.
In case you're building LXC from sources, then the path is actually @LOCALSTATEDIR@/cache/lxc/
where @LOCALSTATEDIR@
is by default --prefix=
+ /var
or --localstatedir
you pass to ./configure
.
As for /var/lib/lxc
, the default path to containers, specific container, and path to container's dir type of datastore could be configured at multiple levels:
lxc.lxcpath
in /etc/lxc/lxc.conf
, consult man lxc.system.conf
for details.lxc-*
tools accepts -P
flag to specify alternate container path.lxc-create
-B dir
backing store has optional --dir ROOTFS
flag.Also, I highly recommend a series of blog posts by Stéphane Graber and Containers storage specifically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With