Commit 5ae26abb by Dwight Engen Committed by Stéphane Graber

if the rootfs is a btrfs subvolume, delete it instead of rm -rf

Check if the rootfs is btrfs subvolume, and if so delete it. Otherwise fall back to the rm -rf. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com>
parent 06a1e1db
...@@ -106,8 +106,8 @@ if [ $? -eq 0 ]; then ...@@ -106,8 +106,8 @@ if [ $? -eq 0 ]; then
fi fi
# Deduce the type of rootfs # Deduce the type of rootfs
# If LVM partition, destroy it. If anything else, ignore it. We'll support # If LVM partition, destroy it. For btrfs, we delete the subvolue. If anything
# deletion of others later. # 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/^[^/]*/\//'` rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
if [ -n "$rootdev" ]; then if [ -n "$rootdev" ]; then
if [ -b "$rootdev" ]; then if [ -b "$rootdev" ]; then
...@@ -117,8 +117,13 @@ if [ -n "$rootdev" ]; then ...@@ -117,8 +117,13 @@ if [ -n "$rootdev" ]; then
lvremove -f $rootdev lvremove -f $rootdev
fi fi
elif [ -h "$rootdev" -o -d "$rootdev" ]; then elif [ -h "$rootdev" -o -d "$rootdev" ]; then
# In case rootfs is not under $lxc_path/$lxc_name, remove it if which btrfs >/dev/null 2>&1 &&
rm -rf --one-file-system --preserve-root $rootdev btrfs subvolume list "$rootdev" >/dev/null 2>&1; then
btrfs subvolume delete "$rootdev"
else
# In case rootfs is not under $lxc_path/$lxc_name, remove it
rm -rf --one-file-system --preserve-root $rootdev
fi
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