0

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:

  LXC_AUTO="true"
  LXC_DIRECTORY="/home/al/lxc"

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?

Alex Marandon
  • 115
  • 1
  • 6

2 Answers2

1

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.

EDIT #2 END

EDIT:

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.

EDIT END

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:

localstatedir=/home
lxc_path=${localstatedir}/al/lxc

Or possibly:

localstatedir=/home/al
lxc_path=${localstatedir}/lxc

My setup:

localstatedir=/home
lxc_path=${localstatedir}/lxc

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:

LXC_DIRECTORY="/home/al/lxc"

and mine reads:

LXC_DIRECTORY="/home/lxc"

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.

William
  • 26
  • 2
1

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