[Lxc-users] how to limit disk space in lxc

Fajar A. Nugraha list at fajar.net
Thu Oct 25 14:42:02 UTC 2012


On Thu, Oct 25, 2012 at 9:07 PM, Serge Hallyn
<serge.hallyn at canonical.com> wrote:
> Quoting Fajar A. Nugraha (list at fajar.net):
>> On Thu, Oct 25, 2012 at 4:11 PM, 宣铭艺 <xuanmingyi at gmail.com> wrote:
>> > Dear all:
>> > The problem is that,how can we limit the disk space in lxc.Now I use the
>> > default config.
>> > And the container can access all space in host.can we use lvm or other tools
>> > to limit it?
>> > And how :)
>>
>> simplest solution: place the container rootfs in an LV.
>>
>> You need to create and format the LV and move the rootfs MANUALLY
>> after the container is created though, as AFAIK no template has the
>> ability to "create a rootfs in an LV of this size".
>
> -B option to lxc-create specifies the backing store type.
>
> sudo lxc-create -t ubuntu -B lvm -n u1
>
> will default to 500M rootfs with ext4, or
>
> sudo lxc-create -t ubuntu -B lvm -n u1 --fssize 2G --fstype xfs
>


Ah, thanks for pointing that out. I was (mistakenly) looking at the
template (/usr/share/lxc/templates/lxc-ubuntu --help), while in fact
the option belongs to lxc-create.

-- 
Fajar




More information about the lxc-users mailing list