[lxc-devel] [PATCH] if the rootfs is a btrfs subvolume, delete it instead of rm -rf
Stéphane Graber
stgraber at ubuntu.com
Wed Sep 26 17:38:47 UTC 2012
On 12-09-26 12:59 PM, Dwight Engen wrote:
> Check if the rootfs is btrfs subvolume, and if so delete it. Otherwise
> fall back to the rm -rf.
>
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
> ---
> src/lxc/lxc-destroy.in | 13 +++++++++----
> 1 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/lxc/lxc-destroy.in b/src/lxc/lxc-destroy.in
> index 5c76569..1ea4a81 100644
> --- a/src/lxc/lxc-destroy.in
> +++ b/src/lxc/lxc-destroy.in
> @@ -106,8 +106,8 @@ if [ $? -eq 0 ]; then
> fi
>
> # Deduce the type of rootfs
> -# If LVM partition, destroy it. If anything else, ignore it. We'll support
> -# deletion of others later.
> +# If LVM partition, destroy it. For btrfs, we delete the subvolue. 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 [ -n "$rootdev" ]; then
> if [ -b "$rootdev" ]; then
> @@ -117,8 +117,13 @@ if [ -n "$rootdev" ]; then
> 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
> + if which btrfs >/dev/null 2>&1 &&
> + 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
Looks good, applied to staging.
Thanks
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 897 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20120926/e4c71c87/attachment.pgp>
More information about the lxc-devel
mailing list