[Lxc-users] Hard links, code map sharing
Daniel Lezcano
daniel.lezcano at free.fr
Mon Feb 21 09:52:29 UTC 2011
On 02/21/2011 10:42 AM, Daniel Farina wrote:
> On Mon, Feb 21, 2011 at 1:33 AM, Daniel Lezcano<daniel.lezcano at free.fr> wrote:
>> On 02/20/2011 08:08 PM, Daniel Farina wrote:
>>> Hello list,
>>>
>>> I've been scouring The Internet on and off for this, but have not come
>>> to a conclusion:
>>>
>>> Does a linux host running LXC share code maps between containers? e.g.
>>> redundant read-only maps to the same .so or /bin/foo, as defined by an
>>> equivalent hardlink?
>> Hmm, I suppose you are refering to similar feature than
>> http://linux-vserver.org/util-vserver:Vhashify right ?
> I think my need/question is simpler than that: basically, when running
> a binary, I am asking if there is a way to arrange sharing of the
> read-only code-segment/binary maps between processes, as they usually
> do when using non-lxc process isolation.
>
> Ex: if I have 1000 containers running, and all use libc, I'd want to
> not spend a megabyte per libc (as seen in /proc/<pid>/smaps) per
> container. I want to spend one megabyte for code space among all 1000
> containers.
Yep, as Serge mentioned, you can read-only bind mount in your
container's rootfs the system binary/library directories.
eg.
...
lxc.rootfs = $rootfs
lxc.mount.entry=/lib $rootfs/lib none ro,bind 0 0
lxc.mount.entry=/bin $rootfs/bin none ro,bind 0 0
lxc.mount.entry=/usr /$rootfs/usr none ro,bind 0 0
lxc.mount.entry=/sbin $rootfs/sbin none ro,bind 0 0
...
There is no variable substitution here, it is an example. You should
replace $rootfs by an absolute path.
Cheers
-- Daniel
More information about the lxc-users
mailing list