#17039: EFI installation won't boot without visiting menu
-------------------------------------+----------------------------
Reporter: beaglejoe | Owner: tqh
Type: bug | Status: assigned
Priority: normal | Milestone: Unscheduled
Component: System/Boot Loader/EFI | Version: R1/Development
Resolution: | Keywords:
Blocked By: | Blocking:
Platform: All |
-------------------------------------+----------------------------
Comment (by beaglejoe):
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)
--
Ticket URL: <https://dev.haiku-os.org/ticket/17039#comment:8>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.