[Lxc-users] [PATCH 3/9] lxc-clone: maintain size of lvm snapshot

Serge Hallyn serge at hallyn.com
Thu Apr 26 05:09:35 UTC 2012


From: Serge Hallyn <serge.hallyn at ubuntu.com>

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 at ubuntu.com>
---
 src/lxc/lxc-clone.in |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in
index 228fd0d..28c47e8 100644
--- a/src/lxc/lxc-clone.in
+++ b/src/lxc/lxc-clone.in
@@ -48,7 +48,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
@@ -203,6 +204,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
-- 
1.7.9.5





More information about the lxc-users mailing list