From: Serge E. Hallyn Date: Thu, 23 Jun 2011 22:42:24 +0000 (+0200) Subject: lxc-destroy: delete a rootfs if it is an lvm volume X-Git-Tag: lxc-0.7.5~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2e0ee250188302b85d2056b354e6c57b9242194;p=thirdparty%2Flxc.git lxc-destroy: delete a rootfs if it is an lvm volume If this is acceptable as is, then I'll try to get a simple lxc-clone out tomorrow (taking into account your comments from last time). Signed-off-by: Serge Hallyn Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc-destroy.in b/src/lxc/lxc-destroy.in index 565d89d6c..ddd3c3b39 100644 --- a/src/lxc/lxc-destroy.in +++ b/src/lxc/lxc-destroy.in @@ -75,5 +75,15 @@ if [ ! -d "$lxc_path/$lxc_name" ]; then exit 1 fi +# Deduce the type of rootfs +# If LVM partition, destroy it. If anything else, ignore it. We'll support +# deletion of others later. +rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config | awk -F= '{ print $2 '}` +if [ -b $rootdev -o -h $rootdev ]; then + lvdisplay $rootdev > /dev/null 2>&1 + if [ $? -eq 0 ]; then + lvremove $rootdev + fi +fi # recursively remove the container to remove old container configuration rm -rf --preserve-root $lxc_path/$lxc_name