Unable to boot image installed in UEFI partition

Hello, I’m trying to install Haiku on a partition on a 64-bit EUFI machine and run it within qemu-kvm. I’ve set the partition type to 42465331-3BA3-10F1-802A-4861696B7521 and performed the build, apparently without errors.

The build host is Gentoo. The partition is /dev/sda3 and (obviously) has ownership and permissions which allow me to write to it.

The qemu command is:

qemu-system-x86_64 -m 512M -cpu host -enable-kvm -nodefaults -smp 1,cores=1 -vga std -net nic -net user -device virtio-scsi-pci,id=scsi -drive file=/dev/sda3,format=raw,media=disk

The error is that the Haiku boot loader can’t find and boot volumes. I’ve also tried to install by running:

qemu-system-x86_64 -m 512M -cpu host -boot order=d -enable-kvm -nodefaults -smp 1,cores=1 -vga std -net nic -net user -drive if=virtio,id=disk.0,file=haiku-qemu.image,format=raw,media=cdrom,index=1 -device virtio-scsi-pci,id=scsi -drive if=virtio,file=/dev/sda3,format=raw,media=disk,index=0

which boots from the created CD-ROM image and allows me to perform an installation to the HDD, again apparently without any warning messages or complaints.
So why is it that I can never boot from the hard disk image/partition?
Is it because the built Haiku system is 32-bit? In which case, why doesn’t the CD build fail?
The boot loader log ends with:

...
add_partitions_for(0x001058f8, mountFS = yes)
add_partitions_for(fd = 2, mountFS = yes)
0x00106088 Partition::Partition
0x00106088 Partition::Scan()
check for partitioning_system: GUID Partition MaScan()
check for partitioning_system: Intel Partition MaScan()
  priority: 500
check for partitioning_system: Intel Extended Partition
0x00106088 Partition::_Mount check for file_system: BFS Filesystem
PackageVolumeInfo::SetTo()
PackageVolumeInfo::_InitState(): failed to parse activated-packages: No such file or directory
PackageVolumeInfo::SetTo(): failed to open administrative directory: No such file or directory
../../source/src/system/boot/loader/file_systems/packagefs/packagefs.cpp: 846: Bad data
PackageVolumeInfo::SetTo()
PackageVolumeInfo::_InitState(): failed to parse activated-packages: No such file or directory
PackageVolumeInfo::SetTo(): failed to open administrative directory: No such file or directory
../../source/src/system/boot/loader/file_systems/packagefs/packagefs.cpp: 846: Bad data

If I qemu boot with the CD-ROM image, I can mount and explore the HDD partition. But I can’t boot from it. Why not?

Yes, the EFI loader doesn’t support 32-bit kernels.

However, I find it very interesting that the message from packagefs is “bad data.” That seems pretty weird; I’d expect the error to occur much later when attempting to load the kernel itself. Perhaps there’s some problem we need to try and investigate here; I seem to recall that @Evgen saw the same thing on his boot failure ticket.

I didn’t ask for, or want, the EFI loader. Isn’t there any way of making this a purely 32-bit installation? or set up a small separate booting partition?

Oh, then in that case, this isn’t the EFI loader but rather the BIOS loader, in which case this may be a duplicate of @Evgen’s #14993.

If you can actually reproduce it in QEMU, that’s extremely interesting. I (and I don’t think anyone else besides Evgen) has seen it anywhere else. Can you please try and investigate? I guess if you’ve figured out how to build Haiku, you may have enough skills to try and debug whatever is going on :slight_smile:

I added some more debugging code in hrev53090 which should add another error besides “bad data.” This should help with figuring out what’s going on.

I added comment to #14993

The debug log now reads, at the end:

PackageVolumeInfo::SetTo()
PackageVolumeInfo::_InitState(): failed to parse activated-packages: No such file or directory
PackageVolumeInfo::SetTo(): failed to open administrative directory: No such file or directory
Error: Invalid package file: Total size in header (51237355) doesn't agree with total file size (51238912)
../../source/src/system/boot/loader/file_systems/packagefs/packagefs.cpp: 846: Bad data

I rebooted with the CD-ROM image I’d created, mounted the HDD partition image, but couldn’t find any file with package in the name, and no file of more than 5 MiB in size.

The file is probably the main Haiku package file in /system/packages. What is its size?

Using Alt-I (Get Info):

| file | size in bytes |
| /system/packages | 507,746,304 |
| /system/packages/haiku-r1-beta1_hrev53091-1-x86_gcc2.hpkg | 51,238,912 |
| /system/packages/gcc_x86-7.3.0_2018_05_01-3-x86_gcc2.hpkg | 45,331,560 |

I erroneously reported the size in the previous post as 51230912; I have corrected that post. The size, as reported in the build log, equals the size reported by Get Info on haiku-r1-beta1_hrev53091-1-x86_gcc2.hpkg.

I don’t understand why I couldn’t previously find a file of more than 5 MiB in size. I used:

find * -size +5000000c -ls

but must have been in the wrong directory.

In the Linux host:

$ find * -name haiku-r1?beta1_hrev53091-1-x86_gcc2.hpkg -ls
2375233  50040 -rw-r--r--   1  mounty   users    51237355 Apr 23 17:55 objects/haiku/x86_gcc2/packaging/repositories/Haiku/packages/haiku-r1~beta1_hrev53091-1-x86_gcc2.hpkg

Just thought I’d mention that. Looks like it’s being rounded-up to the next 4 KiB. This has not happened to the package in the created CDROM image.

Hello Waddlesplash; I appreciate that you may have other things to do in your life than fix this one bug, but do you need any input from me? Now that it looks like a bug rather than just a misunderstanding, shall I enter it into the bug-tracker?

No, because it’s precisely the same bug as linked above. So you can just subscribe to that.

As I commented there, I am pretty stumped.