pmem / run_qemu

A script to create bootable OS images, and run qemu with a locally built kernel.
Creative Commons Zero v1.0 Universal
58 stars 22 forks source link

sed: can't read ./qbuild/mnt/loader/loader.conf: No such file or directory #8

Open hishine6 opened 2 years ago

hishine6 commented 2 years ago

Hello,

I am currently trying to apply this script with the following materials.

Since my host OS is Ubuntu(20.04), I am trying out the recently merged "Add Ubuntu Support" to install ubuntu-bionic(18.04). But I am facing the following error.

After successfully going through "build_kernel" and "make_rootfs" (I have used the command 'sudo run_qemu.sh --cxl --git-qemu') an error occurs during 'update_rootfs_boot_kernel'.

sed: can't read ./qbuild/mnt/loader/loader.conf: No such file or directory

In line 491 of 'run_qemu.sh', there is a reference to '$builddir/mnt/loader/loader.conf'. So to check this out, I have manually mounted the EFI system partition (using losetup, mount) and checked the /mnt/loader directory. It only contained a directory named 'entries'.

I tried to solve this myself, and looked through all the scripts, but I couldn't find any other part where it mounted the EFI system partition rather than 'update_rootfs_boot_kernel'. Could it be because of some sort of mkosi error?

Thank you for your time.

hishine6 commented 2 years ago

I have passed on this issue by manually creating a "/mnt/loader/loader.conf" file and running the script again. I am not sure what the future consequences would be, but it looks like it works just fine for now.

Thank you.

stellarhopper commented 2 years ago

@hishine6 It is possible that mkosi doesn't setup systemd-boot for Ubuntu 18.x - Can you check if using a more recent Ubuntu for the guest helps?

What that part of the script is trying to do is set up standalone booting in the image so it can be used outside of qemu's direct kernel boot. The setup is specific to the systemd-boot bootloader, so maybe if that isn't found, we should warn and continue without the bootable image setup instead of failing.

hishine6 commented 2 years ago

@stellarhopper Does that mean that in my case, where only using the image to boot through qemu, it won't be a problem?

Also, I have tried out the guest version to "focal"(20.XX), but unfortunately it returned the same results.

Based on the advise you have gave me, I have looked into the mkosi(version 12) codes. Searching through the codes using the key word 'systemd-boot', I have found the following code part in "mkosi/mkosi/init.py"

1645     if args.get_partition(PartitionIdentifier.esp):
1646         # These distros need uefi_stub configured explicitly for dracut to find the systemd-boot uefi stub.
1647         if args.distribution in (Distribution.ubuntu,
1648                                  Distribution.debian,
1649                                  Distribution.mageia,
1650                                  Distribution.openmandriva,
1651                                  Distribution.gentoo):
1652             dracut_dir.joinpath("30-mkosi-uefi-stub.conf").write_text(
1653                 "uefi_stub=/usr/lib/systemd/boot/efi/linuxx64.efi.stub\n"
1654             )
1655 
1656         # efivarfs must be present in order to GPT root discovery work
1657         dracut_dir.joinpath("30-mkosi-efivarfs.conf").write_text(
1658             '[[ $(modinfo -k "$kernel" -F filename efivarfs 2>/dev/null) == /* ]] && add_drivers+=" efivarfs "\n'
1659         )

It seems like it needs additional configuration in order to use the systemd-boot in ubuntu. I am not 100% sure about this, but judging from that it originally worked for fedora & arch and not on ubuntu I think this was the problem. So, I assume that, like you kindly explained above, the run_qemu.sh should show a warning for 'distro=ubuntu' and continue the script process.

Perhaps, something like if [[ -f $defconf ]]; then in 'update_rootfs_boot_kernel'..? It worked for me, but I am not sure that other lines are necessary.

I hope this makes sense and helps! Thank you.