Commit 55116c42 by Serge Hallyn Committed by Stéphane Graber

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent b942e672
...@@ -110,13 +110,16 @@ fi ...@@ -110,13 +110,16 @@ fi
# If LVM partition, destroy it. If anything else, ignore it. We'll support # If LVM partition, destroy it. If anything else, ignore it. We'll support
# deletion of others later. # deletion of others later.
rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'` rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
if [ ! -z "$rootdev" ]; then if [ -n "$rootdev" ]; then
if [ -b "$rootdev" -o -h "$rootdev" ]; then if [ -b "$rootdev" ]; then
lvdisplay $rootdev > /dev/null 2>&1 lvdisplay $rootdev > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "removing backing store: $rootdev" echo "removing backing store: $rootdev"
lvremove -f $rootdev lvremove -f $rootdev
fi 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
fi fi
# recursively remove the container to remove old container configuration # recursively remove the container to remove old container configuration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment