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

Fajar A. Nugraha list at fajar.net
Fri Jun 27 04:18:56 UTC 2014


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.

-- 
Fajar

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20140627/13fc8a71/attachment.html>


More information about the lxc-users mailing list