diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh index 4116f03217..cf2e9c3c3e 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh @@ -34,18 +34,12 @@ if [ -z "${root}" ]; then rdcore rootmap /sysroot --boot-mount ${bootmnt} fi -# And similarly, only inject boot= if it's not already present. -boot=$(karg boot) -if [ -z "${boot}" ]; then - # XXX: `rdcore rootmap --inject-boot-karg` or maybe `rdcore bootmap` - eval $(blkid -o export "${bootdev}") - if [ -z "${UUID}" ]; then - # This should never happen - echo "Boot filesystem ${bootdev} has no UUID" >&2 - exit 1 - fi - rdcore kargs --boot-mount ${bootmnt} --append boot=UUID=${UUID} - # but also put it in /run for the first boot real root mount - mkdir -p /run/coreos - echo "${UUID}" > /run/coreos/bootfs_uuid -fi +# This does a few things: +# 1. it puts the boot UUID in /run/coreos/bootfs_uuid which is used by the real +# root for mounting the bootfs in this boot +# 2. it adds a boot=UUID= karg which is used by the real root for mounting the +# bootfs in subsequent boots +# 3. it create a .root_uuid stamp file on the bootfs or fails if one exists +# 4. it adds GRUB bootuuid.cfg dropins so that GRUB selects the boot filesystem +# by UUID +rdcore bind-boot /sysroot ${bootmnt} diff --git a/tests/kola/reboot/test.sh b/tests/kola/reboot/test.sh index 9d9fa0b9e8..f10e51632e 100755 --- a/tests/kola/reboot/test.sh +++ b/tests/kola/reboot/test.sh @@ -20,6 +20,15 @@ if ! systemctl cat boot.mount | grep -q What=/dev/disk/by-uuid; then fi ok "boot mounted by UUID" +# check that we took ownership of the bootfs +[ -f /boot/.root_uuid ] + +# check for the UUID dropins +[ -f /boot/grub2/bootuuid.cfg ] +mount -o ro /dev/disk/by-label/EFI-SYSTEM /boot/efi +[ -f /boot/efi/EFI/*/bootuuid.cfg ] +umount /boot/efi + case "${AUTOPKGTEST_REBOOT_MARK:-}" in "") ok "first boot" @@ -28,10 +37,12 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in rebooted) # check for expected default kargs - grep root=UUID= /proc/cmdline + grep root=UUID=$(cat /boot/.root_uuid) /proc/cmdline ok "found root karg" - grep boot=UUID= /proc/cmdline + bootsrc=$(findmnt -nvr /boot -o SOURCE) + eval $(blkid -o export "${bootsrc}") + grep boot=UUID=${UUID} /proc/cmdline ok "found boot karg" ok "second boot"