Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2125408

Summary: convert2rhel fails with unable to add a new UEFI bootloader entry for RHEL
Product: Red Hat Enterprise Linux 7 Reporter: Marko Blazic <no-reply>
Component: convert2rhelAssignee: Michal Bocek <mbocek>
Status: CLOSED ERRATA QA Contact: Upgrades and Supportability <upgrades-and-supportability>
Severity: medium Docs Contact: Miriam Portman <mportman>
Priority: unspecified    
Version: 7.9CC: ddiblik, fgustavs, fkrska, pjones, pstodulk
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-14 10:10:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
convert2rhel full log none

Description Marko Blazic 2022-09-08 21:43:29 UTC
Description of problem:
When running convert2rhel, the process fails during the "Convert: Configure the bootloader" step, stating "CRITICAL - Unable to add a new UEFI bootloader entry for RHEL."


Version-Release number of selected component (if applicable):
version: 1.0
package: convert2rhel-1.0-1.el7.noarch


How reproducible:
100%


Steps to Reproduce:
1. Install CentOS
2. Run convert2rhel


Actual results:
Most of the conversion succeeds, beyond the point of no return.  Kernel is installed, all packages are replaced.  Finally near the end, we get:

Adding 'Red Hat Enterprise Linux 7' UEFI bootloader entry.
[09/08/2022 22:38:33] FILE - Calling command '/usr/sbin/efibootmgr --create --disk /dev/sdi --part 129 --loader \EFI\redhat\shimx64.efi --label Red Hat Enterprise Linux 7'
[09/08/2022 22:38:33] FILE - efibootmgr output:
-----
Could not prepare Boot variable: Function not implemented

-----
CRITICAL - Unable to add a new UEFI bootloader entry for RHEL.
The migration of the bootloader setup was not successful.
Do not reboot your machine before doing a manual check of the
bootloader configuration. Ensure that grubenv and grub.cfg files
are present in the /boot/efi/EFI/redhat/ directory and that
a new bootloader entry for Red Hat Enterprise Linux exists
(check `efibootmgr -v` output).
The entry should point to '\EFI\redhat\shimx64.efi'.
[09/08/2022 22:38:33] FILE - Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/convert2rhel/main.py", line 117, in main
    post_ponr_conversion()
  File "/usr/lib/python2.7/site-packages/convert2rhel/main.py", line 240, in post_ponr_conversion
    grub.post_ponr_set_efi_configuration()
  File "/usr/lib/python2.7/site-packages/convert2rhel/grub.py", line 581, in post_ponr_set_efi_configuration
    _log_critical_error(e.message)
  File "/usr/lib/python2.7/site-packages/convert2rhel/grub.py", line 643, in _log_critical_error
    "The entry should point to '\\EFI\\redhat\\shimx64.efi'." % (title, RHEL_EFIDIR_CANONICAL_PATH)
  File "/usr/lib/python2.7/site-packages/convert2rhel/logger.py", line 184, in _critical
    sys.exit(msg)
SystemExit: Unable to add a new UEFI bootloader entry for RHEL.
The migration of the bootloader setup was not successful.
Do not reboot your machine before doing a manual check of the
bootloader configuration. Ensure that grubenv and grub.cfg files
are present in the /boot/efi/EFI/redhat/ directory and that
a new bootloader entry for Red Hat Enterprise Linux exists
(check `efibootmgr -v` output).
The entry should point to '\EFI\redhat\shimx64.efi'.

WARNING - Conversion process interrupted and manual user intervention will be necessary.


root@machine:~# efibootmgr -v
BootCurrent: 0006
BootOrder: 0006,0000,0001,0002,0003,0004,0005
Boot0000* EFI VMware Virtual SATA Hard Drive (1.0)      /Pci(0x11,0x0)/Pci(0x1,0x0)/Sata(1,0,0)
Boot0001* EFI VMware Virtual SATA Hard Drive (2.0)      /Pci(0x11,0x0)/Pci(0x1,0x0)/Sata(2,0,0)
Boot0002* EFI VMware Virtual SATA CDROM Drive (0.0)     /Pci(0x11,0x0)/Pci(0x1,0x0)/Sata(0,0,0)
Boot0003* EFI Network   /Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(000c29cde1e1,1)
Boot0004* EFI Network 1 /Pci(0x17,0x0)/Pci(0x0,0x0)/MAC(000c29cde1eb,1)
Boot0005* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xef90018,0xf3f6017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0006* CentOS        HD(1,GPT,7d501302-2dc2-460b-bf53-8b38b8499478,0x800,0x200000)/File(\EFI\centos\shimx64.efi)

Expected results:
The efi boot entry should succeed, and the process should continue.


