Skip to content

Commit

Permalink
coreos-boot-edit: run rdcore bind-boot
Browse files Browse the repository at this point in the history
This binds the bootloader to the bootfs and the bootfs to the rootfs.

Part of coreos/fedora-coreos-tracker#976.
  • Loading branch information
jlebon authored and HuijingHei committed Oct 10, 2023
1 parent 568cbdf commit be968dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
15 changes: 13 additions & 2 deletions tests/kola/reboot/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit be968dd

Please sign in to comment.