From 7de5bc6fa3cc7b71e31b3de5eeffd9dae70ffa6c Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Fri, 11 Mar 2022 15:48:03 +1300 Subject: [PATCH] Handle btrfs root subvolume for fedora extract-image This adds a check for the root device having filesystem type btrfs, and when it is assume there is a subvolume called "root". This fixes extract-image when using Fedora-Cloud-Base btrfs images. This should be sufficient until there is another btrfs base image with a different subvolume layout. Change-Id: Ib18979090585ba92566e523951b521b9d902fcb7 --- diskimage_builder/elements/sysprep/bin/extract-image | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/diskimage_builder/elements/sysprep/bin/extract-image b/diskimage_builder/elements/sysprep/bin/extract-image index 2fc27b52b..8a5526da7 100755 --- a/diskimage_builder/elements/sysprep/bin/extract-image +++ b/diskimage_builder/elements/sysprep/bin/extract-image @@ -131,7 +131,8 @@ function extract_image() { done mkdir $WORKING/mnt - if [ "xfs" = "$(sudo blkid -o value -s TYPE $ROOT_LOOPDEV)" ]; then + ROOT_FSTYPE=$(sudo blkid -o value -s TYPE $ROOT_LOOPDEV) + if [ "xfs" = "$ROOT_FSTYPE" ]; then # mount xfs with nouuid, just in case that uuid is already mounted # use ro to avoid/workaround xfs uuid issues on older # kernels with newer rhel images which seem to set @@ -139,6 +140,12 @@ function extract_image() { # xfs superblock has incompatible features (0x4) # we don't need to worry about this, we just want the data MOUNTOPTS="-o nouuid,ro" + elif [ "btrfs" = "$ROOT_FSTYPE" ]; then + # Fedora has a btrfs filesystem with a subvolume called root. + # For now assume there will be a 'root' subvolume, but in the + # future the subvolume layout may need to be discovered for different + # images + MOUNTOPTS="-o subvol=root" else MOUNTOPTS="" fi