My root filesystem is full and I'd like to create a container in my home directory, which has a lot of free space. I made a config file like this:


And I'm creating a container like this:

  $ sudo lxc-create -f lxc.conf -t ubuntu -n foo

But it's still filling up /var.

How can I tell lxc to create a container in my home dir?


EDIT #2:

Wow, can't believe I missed this:

When first installing lxc (version: 0.8.0~rc1-8+deb7u1) ("apt-get install lxc") it will ask you in what directory you want the containers to go.



Apparently if you install "lxc" from source with the command:

make install --localstatedir=/home

it should allow automatic creation of a VE in the /home directory. This will impact all lxc-* tools.


You need to edit "lxc-create" (for me it's in "/usr/bin"). In that file where it defines "localstatedir" and "lxc_path" you need to change that.

Based on what you want, you would need:


Or possibly:


My setup:


I have just figured this out; it creates the container without any errors, but I have not tested it beyond that. As for the line "LXC_DIRECTORY=" in the config file "/etc/default/lxc", it needs to match the line "lxc_path=" in the file "lxc-create" or it will create a rootfs in two different directories.

So your config file "/etc/default/lxc" would need to read:


and mine reads:


This is of course a workaround, and I do not know the impact this has on other lxc-* tools. They may need to be edited as needed also; perhaps someone else can chime in on how to install lxc with this built into the program.

  • Installing from source with the --localstatedir option did the trick. – Alex Marandon Apr 5 '14 at 8:05
  • is it possible to set the backing directory on a per container basis? – andresp Dec 14 '14 at 14:13
  • 2
    You can just use the '-P' argument of lxc-create. Other commands as lxc-console and lxc-start accepts it too. I think it is easier than define environment variables. – Eduardo Ramos Jan 29 '15 at 17:46

You can override container path with --lxcpath/-P option like this:

sudo lxc-create -P /home/al/lxc -f lxc.conf -t ubuntu -n foo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.