From 55116c42e767ce795f796fc51cd2ef7d76cf18af Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Wed, 5 Sep 2012 21:59:13 -0500 Subject: [PATCH] lxc-destroy: Separately rm rootfs if it is a symlink If rootfs is a symbolic link but not to a block device, then do a separate rm of its contents. We have to do this because, out of cowardice, we call rm with --one-filesystem. Removing the '-o -h $rootdev' is ok, because if $rootdev is a symbolic link to a block device (including lvm blockdev) then -b will still return true. Signed-off-by: Serge Hallyn --- src/lxc/lxc-destroy.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc-destroy.in b/src/lxc/lxc-destroy.in index aa9473bec..5ae572213 100644 --- a/src/lxc/lxc-destroy.in +++ b/src/lxc/lxc-destroy.in @@ -110,13 +110,16 @@ fi # 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 2>/dev/null | sed -e 's/^[^/]*/\//'` -if [ ! -z "$rootdev" ]; then - if [ -b "$rootdev" -o -h "$rootdev" ]; then +if [ -n "$rootdev" ]; then + if [ -b "$rootdev" ]; then lvdisplay $rootdev > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "removing backing store: $rootdev" lvremove -f $rootdev fi + elif [ -h "$rootdev" -o -d "$rootdev" ]; then + # In case rootfs is not under $lxc_path/$lxc_name, remove it + rm -rf --one-file-system --preserve-root $rootdev fi fi # recursively remove the container to remove old container configuration