Uploaded image for project: 'RHEL Conversions'
  1. RHEL Conversions
  2. RHELC-1601

Misconfigured grub file causes conversion to fail on Oracle and Rocky Linux 9.4

XMLWordPrintable

    • 3
    • Testable

      Reproduced on OL9.3-x86_64-HVM-2024-02-02 updated to 9.4 with minimal reproducer on Rocky-9-EC2-Base-9.4-20240509.0.x86_64
      With misconfigured /etc/default/grub file convert2rhel is unable to remove the old vendor kernel packages in both the main transaction and then in the [Convert: Prepare kernel] task.
      The conversion then fails with many tasks to still go through, most importantly the bootloader and/or GRUB2 configurations.
      The system is left in undetermined state.

      Running scriptlet: kernel-core-5.14.0-362.8.1.el9_3.x86_64 [789/789]
      WARNING - Scriptlet output: /etc/default/grub: line 9: GRUB_CMDLINE_LINUX: command not found
      depmod: WARNING: could not open modules.order at /lib/modules/5.14.0-362.8.1.el9_3.x86_64: No such file or directory
      depmod: WARNING: could not open modules.builtin at /lib/modules/5.14.0-362.8.1.el9_3.x86_64: No such file or directory
      dracut-install: Failed to find module 'virtio_pci'
      dracut: FAILED:  /usr/lib/dracut/dracut-install -D /var/tmp/dracut.DQaCQP/initramfs --kerneldir /lib/modules/5.14.0-362.8.1.el9_3.x86_64/ -m xen_netfront xen_blkfront virtio_blk virtio_net virtio_pci virtio_balloon hyperv_keyboard hv_netvsc hid_hyperv hv_utils hv_storvsc hyperv_fb ahci libahci ahci_platform libahci_platform ena nvme nvme_core
      depmod: WARNING: could not open modules.order at /var/tmp/dracut.DQaCQP/initramfs/lib/modules/5.14.0-362.8.1.el9_3.x86_64: No such file or directory
      depmod: WARNING: could not open modules.builtin at /var/tmp/dracut.DQaCQP/initramfs/lib/modules/5.14.0-362.8.1.el9_3.x86_64: No such file or directory
      /etc/default/grub: line 9: GRUB_CMDLINE_LINUX: command not found
      warning: %posttrans(kernel-core-5.14.0-362.8.1.el9_3.x86_64) scriptlet failed, exit status 127
      

      Minimal reproducer

      1. Get e.g. Rocky-9-EC2-Base-9.4-20240509.0.x86_64 machine
      2. Make the invalid changes to the grub file, prepare a repo for installation of oder kernel to be able to reproduce the removal and install the kernel
        # mkdir bkp
        # cp /etc/default/grub bkp/
        # sed -i 's/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX/' /etc/default/grub 
        # grub2-mkconfig -o bkp/
        /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
        # cat /etc/default/grub 
        GRUB_DEFAULT=saved
        GRUB_CMDLINE_LINUX
        GRUB_GFXMODE=auto
        GRUB_TERMINAL_INPUT="console"
        GRUB_TERMINAL_OUTPUT="gfxterm"
        GRUB_TIMEOUT=1
        # grub2-mkconfig -o bkp/grub.cfg
        /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
        # sed -i -e 's/^mirrorlist/#mirrorlist/' -e 's/\$contentdir\/\$releasever/vault\/9\.3/' -e 's/^#baseurl/baseurl/' /etc/yum.repos.d/rocky.repo
        # yum install -y --disablerepo * --enablerepo baseos https://download.rockylinux.org/vault/rocky/9.3/BaseOS/x86_64/os/Packages/k/kernel-5.14.0-362.24.1.el9_3.x86_64.rpm
        
      1. The kernel and kernel-core packages get installed, but posttrans scriptlet failure can be observed
        Running scriptlet: kernel-core-5.14.0-362.24.1.el9_3.x86_64                                                                                                                                                                           4/4 
        /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
        /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
        warning: %posttrans(kernel-core-5.14.0-362.24.1.el9_3.x86_64) scriptlet failed, exit status 127
        
        Error in POSTTRANS scriptlet in rpm package kernel-core
        
      1. Try to uninstall the kernel the same way as convert2rhel attemps to in the Prepare kernel step
        # rpm -e --nodeps kernel-5.14.0-362.24.1.el9_3.x86_64 kernel-core-5.14.0-362.24.1.el9_3.x86_64
        /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
        /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
        error: %preun(kernel-core-5.14.0-362.24.1.el9_3.x86_64) scriptlet failed, exit status 127
        error: kernel-core-5.14.0-362.24.1.el9_3.x86_64: erase failed
        
        1. Only the kernel package gets removed with kernel-core failed erase and preuninstall scriptlet errors

      convert2rhel reproducer

      1. follow steps 1 & 2 from the minimal reproducer and attempt a full conversion
      2. convert2rhel -y --debug -u username -p password --serverurl url 

      This could be possibly prevented by early check of the grub file validity similarly as done in the minimal reproducer and cehck for the returncode.
      We could raise an error during the analysis and ask the user to fix the grub file.

      ### INVALID FILE 
      >>> import subprocess
      >>> subprocess.run(["grub2-mkconfig"], stdout=subprocess.DEVNULL)
      /etc/default/grub: line 2: GRUB_CMDLINE_LINUX: command not found
      CompletedProcess(args=['grub2-mkconfig'], returncode=127)
      
      ### VALID FILE
      >>> subprocess.run(["grub2-mkconfig"], stdout=subprocess.DEVNULL)
      Generating grub configuration file ...
      Adding boot menu entry for UEFI Firmware Settings ...
      done
      CompletedProcess(args=['grub2-mkconfig'], returncode=0)
      

              prwatson@redhat.com Preston Watson
              ddiblik@redhat.com Daniel Diblik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: