From 13e04601a55ae89a1778685f60fa7b724d15d1cb Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 2 Jan 2025 16:01:39 -0800 Subject: [PATCH 1/5] efi/loader/run_qemu.conf: remove bogus "source" line Fixes the following `bootctl` warning: ``` /efi/loader/entries/run-qemu-kernel-6.12.0-dirty.conf:6: Unknown line 'source', ignoring. ``` The path argument does not make sense either. This line came with big commit 01c2116cb713 ("run_qemu: fix bootable disk images"). Note `bootctl` _outputs_ a line prefixed with `source: foo.conf`, so maybe that's where the confusion came from. Signed-off-by: Marc Herbert --- run_qemu.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/run_qemu.sh b/run_qemu.sh index aa198aa..6296c9b 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -785,7 +785,6 @@ update_rootfs_boot_kernel() sudo tee "$conffile" > /dev/null <<- EOF title run-qemu-$_distro ($kver) version $kver - source /efi/EFI/Linux/linux-$kver.efi linux EFI/Linux/linux-$kver.efi options ${kcmd[*]} EOF From f437f5ec17b2543730e8e3d37ec12f24b910da28 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 2 Jan 2025 17:40:16 -0800 Subject: [PATCH 2/5] run_qemu.sh: rename move and kernel in ESP outside of EFI/ directory Clears confusion and fixes the following error message: "Parsed PE file '/efi/EFI/Linux/linux-6.12.0-dirty.efi' is not a UKI." The EFI/ directory is for stuff that EFI can actually run. Also stop appending a bogus and confusing ".efi" filename extension. Signed-off-by: Marc Herbert --- run_qemu.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run_qemu.sh b/run_qemu.sh index 6296c9b..762ddd3 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -781,15 +781,16 @@ update_rootfs_boot_kernel() fail "Unable to determine root partition UUID, is the mkosi image 'Bootable'?" fi + # Note there is no initrd when booting this way, root filesystem must be built-in. build_kernel_cmdline "PARTUUID=$root_partuuid" sudo tee "$conffile" > /dev/null <<- EOF title run-qemu-$_distro ($kver) version $kver - linux EFI/Linux/linux-$kver.efi + linux run-qemu-kernel/$kver/vmlinuz options ${kcmd[*]} EOF sudo mkdir -p "$builddir/mnt/run-qemu-kernel/$kver" - sudo cp "$builddir/mkosi.extra/boot/vmlinuz-$kver" "$builddir/mnt/EFI/Linux/linux-$kver.efi" + sudo cp "$builddir/mkosi.extra/boot/vmlinuz-$kver" "$builddir/mnt/run-qemu-kernel/$kver/vmlinuz" defconf="$builddir/mnt/loader/loader.conf" if [ -f "$defconf" ]; then From 8f0c60b67b82f7f4b76742db7303fcb7a098b1fb Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 2 Jan 2025 17:43:23 -0800 Subject: [PATCH 3/5] run_qemu.sh: install Shell.efi if found It is automatically offered by systemd-boot when in the right place. Signed-off-by: Marc Herbert --- run_qemu.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/run_qemu.sh b/run_qemu.sh index 762ddd3..e9a3397 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -800,6 +800,13 @@ update_rootfs_boot_kernel() echo "timeout 4" | sudo tee "$defconf" fi echo "default run-qemu-kernel-$kver.conf" | sudo tee -a "$defconf" + + # Fedora + sudo cp "$ovmf_path"/Shell.efi "$builddir"/mnt/shellx64.efi || + # Arch Linux + sudo cp /usr/share/edk2-shell/x64/Shell_Full.efi "$builddir"/mnt/shellx64.efi || + true + umount_rootfs 1 mount_rootfs 2 # Linux root partition @@ -1303,7 +1310,7 @@ get_ovmf_binaries() fi if ! [ -e "OVMF_CODE.fd" ] && ! [ -e "OVMF_VARS.fd" ]; then if [ ! -f "$ovmf_path/OVMF_CODE.fd" ]; then - echo "OVMF binaries not found, please install 'edk2-ovmf' or similar" + echo "OVMF binaries not found, please install '[edk2-]ovmf' or similar, 'edk2-shell', ..." exit 1 fi cp "$ovmf_path/OVMF_CODE.fd" . From 264a084e61e85ee1121c39129344582f6884acce Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 3 Jan 2025 07:06:11 -0800 Subject: [PATCH 4/5] Fix ../efi/run-qemu-kernel symbolic link in /boot Fixes commit b4a9b653af80 ("run_qemu: remove unnecessary pushd/popd in update_rootfs_boot_kernel"). I still don't know what is the purpose of this symbolic link but now it at least points to something: what it used to point at before b4a9b653af80 Signed-off-by: Marc Herbert --- run_qemu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_qemu.sh b/run_qemu.sh index e9a3397..53b39ac 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -810,7 +810,7 @@ update_rootfs_boot_kernel() umount_rootfs 1 mount_rootfs 2 # Linux root partition - sudo ln -sf "$builddir/mnt/efi/run-qemu-kernel" "$builddir/mnt/boot/run-qemu-kernel" + sudo ln -sf "../efi/run-qemu-kernel" "$builddir/mnt/boot/run-qemu-kernel" umount_rootfs 2 } From dfd88ca3c0783e70eab44fc2423faea3f26f5897 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 3 Jan 2025 10:50:18 -0800 Subject: [PATCH 5/5] run_qemu.sh: fix broken symlinks System.map and vmlinuz This does not fix #88 at all but clears some of the confusion around it. Fixes: ``` $ file qbuild/mkosi.extra/boot/* qbuild/mkosi.extra/boot/System.map: broken symbolic link to ./qbuild/mkosi.extra/boot/System.map-6.12.0-dirty qbuild/mkosi.extra/boot/vmlinuz: broken symbolic link to ./qbuild/mkosi.extra/boot/vmlinuz-6.12.0-dirty ``` Fixes commit f9d733065053 ("run_qemu: work around new systemd-based installkernel") which added these symbolic links. They never worked. Signed-off-by: Marc Herbert --- run_qemu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_qemu.sh b/run_qemu.sh index 53b39ac..9fce026 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -446,8 +446,8 @@ make_install_kernel() cat arch/x86_64/boot/bzImage > "$inst_path"/vmlinuz-"$kver" cp System.map "$inst_path"/System.map-"$kver" - ln -fs "$inst_path"/vmlinuz-"$kver" "$inst_path"/vmlinuz - ln -fs "$inst_path"/System.map-"$kver" "$inst_path"/System.map + ln -fs vmlinuz-"$kver" "$inst_path"/vmlinuz + ln -fs System.map-"$kver" "$inst_path"/System.map } install_build_initrd()