Skip to content

Commit 37a1853

Browse files
committed
overlay/ignition: delete pre-existing bootuuid.cfg
In our disk images, bootupd inject a grub script that looks for a `/boot/grub2/bootuuid.cfg` to find the boot partition. If the file is not present, the label `boot` is used to find the partition. See [1] for more. During the first boot, the hard-coded uuid of the boot partition is replaced with a random one [2]. However this happen in two phases: First `coreos-gpt-setup.service` assigns a new UUID to the partition, Then `coreos-boot-edit.service` writes that new uuid to `/boot/grub2/bootuuid.cfg`. However, when ignition needs to reboot (e.g. for applying a karg), the reboot happens between the two. In `bootc install to-disk` the UUID of the boot partition is written to `/boot/grub2/bootuuid.cfg`, so it will be present at first boot. But if we restamp the parition then reboot, the original `bootuuid.cfg` is still there, preventing the reboot. So let's delete this file just before the restamp, so we don't end up in this inconsistent state. This allows us to use `bootc install to-disk` to build our disk images. See [3][4]. [1] https://github.com/coreos/bootupd/blob/1768f31c85b5d8cd72f4339ab669b703d7071b51/src/grub2/grub-static-pre.cfg [2] https://github.com/coreos/fedora-coreos-config/blob/testing-devel/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-gpt-setup.service [3] https://issues.redhat.com/browse/COS-3374 [4] coreos/coreos-assembler#4224
1 parent 79736c3 commit 37a1853

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-gpt-setup.service

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ OnFailureJobMode=isolate
2828
Type=oneshot
2929
RemainAfterExit=yes
3030
ExecStart=/usr/sbin/coreos-gpt-setup /dev/disk/by-label/boot
31+
# MountFlags=slave is so the umount of /boot is guaranteed to happen.
32+
# /boot will only be mounted for the lifetime of the unit.
33+
MountFlags=slave

overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-gpt-setup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ if [ "${PTUUID:-}" != "$UNINITIALIZED_GUID" ]; then
2626
exit 0
2727
fi
2828

29+
30+
# Mount /boot. Note that we mount /boot but we don't unmount it because we
31+
# are run in a systemd unit with MountFlags=slave so it is unmounted for us.
32+
bootmnt=/mnt/boot_partition/
33+
bootdev=/dev/disk/by-label/boot
34+
mount -o rw ${bootdev} ${bootmnt}
35+
# Make sure we delete any pre-existing bootuuid.cfg
36+
# bootc install stamps it during the disk image creation
37+
# since we are changing the uuid here we want to remove this file
38+
# otherwise it will prevent a reboot
39+
rm -f ${bootmnt}/grub2/bootuuid.cfg
40+
41+
2942
echo "Randomizing disk GUID"
3043
sgdisk --disk-guid=R --move-second-header "$PKNAME"
3144
udevadm settle || :

0 commit comments

Comments
 (0)