[Lxc-users] limiting RAM usage and disk space usage
Michael H. Warfield
mhw at WittsEnd.com
Fri Dec 3 03:22:45 UTC 2010
Sorry, I should have added an example...
Below...
On Thu, 2010-12-02 at 22:18 -0500, Michael H. Warfield wrote:
> On Thu, 2010-12-02 at 18:29 -0600, Serge E. Hallyn wrote:
> > Quoting Gordon Henderson (gordon at drogon.net):
> > > On Thu, 2 Dec 2010, Serge E. Hallyn wrote:
> > >
> > > > Quoting Gordon Henderson (gordon at drogon.net):
> > > >> On Mon, 29 Nov 2010, Trent W. Buck wrote:
> > > >>
> > > >>> Siju George <sgeorge.ml at gmail.com> writes:
> > > >>>
> > > >>>> 1) how do I limit the RAM usage of a container?
> > > >>>
> > > >>> In lxc.conf(5):
> > > >>>
> > > >>> lxc.cgroup.memory.limit_in_bytes = 256M
> > > >>> lxc.cgroup.memory.memsw.limit_in_bytes = 1G
> > > >>>
> > > >>>> 2) how do I limit the disk usage of a container ?
> > > >>>
> > > >>> Ensure the rootfs is a dedicated filesystem (e.g. an LVM LV), and limit
> > > >>> its size accordingly.
> > > >>
> > > >> Finally, a use for LVM....
> > > >>
> > > >> And here was me about to embark on using filesystems in files loopback
> > > >> mounted...
> > > >
> > > > That should also work, just a bit slower, right?
> > >
> > > I don't know, really. I use loopback mounted filesystems for other things
> > > and I don't really notice much slowdowns compared to the native
> > > filesystem, but I've never benchmarked it.
> > >
> > > It is some years since I looked at LVM and I wasn't impressed then so
> > > stopped thinking about it and used something else (I was looking at
> > > snapshot abilities at the time) I build systems for a purpose so rarely
> > > have the need to do the only thing LVM might be handy for - ie. resizing a
> > > volume so it just doesn't fgure in my systems, but maybe this is a valid
> > > use now.
>
> > It seems to me that a little extension to lxc-create which creates
> > the container inside a loopback fs would be pretty neat.
>
> Wouldn't simply adding the rootfs to the fstab conf with the file system
> image and the "-o loop" option do it? I would think it would. I
> haven't tried it in lxc but I do it all the time just for general
> mounting and day to day work.
So this is an excerpt from one of my LXC VM's fstab (I normally use an
explicit bind mount for them):
/srv/lxc/private/1004 /srv/lxc/rootfs none bind 0 0
Now... Wouldn't this work as well? Untested:
/srv/lxc/private/disk.image /srv/lxc/rootfs none loop 0 0
Seems to me that if the bind option works the loop option should as
well.
> > -serge
Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 985-6132 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20101202/02f3c63e/attachment.pgp>
More information about the lxc-users
mailing list