Additional info:
root@machine:~# blkid
/dev/mapper/vg0-root: LABEL="root" UUID="335ebad8-bff3-44e2-9dc2-4515d368ae33" TYPE="ext4"
/dev/sdi3: UUID="lIsCW3-qKTc-UXrZ-2Fm9-fKdy-rriX-9rCeJP" TYPE="LVM2_member" PARTUUID="b879e134-e92f-45a4-a10e-3aec83ed3a64"
/dev/sdi2: LABEL="boot" UUID="62b36c56-dd60-435a-b0fd-3e0828447328" TYPE="ext4" PARTUUID="f0a26559-ba8c-4fd5-ad10-01368495dec3"
/dev/sdi1: LABEL="bootefi" UUID="DCA8-C17A" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="7d501302-2dc2-460b-bf53-8b38b8499478"
/dev/sdf1: LABEL="tank0" UUID="1423547846853167669" UUID_SUB="2742669453951396671" TYPE="zfs_member" PARTLABEL="zfs-193eec712d60a743" PARTUUID="82e5f604-825a-ef4d-bf0a-d6f54261e167"
/dev/sdf9: PARTUUID="dc8d2238-322b-d64e-b814-4508d0637768"
/dev/sde1: LABEL="tank0" UUID="1423547846853167669" UUID_SUB="6394520241064154399" TYPE="zfs_member" PARTLABEL="zfs-1d306a00dba61241" PARTUUID="b8e43cc6-6ad2-1a48-b9e1-5edb34a320bb"
/dev/sde9: PARTUUID="47601dcb-47fe-3145-b3ae-3ea894dfa43c"
/dev/sda1: LABEL="tank0" UUID="1423547846853167669" UUID_SUB="14663582042536603456" TYPE="zfs_member" PARTLABEL="zfs-54e881033d190c4a" PARTUUID="b2a9ebe9-a42e-4546-bc99-8a52edeb7a1e"
/dev/sda9: PARTUUID="60cc1946-4ac7-1e4e-9d28-35f43db31707"
/dev/sdh1: LABEL="tank0" UUID="1423547846853167669" UUID_SUB="473863182441896125" TYPE="zfs_member" PARTLABEL="zfs-9c91d52e4a3fc1df" PARTUUID="fcc5d27b-4e13-c648-9e07-a496b60163b9"
/dev/sdh9: PARTUUID="593716ca-c7e9-9042-8d53-17bde181b2d5"
/dev/sdd1: LABEL="tank0" UUID="1423547846853167669" UUID_SUB="15115090788857953475" TYPE="zfs_member" PARTLABEL="zfs-1e67d6e559188035" PARTUUID="ede964c6-2c38-a54c-902e-64c87a49d377"
/dev/sdd9: PARTUUID="3524b1de-0f6c-6c4d-952b-d7555721c205"
/dev/sdg1: LABEL="tank0" UUID="1423547846853167669" UUID_SUB="8614585476245893985" TYPE="zfs_member" PARTLABEL="zfs-bd489f58ccdb98ae" PARTUUID="f192deab-7370-db48-a480-42f4675af995"
/dev/sdg9: PARTUUID="be030176-a81d-f742-94d1-a680a6c55a65"
/dev/mapper/vg0-opt: LABEL="opt" UUID="1bfca40e-ea66-4a44-ae54-e3d084bc3f38" TYPE="ext4"
/dev/mapper/vg0-var: LABEL="var" UUID="f1d13977-473d-4e26-93bf-cc098866a267" TYPE="ext4"
/dev/mapper/vg0-tmp: LABEL="tmp" UUID="471a1101-4874-4d72-8767-d69efb6ff955" TYPE="ext4"
/dev/mapper/vg0-vartmp: LABEL="vartmp" UUID="6df4cf46-0c0f-46fc-9528-71ee79f05dc5" TYPE="ext4"

Comment 3 Freya Gustavsson 2022-09-09 10:59:33 UTC
Hi @mblazic! 

I will follow up with folks to find out more information about the bug, in the meantime could you give me some info?

Is the system up to date?

Can you provide a full convert2rhel.log file? If you run the efibootmgr command by itself, is there anything more outputted? (we only capture stdout)

Comment 4 Marko Blazic 2022-09-09 11:14:05 UTC
Created attachment 1910656 [details]
convert2rhel full log

Comment 5 Marko Blazic 2022-09-09 11:17:35 UTC
Hi @egustavs,

yes, the system is fully updated:
root@machine:~# yum update
...
No packages marked for update

Full convert2rhel.log file is in the attachment above.

