From 05d531238268e3366303f91ffa2fb1552bdb6d2f Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 17 Jan 2024 20:26:31 -0600 Subject: [PATCH] fix-hybrid-mbr: Fix Hybrid GPT/MBR on RPi3 When Fedora CoreOS first boots, Ignition modifies the partition table, either to add partitions as requested in the config, or just to resize the root filesystem. In any case, this has the side effect of erasing the hybrid MBR partition table. If the hybrid MBR table is missing or incorrect, Raspberry Pi 2 and 3 devices will not be able to boot. We must therefore rebuild the missing table on first boot after Ignition has run. --- fix-hybrid-mbr.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 fix-hybrid-mbr.yaml diff --git a/fix-hybrid-mbr.yaml b/fix-hybrid-mbr.yaml new file mode 100644 index 0000000..09f279a --- /dev/null +++ b/fix-hybrid-mbr.yaml @@ -0,0 +1,36 @@ +variant: fcos +version: 1.4.0 + +storage: + files: + - path: /etc/ignition/fix-hybrid-mbr.sh + mode: 0755 + contents: + inline: |- + #!/bin/sh + + set -ex + + bootdev=$(awk '$5=="/boot"{print $10}' /proc/1/mountinfo) + sysdev=$(readlink -e /sys/class/block/${bootdev##*/}) + sysdev_parent=${sysdev%/*} + disk=/dev/${sysdev_parent##*/} + + sgdisk -h 2:EE "${disk}" + echo type=0c,bootable | sfdisk -Y mbr -N 1 "${disk}" + +systemd: + units: + - name: fix-hybrid-mbr.service + contents: |- + [Unit] + Description=Fix Hybrid MBR for Raspberry Pi 2/3 + ConditionFirstBoot=yes + + [Service] + Type=oneshot + ExecStart=/etc/ignition/fix-hybrid-mbr.sh + + [Install] + WantedBy=basic.target + enabled: true