Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-123857

Cannot migrate an efi-based edge to image mode with bootc install to-existing-root

Linking RHIVOS CVEs to...Migration: Automation ...RHELPRIO AssignedTeam ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • rhel-9.4.z, rhel-9.6
    • rhel-bootc-container
    • None
    • None
    • Low
    • rhel-image-mode
    • 8
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • All
    • None

      What were you trying to do that didn't work?

      All BIOS-based migration works well, and an EFI-based and package-based migration works well.
      But an EFI-based edge fails to update properly the grub configuration.
      All tested systems have a dedicated /boot (xfs) and /boot/efi (vfat) partitions.

      The customer followed the following doc to migrate from Edge 9.4 to Image mode 9.6:
      https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/using_image_mode_for_rhel_to_build_deploy_and_manage_operating_systems/deploying-the-rhel-bootc-images_using-image-mode-for-rhel-to-build-deploy-and-manage-operating-systems#advanced-installation-with-to-filesystem_deploying-the-rhel-bootc-images 

      What is the impact of this issue to you?

      Cannot move to image mode.

      Please provide the package NVR for which the bug is seen:

      registry.redhat.io/rhel9/rhel-bootc:latest

      How reproducible is this bug?:

      Always

      Steps to reproduce

      1. Install an EFI-based Edge 9.4 (or 9.6) with dedicated /boot and /boot/efi partitions. As an example, I deployed the edge-commit with the below KS:

      text
      lang en_US.UTF-8
      keyboard us
      timezone UTC
      zerombr
      clearpart --all --initlabel
      ignoredisk --only-use=vda
      part /boot/efi --fstype="efi" --ondisk=vda --size=600 --fsoptions="umask=0077,shortname=winnt"
      part /boot --fstype=xfs --asprimary --size=1024
      part pv.01     --fstype="lvmpv"  --size=1 --grow
      volgroup rootvg        --pesize=4096   pv.01
      logvol /       --fstype="xfs"    --size=1        --name=lv_root  --vgname=rootvg --grow
      logvol swap    --fstype="swap"   --size=1024      --name=lv_swap  --vgname=rootvg
      bootloader --append="console=tty0 console=ttyS0,115200n1"
      network --bootproto=dhcp
      rootpw --plaintext rootroot --allow-ssh
      ostreesetup --nogpg --osname=rhel --remote=edge --url=http://192.168.124.10/repo --ref=rhel/9/x86_64/edge
      eula --agreed
      reboot
      

      2. Migrate it with the `podman ... bootc install to-existing-root` method

      # podman run --rm --privileged -v /dev:/dev -v /var/lib/containers:/var/lib/containers -v /:/target \
                  --pid=host --security-opt label=type:unconfined_t \
                  registry.redhat.io/rhel9/rhel-bootc:latest \
                  bootc install to-existing-root --skip-fetch-check --acknowledge-destructive --root-ssh-authorized-keys /target/root/.ssh/authorized_keys
       :
       :
      > bootupctl backend install --write-uuid --update-firmware --auto --device /dev/vda /target/sysroot
       :
      Installed: grub.cfg
      Could not find /boot/efi/EFI when installing "redhat/grub.cfg"
      Installation complete!

      Expected results

      /boot/efi/EFI/redhat/grub.cfg is updated and the updated contents are copied to the writable /boot.

      Actual results

      On RHEL 9.6, /boot/efi/EFI/redhat/grub.cfg is a stub that points to the /boot/grub2/grub.cfg file, and it remains unchanged after the migration:

      # cat /boot/efi/EFI/redhat/grub.cfg 
      search --no-floppy --fs-uuid --set=dev 0a831a8b-c5e2-46df-a4ee-2b31826ee946
      set prefix=($dev)/grub2
      export $prefix
      configfile $prefix/grub.cfg

      Where the UUID above is the one of the /boot partition:

      # blkid /dev/vda2
      /dev/vda2: UUID="0a831a8b-c5e2-46df-a4ee-2b31826ee946" TYPE="xfs" PARTUUID="8e5b7b49-0f4a-48d7-9f79-52298275955c"

      The grub.cfg from the EFI part still pointing to the old /boot which is not updated, the system boots on the old edge 9.4 system:

      # cat /proc/cmdline 
      BOOT_IMAGE=(hd0,gpt2)/ostree/rhel-e27929c4d6156dca998a5e06b9ffdfb1e721f93c04927ec301b3ac1ad853a3d4/vmlinuz-5.14.0-427.42.1.el9_4.x86_64 console=tty0 console=ttyS0,115200n1 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rootvg-lv_swap rd.lvm.lv=rootvg/lv_root rd.lvm.lv=rootvg/lv_swap root=/dev/mapper/rootvg-lv_root rw ostree=/ostree/boot.0/rhel/e27929c4d6156dca998a5e06b9ffdfb1e721f93c04927ec301b3ac1ad853a3d4/0
      # ls -l /boot
      total 4
      lrwxrwxrwx. 1 root root    1 Oct 23 11:47 boot -> .
      drwx------. 4 root root 4096 Jan  1  1970 efi
      lrwxrwxrwx. 1 root root    8 Oct 23 11:47 loader -> loader.1
      drwxr-xr-x. 3 root root   21 Oct 23 11:47 loader.1
      drwxr-xr-x. 3 root root   86 Oct 23 11:47 ostree
      # head -n1 /boot/loader/entries/ostree-1.conf 
      title Red Hat Enterprise Linux 9.6 (Plow) (ostree:0)
      # mount /dev/vda2 /mnt
      # ls -l /mnt/
      total 4
      lrwxrwxrwx. 1 root root    1 Oct 23 09:41 boot -> .
      drwxr-xr-x. 2 root root    6 Oct 23 09:41 efi
      drwx------. 3 root root   50 Oct 23 09:41 grub2
      -rw-r--r--. 1 root root 1024 Oct 23 11:44 grubenv
      lrwxrwxrwx. 1 root root    8 Oct 23 09:41 loader -> loader.0
      drwxr-xr-x. 3 root root   37 Oct 23 09:41 loader.0
      drwxr-xr-x. 3 root root   83 Oct 23 09:41 ostree
      # head -n1 /mnt/loader/entries/ostree-1.conf 
      title Red Hat Enterprise Linux 9.4 (Plow) (ostree:0)
      

      Another symptom of this problem is a grub2 directory created into /boot/efi and the bootuuid.cfg file points to the EFI part (??):

      # ls /boot/efi/grub2
      bootuuid.cfg  grub.cfg
      # cat /boot/efi/grub2/bootuuid.cfg 
      set BOOT_UUID="83DC-3E41"

      Workaround

      Warning: for testing purposes only

      After the reboot, copy the updated content from /boot to the real /boot partition (which is not mounted) and reuse the old grub.cfg from the Edge system.

      # mount /dev/vda2 /mnt
      # rm -rf /mnt/ostree /mnt/loader
      # cp -a /boot/{ostree,loader.1} /mnt
      # ln -sfv loader.1 /mnt/loader
      # cp /mnt/loader.0/grub.cfg /mnt/loader.1/
      # reboot

       

              walters@redhat.com Colin Walters
              rhn-support-cbesson Christophe Besson
              Colin Walters Colin Walters
              Wei Shi Wei Shi
              Gabriela Necasova Gabriela Necasova
              Votes:
              2 Vote for this issue
              Watchers:
              13 Start watching this issue

                Created:
                Updated: