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

leapp preupgrade fails in "checkfirstpartitionoffset" actor due to scan_grub_device_partition_layout parsing some unexpected line

    • No
    • Medium
    • 1
    • sst_upgrades
    • 12
    • 2
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • Leapp: 9.6 & 10.0
    • None
    • None
    • None

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

      When fdisk -l -u=sectors /dev/sdX displays a warning after printing the partition table, leapp parses the warning line, causing the "checkfirstpartitionoffset" to fail:

      Risk Factor: high (inhibitor)
      Title: Found GRUB devices with too little space reserved before the first partition
      Summary: On the system booting by using BIOS, the in-place upgrade fails when upgrading the GRUB2 bootloader if the boot disk's embedding area does not contain enough space for the core image installation. This results in a broken system, and can occur when the disk has been partitioned manually, for example using the RHEL 6 fdisk utility.
      
      The list of devices with small embedding area:
      - /dev/sda.
      Remediation: [hint] We recommend to perform a fresh installation of the RHEL 8 system instead of performing the in-place upgrade.
      Another possibility is to reformat the devices so that there is at least 1024 kiB space before the first partition. Note that this operation is not supported and does not have to be always possible.
      Key: 98eb0d6d72263cb21ac172fc6a612e27e48a9e91
      

      This occurs for example because of the following output returned by fdisk:

      Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 4096 bytes
      I/O size (minimum/optimal): 4096 bytes / 4096 bytes
      Disk label type: dos
      Disk identifier: 0x00033f57
      
         Device Boot      Start         End      Blocks   Id  System
      /dev/sda1            4096     4198400     2097152+  83  Linux
      /dev/sda2         4198401   167772126    81786863   8e  Linux LVM
      Partition 2 does not start on physical sector boundary.
      

      The current code in scan_grub_device_partition_layout library parses the last line Partition 2 does ..., which ends up being handled as a 3rd partition starting at offset 2.

      A solution is to skip all lines not starting with /dev, see proposed lines 74-75 (/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py):

       71     for partition_line in table_iter:
       72         # Fields:               Device     Boot   Start      End  Sectors Size Id Type
       73         # The line looks like: `/dev/vda1  *       2048  2099199  2097152   1G 83 Linux`
       74         if not partition_line.startswith('/dev/'):
       75             continue
       76         part_info = split_on_space_segments(partition_line)
       77 
       78         # If the partition is not bootable, the Boot column might be empty
       79         part_device = part_info[0]
       80         part_start = int(part_info[2]) if len(part_info) == len(part_all_attrs) else int(part_info[1])
       81         partitions.append(PartitionInfo(part_device=part_device, start_offset=part_start*unit))
      

      Please provide the package NVR for which bug is seen:

      leapp-upgrade-el7toel8-0.20.0-9.el7_9.noarch

      How reproducible:

      Always with injecting a "rogue" line in fdisk output

      Steps to reproduce

      1. Edit /usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py to insert a fake warning in fdisk output (new line 15)
         12 def get_partition_layout(device):
         13     try:
         14         partition_table = run(['fdisk', '-l', '-u=sectors', device], split=True)['stdout']
         15         partition_table.append("Partition 2 does not start on physical sector boundary.")
        
      2. Execute leapp preupgrade

      Expected results

      No issue with a standard partition layout

      Actual results

      Unrecoverable Error

            leapp-notifications leapp-notifications
            rhn-support-rmetrich Renaud Métrich
            leapp-notifications leapp-notifications
            RHEL Upgrades QE Team RHEL Upgrades QE Team
            Miriam Portman Miriam Portman
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: