[lxc-users] Setting a limit on the disk size that a container can use

Serge Hallyn serge.hallyn at ubuntu.com
Fri Jun 27 04:56:48 UTC 2014


Quoting Fajar A. Nugraha (list at fajar.net):
> On Fri, Jun 27, 2014 at 11:02 AM, Qiang Huang <h.huangqiang at huawei.com>
> wrote:
> 
> > On 2014/6/27 11:38, Fajar A. Nugraha wrote:
> > > On Fri, Jun 27, 2014 at 9:28 AM, Qiang Huang <h.huangqiang at huawei.com
> > <mailto:h.huangqiang at huawei.com>> wrote:
> > >
> > >     On 2014/3/16 17:07, Guido Jäkel wrote:
> > >     > ... or use an image file on an abitrary file system on the host.
> > Just create
> > >     > a file containing a filesystem and use it direct (no loop device
> > required) as
> > >     > rootfs for the container.
> > >     >
> > >     > Guido
> > >
> > >     Hi Guido,
> > >
> > >     Can you be more specific about how to use a image file to limit disk
> > size
> > >     but with no loop device?
> > >
> > >     All I know is something like this:
> > >     # dd if=/dev/zero of=lxc.img bs=1M count=0 seek=40960
> > >     # mkfs.ext3 lxc.img
> > >     # mount -o loop lxc.img /lxc_container1/       # here we need loop
> > device
> > >     # cp -r /template1/rootfs/* /lxc_container1/
> > >
> > >
> > > I'm pretty sure you still need loop device support. However you don't
> > have to allocate the loop device or mount the image manually, you can just
> > pass the image file name in lxc config file.
> > >
> >
> > Yes, that's what I thought, seems like loop device is the only way to use
> > image file
> > to limit disk. But I found some problems using loop device,
> 
> 
> What problems?
> 
> 
> 
> > wounding if we can
> > skip loop device, then I found Guido's mail.
> >
> >
> 
> There are other ways to use file as block device without loop. However,
> it's not specific to lxc, and there's no automatic hook for that in lxc
> config file.
> 
> For example, my favorite is using scst with vdisk_fileio, disable nv_cache
> (if you have problems with cache), and then access it locally using
> scst_local. Other scsi targets (e.g. LIO) should also have similar feature.
> 
> The downside is that you need to create the mapping separately from lxc.
> After that, use the block device in lxc config file.

That sounds like it could make a neat addition to the current loop and
qemu-nbd options.  Hopefully someone will write a patch for it :)

-serge


More information about the lxc-users mailing list