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.
master
Dustin 2024-01-17 20:26:31 -06:00
parent 196ce46d54
commit 05d5312382
1 changed files with 36 additions and 0 deletions

36
fix-hybrid-mbr.yaml Normal file
View File

@ -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