From 57149d9eb19f81c1b4278fffaa6c4c2894d9589f Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Wed, 25 May 2022 08:33:31 -0700 Subject: [PATCH] Check and mount boot volume for data extraction with nouuid When building an image, say RHEL9, on a host installed with that same image, you will be blocked from mounting the filesystems to extract contents, as the host OS kernel will identify the duplicate UUIDs and error accordingly. This was previously fixed for the root filesystem, but not the boot filesystem. Change-Id: I63a34fba033ed1c459aeb9c201c8821fa38a36e9 --- .../elements/sysprep/bin/extract-image | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/diskimage_builder/elements/sysprep/bin/extract-image b/diskimage_builder/elements/sysprep/bin/extract-image index 8a5526da..c460dccf 100755 --- a/diskimage_builder/elements/sysprep/bin/extract-image +++ b/diskimage_builder/elements/sysprep/bin/extract-image @@ -156,7 +156,18 @@ function extract_image() { if [ ! -z "$BOOT_LOOPDEV" ]; then # mount to /boot - sudo mount $BOOT_LOOPDEV $WORKING/mnt/boot + BOOT_FSTYPE=$(sudo blkid -o value -s TYPE $ROOT_LOOPDEV) + if [ "xfs" = "$BOOT_FSTYPE" ]; then + BOOT_MOUNTOPTS="-o nouuid,ro" + # Similar to root filesystem, if the boot filesystem + # is XFS and the base OS is the same as the image being + # rebuilt, we need to pass "nouuid" to bypass UUID safety + # checks and successfully mounts so we can extract the + # contents. + else + BOOT_MOUNTOPTS="" + fi + sudo mount $BOOT_MOUNTOPTS $BOOT_LOOPDEV $WORKING/mnt/boot EACTION="sudo umount -f $BOOT_LOOPDEV ; $EACTION" trap "$EACTION" EXIT fi