]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-clone: maintain size of lvm snapshot
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 31 Jul 2012 14:01:28 +0000 (16:01 +0200)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Tue, 31 Jul 2012 14:01:28 +0000 (16:01 +0200)
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 <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc-clone.in

index 78058ecb9ae8a978ff41e87386161cbd6c5a6c42..deb01f7d953ca7320ccadbcebd252fd7236e791c 100644 (file)
@@ -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