From 8f12d9530ed79359fb988688caadfa6dc318f7a5 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 8 Sep 2020 16:46:29 +1000 Subject: [PATCH] bootloader: remove dangling grubenv links The rhel8.2 .qcow2 images have moved from a single xfs partition into an EFI style layout with separate /boot/efi partition. This means the root partition has /boot/grub2/grubenv as a symlink to ../efi/EFI/redhat/grubenv, which is dangling when we are running the bootloader element as /boot/efi is blank. grub-install tries to call rename() in the process of re-writing this file, which fails and bails out dib. Remove this symlink if it exists Change-Id: I5591144a3617dbae148b0c5d2a6a404942ffcd4e Parital-Bug: #1893029 Redhat-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1871669 --- .../elements/bootloader/finalise.d/50-bootloader | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader index 88de8d89..8a48d320 100755 --- a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader +++ b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader @@ -88,6 +88,17 @@ function install_grub2 { echo "Installing GRUB2..." + # When using EFI image-based builds, particularly rhel element + # based on RHEL>=8.2 .qcow2, we might have /boot/grub2/grubenv + # as a dangling symlink to /boot/efi because we have extracted + # it from the root fs, but we didn't populate the separate EFI + # boot partition from the image. grub2-install calls rename() + # on this file, so if it's a dangling symlink it errors. Just + # remove it if it exists. + if [[ -L /boot/grub2/grubenv ]]; then + rm -f /boot/grub2/grubenv + fi + # We need --force so grub does not fail due to being installed on the # root partition of a block device. GRUB_OPTS=${GRUB_OPTS:-"--force"}