[Lxc-users] lxc-clone

Daniel Lezcano daniel.lezcano at free.fr
Wed Apr 6 10:22:07 UTC 2011


On 04/05/2011 02:52 PM, Serge Hallyn wrote:
> Quoting Daniel Lezcano (daniel.lezcano at free.fr):
>> I think more configuration tweaking will be needed but this patch
>> looks good for me.
> I'm hoping to set up a machine on which to play with lxc on btrfs
> snapshots sometime this week.  (In the background, starting the
> build now).

Nice :)

>>> +echo "Tweaking configuration"
>>> +cp $lxc_path/$lxc_orig/config $lxc_path/$lxc_new/config
>>> +sed -i '/lxc.utsname/d' $lxc_path/$lxc_new/config
>>> +echo "lxc.utsname = $hostname">>   $lxc_path/$lxc_new/config
>> We should not assume lxc.utsname is in the configuration file in
>> order to not write a hostname in all the cases.
>> The user may want to let the container to setup itself the hostname.
> What do you think is the best way to do this?  We could allow the user
> to specify a 'firstboot' script, which gets copied into root directory
> of the container.   Maybe boot the container when it's done, run
> /firstboot.sh, and shut down.  Or just let that happen when the user
> first boots.  We could use a /etc/init.d/lxc-firstboot script, but
> that will only work if the container's init system actually looks at
> sysvinit scripts.  Obviously sysvinit and upstart do, and I must
> assume that systemd does.  lxc-init I assume doesn't.

Mmh, that's look a bit complicate for the user. I was thinking about 
something simpler like:

grep -q "lxc.utsname" $lxc_path/$lxc_new/config
if [ $? == 0 ]; then
     sed -e "s/lxc.utsname/lxc.utsname=$hostname" $lxc_path/$lxc_new/config
else
     echo "lxc.utsname = $hostname">> $lxc_path/$lxc_new/config
fi

and so for the rest of the configuration variables.

I suspect the configuration tweaks will be more complicated than that..

For example:

lxc.network.veth.peer = veth1234

should be removed or replaced by a random name.

But we can improve the different configuration tweaks later.

> Thanks for looking it over, Daniel.  I'm using this heavily every day,
> so am really keen on polishing it :)

Thanks for this command, I think it is very useful.

By the way, did the lxc.rootfs=<lvm_image> worked ?

Thanks

   -- Daniel




More information about the lxc-users mailing list