From: Serge Hallyn Date: Tue, 31 Jul 2012 14:01:28 +0000 (+0200) Subject: lxc-clone: maintain size of lvm snapshot X-Git-Tag: lxc-0.8.0~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93f292149ea555a61cf043acf760ce2520b43472;p=thirdparty%2Flxc.git lxc-clone: maintain size of lvm snapshot When creating a container as lvm snapshot, use the original size unless user explicitly overrides it. It's all well and good to day "use lvextend if you run out of space", but in the meantime applications may become corrupted... Signed-off-by: Serge Hallyn Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in index 78058ecb9..deb01f7d9 100644 --- a/src/lxc/lxc-clone.in +++ b/src/lxc/lxc-clone.in @@ -50,7 +50,8 @@ localstatedir=@LOCALSTATEDIR@ lxc_path=@LXCPATH@ bindir=@BINDIR@ snapshot=no -lxc_size=2G +lxc_defsize=2G +lxc_size=_unset lxc_vg=lxc lxc_lv_prefix="" fstype=ext3 @@ -199,6 +200,9 @@ if [ -b $oldroot ]; then lxc-freeze -n $lxc_orig frozen=1 fi + if [ $lxc_size = "_unset" ]; then + lxc_size=`lvdisplay $oldroot | grep Size | awk '{ print $3 $4 }'` + fi lvcreate -s -L $lxc_size -n ${lxc_lv_prefix}${lxc_new}_snapshot $oldroot if [ $container_running = "True" ]; then lxc-unfreeze -n $lxc_orig