Manual run:
root@machine1:~# /usr/sbin/efibootmgr --create --disk /dev/sdi --part 129 --loader \EFI\redhat\shimx64.efi --label Red Hat Enterprise Linux 7
Could not prepare Boot variable: Function not implemented


Please let me know of you need anything else.

Comment 6 Peter Jones 2022-09-09 15:54:00 UTC
> [09/08/2022 22:38:33] FILE - Calling command 'lsblk -spnlo name /dev/sdi1'
> [09/08/2022 22:38:33] FILE - Block device: /dev/sdi
> [09/08/2022 22:38:33] FILE - ESP device number: {'major': 8, 'minor': 129}
> [09/08/2022 22:38:33] FILE - The new UEFI binary: /boot/efi/EFI/redhat/shimx64.efi
> Adding 'Red Hat Enterprise Linux 7' UEFI bootloader entry.
> [09/08/2022 22:38:33] FILE - Calling command '/usr/sbin/efibootmgr --create --disk /dev/sdi --part 129 --loader \EFI\redhat\shimx64.efi --label Red Hat Enterprise Linux 7'

This looks wrong to me; that should be "--part 1" not "--part 129"

> [09/08/2022 22:38:33] FILE - efibootmgr output:
> Could not prepare Boot variable: Function not implemented

Comment 7 Marko Blazic 2022-09-09 23:03:26 UTC
Hi @pjones,

I took a look into the code, specifically into /usr/lib/python2.7/site-packages/convert2rhel/grub.py:
    410     # The new boot entry is being set as first in the boot order
    411     cmd = [
    412         "/usr/sbin/efibootmgr",
    413         "--create",
    414         "--disk",
    415         blk_dev,
    416         "--part",
    417         str(dev_number["minor"]),
    418         "--loader",
    419         efi_path,
    420         "--label",
    421         label,
    422     ]


so as argument for --part is taking:
    417         str(dev_number["minor"]),

so from there:
    387     dev_number = _get_device_number(get_efi_partition())


     53 def _get_device_number(device):
    154     """Return dict with 'major' and 'minor' number of the specified device/partition."""
    155     output, ecode = utils.run_subprocess(["lsblk", "-spnlo", "MAJ:MIN", device], print_output=False)
    156     if ecode:
    157         logger.debug("lsblk output:\n-----\n%s\n-----" % output)
    158         raise BootloaderError("Unable to get information about the '%s' device" % device)
    159     # for partitions the output contains multiple lines (for the partition
    160     # and all parents till the devices itself). We want maj:min number just
    161     # for the specified device/partition, so take the first line only
    162     majmin = output.splitlines()[0].strip().split(":")
    163     return {"major": int(majmin[0]), "minor": int(majmin[1])}


root@machine:~# lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
...
sdi              8:128  0   50G  0 disk
├─sdi1           8:129  0    1G  0 part /boot/efi
├─sdi2           8:130  0    1G  0 part /boot
└─sdi3           8:131  0   48G  0 part
  ├─vg0-root   253:0    0   10G  0 lvm  /
  ├─vg0-opt    253:1    0    2G  0 lvm  /opt
  ├─vg0-var    253:2    0   10G  0 lvm  /var
  ├─vg0-tmp    253:3    0    2G  0 lvm  /tmp
  └─vg0-vartmp 253:4    0    5G  0 lvm  /var/tmp
sr0             11:0    1 1024M  0 rom


convert2rhel has correctly found that EFI partition is:
sdi1           8:129  0    1G  0 part /boot/efi

Comment 8 Freya Gustavsson 2022-09-12 14:58:38 UTC
Hi Marco

I can confirm this is a bug with how we grab the partition number. Thanks for reporting it!

We will tackle this to get it fixed for our next version if we have the capacity, we will also update this BZ and our known issues section once a workaround has been created and verified

In the meantime, it would be correct to provide --part 1 to the efibootmgr in this case instead of 129 if you want to change the code yourself for now.

Comment 10 Marko Blazic 2022-09-12 16:35:33 UTC
Hi @egustavs, 

thank you for the information.
I have managed to find a quick solution by removing the HBA controller/disks except OS disk, after reboot sdi will become sda so convert2rhel can use --part 1.

Comment 13 Daniel Diblik 2023-03-07 17:33:53 UTC
This bug was tested as a part of manual regression testing on version convert2rhel-1.1-1.el7.noarch.rpm and convert2rhel-1.2-2.el7.noarch.rpm with their respective results provided in the JIRA issue comments due to BZ comment limitations.
https://issues.redhat.com/browse/RHELC-733?focusedCommentId=21861036&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-21861036

Comment 15 errata-xmlrpc 2023-03-14 10:10:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (convert2rhel bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2023:1197