Skip to content

Commit 2ea6f99

Browse files
committed
OCPBUGS-54594: update bootloader on aarch64 systems
The aarch64 kernel changed the file format [1] [2] and older RHEL8 based systems (4.12 and 4.11) need to update the bootloader otherwise the system won't boot when they get upgraded to 4.19 based on RHEL 9.6. Let's add a systemd unit here that will update the bootloader. Also need to add code that will handle the RAID case because bootupd doesn't currently handle that case. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2162369 [2] https://issues.redhat.com/browse/RHEL-25537 Fixes: https://issues.redhat.com/browse/OCPBUGS-54594
1 parent 9d8f56f commit 2ea6f99

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

overlay.d/05rhcos/usr/lib/systemd/system-preset/43-manifest-rhcos.preset

+5
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ enable nmstate.service
2222
# This unit is not activated on OSTree systems, but it still pulls in
2323
# `network-online.target`. Explicitly disable it.
2424
disable dnf-makecache.timer
25+
26+
# Enable the unit to update the bootloader on aarch64
27+
# machines so they can boot 9.6+ kernels.
28+
# https://issues.redhat.com/browse/OCPBUGS-54594
29+
enable coreos-bootupctl-update-aarch64.service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Update Bootloader for aarch64 systems
3+
Documentation=https://issues.redhat.com/browse/OCPBUGS-54594
4+
ConditionArchitecture=arm64
5+
ConditionFirmware=uefi
6+
ConditionPathExists=!/var/lib/coreos-update-bootloader-aarch64-OCPBUGS-54594.stamp
7+
8+
[Service]
9+
Type=oneshot
10+
# Only run once regardless of success or failure so we touch
11+
# our stamp file here.
12+
ExecStartPre=touch /var/lib/coreos-update-bootloader-aarch64-OCPBUGS-54594.stamp
13+
ExecStart=/usr/libexec/coreos-update-bootloader
14+
RemainAfterExit=yes
15+
MountFlags=slave
16+
17+
[Install]
18+
WantedBy=multi-user.target
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# https://issues.redhat.com/browse/OCPBUGS-54594
5+
6+
# This script updates the bootloader using bootupd
7+
# and also detects RAID-1 setups as those requires
8+
# extra steps.
9+
if [ -e /dev/disk/by-label/EFI-SYSTEM ]; then
10+
echo "Found ESP; calling 'bootupctl update'"
11+
bootupctl update
12+
exit
13+
fi
14+
15+
# Handle RAID case manually since bootupd doesn't support it.
16+
# https://github.com/coreos/bootupd/issues/132
17+
#
18+
# First we'll find the RAID device the root filesystem is
19+
# mounted from (i.e. /dev/md127).
20+
root_raid_device=$(findmnt --json --target /sysroot \
21+
| jq -r .filesystems[0].source)
22+
echo "Detected root raid device is: $root_raid_device"
23+
# Next we'll find all the devices that are a part of that
24+
# RAID array that have an ESP (i.e. a vfat formatted partition
25+
# with a label that starts with "esp-", like "esp-1", "esp-2").
26+
# and we'll capture the device name for the partition.
27+
esp_partitions=$(
28+
lsblk --paths --fs -J | \
29+
jq --arg raid_device "${root_raid_device}" -r '
30+
.blockdevices[]
31+
| select(.children[]?.children[]?.name == $raid_device)
32+
| .children[]
33+
| select(
34+
(.fstype == "vfat") and
35+
(.label != null) and
36+
(.label | startswith("esp"))
37+
)
38+
| .name')
39+
for part in $esp_partitions; do
40+
echo "Found ESP replica in ${part}; updating"
41+
mount $part /boot/efi
42+
echo "[Before Update: ${part}]"
43+
find /boot/efi/ -type f | xargs md5sum
44+
cp -rp /usr/lib/bootupd/updates/EFI /boot/efi
45+
echo "[After Update: ${part}]"
46+
find /boot/efi/ -type f | xargs md5sum
47+
umount /boot/efi
48+
done
49+
sync

0 commit comments

Comments
 (0)