Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change lxc container directory

Tags:

lxc

containers

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.

like image 661
Dumitru Avatar asked Aug 13 '14 12:08

Dumitru


1 Answers

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:

  1. lxc.lxcpath in /etc/lxc/lxc.conf, consult man lxc.system.conf for details.
  2. lxc-* tools accepts -P flag to specify alternate container path.
  3. 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.

like image 137
Arkadi Shishlov Avatar answered Oct 12 '22 07:10

Arkadi Shishlov