Opened 3 years ago

Closed 3 years ago

#17039 closed bug (fixed)

EFI installation won't boot without visiting menu

Reported by: beaglejoe Owned by:
Priority: normal Milestone: Unscheduled
Component: System/Boot Loader/EFI Version: R1/Development
Keywords: Cc: jessicah
Blocked By: Blocking:
Platform: All

Description

Setting up a UEFI single disk system as described at:

https://www.haiku-os.org/guides/uefi_booting

no longer results in a (directly) bootable system.

Note: Also affects r1/beta3

Change History (17)

comment:1 by beaglejoe, 3 years ago

To duplicate:

Run qemu:

qemu-system-x86_64 -m 4096 -enable-kvm -machine q35 -smp 3 -net nic -net user \
	-hda disk1.img \
	-cdrom /haiku/haiku/generated.x86_64/haiku-nightly-anyboot.iso \
	-bios /usr/share/qemu/OVMF.fd

<Esc> to get to the EFI menu From Boot Manager set QEMU to boot from DVD Boot to 'Try out Haiku' Follow instructions here: https://www.haiku-os.org/guides/uefi_booting/

When creating the Haiku BFS partition, Label it something other than 'Haiku' as that is the name of the partition on the iso and you will be unable to tell in the boot menu which is the cd and which is the harddrive. Optionally, leave approx 32 mb unused after the BFS partition because re-creating the EFI partition here and deleting the first one will make the installation boot OK.

Reboot

To test single disk installation: Run qemu:

qemu-system-x86_64 -m 4096 -enable-kvm -machine q35 -smp 3 -net nic -net user \
	-hda disk1.img \
	-bios /usr/share/qemu/OVMF.fd

comment:2 by diver, 3 years ago

Owner: set to tqh
Status: newassigned

comment:3 by beaglejoe, 3 years ago

Tested this with haiku-r1beta3-hrev55181_23-x86_64-anyboot.iso

On Intel NUC with an empty harddrive. Install goes well, but the system cannot be booted without the boot menu appearing and you must goto 'Select boot volume' and (re)selecting the volume.

comment:4 by tqh, 3 years ago

Just to confirm: the efi app is also from same revision?

comment:5 by tqh, 3 years ago

Can you also dump the partition info or the whole syslog?

in reply to:  4 comment:6 by beaglejoe, 3 years ago

Replying to tqh:

Just to confirm: the efi app is also from same revision?

On Qemu, it was from a nightly-anyboot build of hrev55205 On the Intel Nuc, it is from haiku-r1beta3-hrev55181_23-x86_64-anyboot.iso

PS Can you change the version of this ticket to r1beta3 ? I don't have permission to do that.

comment:7 by tqh, 3 years ago

Lets investigate first. If you have several Haiku partitions, you get boot menu, but not if you have one. And since you confirmed that all parts are new it looks like a real issue.

comment:8 by beaglejoe, 3 years ago

The partition layout is:
Partition 1: 32mb FAT EFI
Partition 2: BFS - remainder of disk

The problem is exposed (not caused) by adding FAT32 filesystem support into the EFI executable. https://review.haiku-os.org/c/haiku/+/4085

From: \src\system\boot\loader\vfs.cpp Line 647

status_t
get_boot_file_system(stage2_args* args, BootVolume& _bootVolume)
{
	status_t error = platform_add_boot_device(args, &gBootDevices);
	if (error != B_OK)
		return error;

	NodeIterator iterator = gBootDevices.GetIterator();
	while (iterator.HasNext()) {
		Node *device = iterator.Next();

		error = add_partitions_for(device, false, true);
		if (error != B_OK)
			continue;

		Partition *partition;
		error = platform_get_boot_partition(args, device, &gPartitions, &partition);
		if (error != B_OK)
			continue;

		Directory *fileSystem;
		error = partition->Mount(&fileSystem, true);
		if (error != B_OK) {
			// this partition doesn't contain any known file system; we
			// don't need it anymore
			gPartitions.Remove(partition);
			delete partition;
			continue;
		}

		// init the BootVolume
		error = _bootVolume.SetTo(fileSystem);
		if (error != B_OK)
			continue;

		sBootDevice = device;
		return B_OK;
	}

	return B_ERROR;
}

The function: platform_get_boot_partition() currently just returns the first partition (which is now the FAT EFI partition)

So what happens here is:
add_partitions_for() adds both the partitions to gPartitions
platform_get_boot_partition() returns the first (now ESP fat)
partition->Mount() succeeds
_bootVolume.SetTo() FAILS so continue;
No more devices so B_ERROR
Boot menu

A more subtle problem is that add_partitions_for() APPENDS partitions, so if there are more than one device. ie USB stick is left plugged in. The second time through the iteration: platform_get_boot_partition() will return either

the second partition on the FIRST device (if gPartitions.Remove(partition) was executed
or the first partition on the FIRST device (again)

comment:9 by tqh, 3 years ago

Nice find, the list of bootable partitions should not contain the fat partition. Yes we currently append all partitions, as an EFI app should be able to handle all disks. There has never been a prio order for partitions between disks, but I think I have some WIP code for that.

And if we really wanted we could skip all this and just search for HAIKU BFS UUID's on GPT to find partitions, it would be GPT only and a bit different from other boot platforms though. And if you have a partition UUID you can do the same with that UUID.

in reply to:  7 comment:10 by beaglejoe, 3 years ago

Replying to tqh:

Lets investigate first. If you have several Haiku partitions, you get boot menu, but not if you have one. And since you confirmed that all parts are new it looks like a real issue.

No - with one Haiku partition - you get the boot menu (with Continue booting greyed out) You can select it, then boot ok

comment:11 by beaglejoe, 3 years ago

Please take a look at: https://review.haiku-os.org/c/haiku/+/3881 I have refactored the code to put the logic in devices.cpp
It might be of some help

comment:12 by kallisti5, 3 years ago

Jessicah made patched EFI bootloader to test for this one: https://haiku.nz/files/r1b3/haiku_loader.efi

Please test, and confirm if it solves the issue for you ASAP.

I've merged https://git.haiku-os.org/haiku/commit/ into master because it actually solves the issue for me locally.

We're getting close to R1/beta3 within the next few weeks so need some confidence before merging to R1/beta3.

Last edited 3 years ago by kallisti5 (previous) (diff)

in reply to:  12 comment:13 by beaglejoe, 3 years ago

Replying to kallisti5:

Jessicah made patched EFI bootloader to test for this one: https://haiku.nz/files/r1b3/haiku_loader.efi

Please test, and confirm if it solves the issue for you ASAP.

I've merged hrev55216 into master because it actually solves the issue for me locally.

We're getting close to R1/beta3 within the next few weeks so need some confidence before merging to R1/beta3.

Nice work Jessicah.

Works on my hardware and on QEMU.

Last edited 3 years ago by kallisti5 (previous) (diff)

comment:14 by jessicah, 3 years ago

Cc: jessicah added

comment:15 by tqh, 3 years ago

Owner: tqh removed

comment:16 by beaglejoe, 3 years ago

This ticket is fixed. Please close.

comment:17 by nephele, 3 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.