[Lxc-users] lxc-clone

Ramez Hanna rhanna at informatiq.org
Wed Aug 24 13:16:33 UTC 2011


Hi,

I have started using lxc to setup a pre-production system instead of KVM
at first glance clone seemd to me that it would copy everything to a new roots
but turns out that in case of LVM it will snapshot
AFAIK snapshots are meant more for backup or testing some changes and
discarding them later
do you think it makes sense if I modify the script in this way
if user doesn't specify -s, then a new lv is created and copy all
comtents to it, rather than snapshot which would work if user uses the
-s option?

On Tue, Jun 21, 2011 at 8:58 PM, Serge Hallyn
<serge.hallyn at canonical.com> wrote:
> Hi Daniel,
>
> Quoting Daniel Lezcano (daniel.lezcano at free.fr):
>> >>>+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
>
> I started changing my code to this, but now am wondering how this
> differs from what I was doing, which was:
>
> sed -i '/lxc.utsname/d' $lxc_path/$lxc_new/config
> echo "lxc.utsname = $hostname" >> $lxc_path/$lxc_new/config
>
> The only difference is that in mine, if the original config had a
> hostname at top of file, it'll now be at bottom of file.  But with
> both your snippets and mine, the 'lxc.utsname = new_hostname' will
> be the one and only utsname in the config.
>
> If you still think it's worth changing I'll do so, but I like that
> mine is shorter.
>
> -serge
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Lxc-users mailing list
> Lxc-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-users
>




More information about the lxc-users mailing list