RHEL7: how to strace the reboot phase of leapp

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7
    • leapp

Issue

  • I need to strace the reboot phase of leapp when upgrading from RHEL7 to RHEL8, because of some error showing up for which the log is not sufficient to find the root cause

Resolution

There are 3 files to modify to record an strace during the reboot phase.

  1. Install the strace package

    # yum install strace
    
  2. Add strace as a required package

    Edit /usr/share/leapp-repository/repositories/system_upgrade/common/actors/commonleappdracutmodules/libraries/modscan.py (new line) to add new line 42:

      42     'strace',
    

    Note above the trailing comma.

  3. Add strace as a requisite in the upgrade initramfs

    Edit /usr/share/leapp-repository/repositories/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh to add new lines 87 and 88:

      87     DRACUT_INSTALL="$DRACUT_INSTALL strace"
      88 
    
  4. Update the leapp upgrade command to execute under strace

    Edit /usr/share/leapp-repository/repositories/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh to modify line 239:

     239     /usr/bin/systemd-nspawn $NSPAWN_OPTS -D "$NEWROOT" /usr/bin/bash -c "mount -a; /usr/bin/strace -fttTvyy -s 256 -o /var/lib/leapp/leapp_reboot.strace -- $LEAPPBIN upgrade --resume $args"
    

    Important note: the strace output is stored as /var/lib/leapp/leapp_reboot.strace as in the example above. You may change this path, just make sure there is several Gigabytes of free space on the chosen mount point, because the strace output may be extremely large, depending on when the leapp reboot phase fails.

  5. Re-execute leapp upgrade to regenerate the upgrade initramfs

    # leapp upgrade [...]
    
  6. Confirm that strace is now embedded in the upgrade initramfs

    # lsinitrd /boot/initramfs-upgrade.x86_64.img | grep strace
    Arguments: -v -v -v -v --force --conf '/dev/null' --confdir '/var/empty' --install 'systemd-nspawn strace' --add 'sys-upgrade-redhat' --add 'sys-upgrade' --add 'sys-upgrade-redhat' --add 'sys-upgrade' --nomdadmconf --nolvmconf --no-hostonly --kver '4.18.0-553.53.1.el8_10.x86_64' --kernel-image 'vmlinuz-upgrade.x86_64'
    -rwxr-xr-x   1 root     root      2066344 Jan 15  2024 usr/bin/strace
    
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.