[Polished] EFI Dualboot of existing Debian (Linux) and after installed Haiku 64 bit -- using Grub2 --> Works

Hello from Haiku,

I have installed today on ASUS - X751L equipped with a Debian Linux OS on it, it’s a Dualboot now with Haiku and it work.

As the guide here say:
https://www.haiku-os.org/guides/booting/

I had to put a EFI system entry point in the Grub2 menu:

# for EFI systems
menuentry "Haiku" {
	load_video
	insmod part_msdos
	insmod chain
	search --fs-uuid --set=root <EFIBOOT partition UUID>
	chainloader ($root)/EFI/BOOT/BOOTX64.EFI
}

I have encounter a little trouble about it at the chainloader line
I had due to create a variable with the path before this chainloader. Something similar to it:

prefix=/EFI/BOOT
chainloader ($root)$prefix/BOOTX64.EFI

Without it the system give me this error: EFI file not found

So, Haiku boot now and it work. Wifi chipset work too apparently cause I capt the signals.

3 Likes

the root variable is initialized in previous line:

search --fs-uuid --set=root <EFIBOOT partition UUID>

I suppose, you did not write it as it is written here. <EFIBOOT partition UUID> needs to be replaces with uuid code of that partition. You can find it out from Debian Terminal by issuing:

ls -l /dev/disk/by-uuid

and search for partition where EFI resides. Then copy it to /etc/grub.d/40_custom file (or whatever you use to configure Grub2) and it should make the trick.

Yes I put the UUID found like it:

menuentry "Haiku" {
        load_video
        insmod part_msdos
        insmod chain
        search --fs-uuid --set=root 1C93-8EC3
        prefix='/EFI/haiku'
        chainloader ($root)$prefix/BOOTX64.EFI
}

OK, in this case you have several variants. First, explicit:

menuentry "Haiku" {
    load_video
    insmod part_gpt
    insmod chain
    set root==UUID=1C93-8EC3
    chainloader /EFI/haiku/BOOTX64.EFI
}

Second, by search:

menuentry "Haiku" {
    load_video
    insmod part_gpt
    insmod chain
    search --fs-uuid --set-root 1C93-8EC3
    chainloader /EFI/haiku/BOOTX64.EFI
}

Additionally, Grub2 gives you an interactive shell to try all these commands and see what it finds. For this, in Grub2 press C to enter the command prompt. Use <TAB> for auto-completion and try all the commands between { and }. Finally, if the efi file was successfully located and loaded, in prompt, issue:

boot
1 Like

Thank for your explanation, but it work like I wrote in the first post.

Maybe the official web page need little update here about Grub2 commands, cause I had following this guide:
https://www.haiku-os.org/guides/booting/
That’s when I encounter the trouble.

So, you propose in User Guide about booting Haiku with Grub2 to change from:

chainloader ($root)/EFI/haiku/BOOTX64.EFI

(which apparently does not work) to:

chainloader /EFI/BOOT/BOOTX64.EFI

?

Does ($root)/EFI/BOOT/BOOTX64.EFI evaluate to something like (hd0,0)(hd0,0)/EFI/BOOT/BOOTX64.EFI (just a guess). Can you try it in Grub2 interactive prompt? It may be a Grub2 bug. Or it may mean the Haiku documentation really needs a correction.

I don’t think the documentation is wrong as such, the problem is more that configuring grub2 is needlessly hard, and there exists little information in Haiku since nobody really bothers to do it.

“Make grub2 boot this .efi file” should not be such a hard problem, really.

The common advice here is to use another software that does make this easy, like rEFInd. Which can just find efi files on it’s own and boot them. Linux can be booted from rEFInd without grub2 aswell. Either wirh gummiboot, kernel-as-efi-stub etc.

I don’t have tested your version of the script and I just use a prefix variable like I said before and it work:

        prefix='/EFI/haiku'
        chainloader ($root)$prefix/BOOTX64.EFI

But yes, maybe this is not the most cleanup version the users can use.

Nephele, I think grub2 is widely used by Linux distributions. But maybe I’m wrong?
I never heard about rEFInd before this post. Sorry.

It was a suggestion about this guide just cause I encounter an issue to make dualbooting. This guide can stay as is.

Yes it is. But outside of Linux it is basically not used because of the complexity, many linux distros even have alternatives but choose to use grub2 always because they don’t want to support two “different” bootloaders. Despite EFI and bios booting beeing very different. : )

1 Like

Just my 0.02 but you might find it easier to install rEFInd, since it happens at a level above and it’s very easy to configure. Especially when Haiku itself makes it so easy to work with the EFI partition :slight_smile:

So, can you try in Grub2 command prompt the following:

search --fs-uuid --set=root 1C93-8EC3
prefix='/EFI/haiku'
echo ($root)/EFI/haiku/BOOTX64.EFI
echo ($root)$prefix/BOOTX64.EFI

to see how it evaluates. Maybe ($root) evaluates to something like ((h01,0)), which is evidently wrong. Maybe instead

chainloader $root/EFI/haiku/BOOTX64.EFI

would do the trick?

P.S. I personally like Grub2 for its hackability. Unfortunately, it is very hard to use outside Linux.

The 2 echo seem to feedback the same line but it’s appear really quickly on my screen.

And Maybe I have just made a type error cause now it work without prefix as in this screen:

Capture d’écran du 2024-02-29 21-36-22
I will restart again the computer for a new test of this file…
ok it work with this code:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

# for BIOS systems
menuentry "Haiku" {
        load_video
        insmod part_msdos
        insmod chain
        search --fs-uuid --set=root 1C93-8EC3
        chainloader ($root)/EFI/haiku/BOOTX64.EFI
}

Thank you

You are welcome, I am glad to see it works and User Manual is correct. Just 2 more cents to the discussion:

  1. You can enter in Grub2 prompt by pressing C button when in Grub menu. And there you can run whatever Grub2 commands you want to research your system configuration and bootability, <TAB> for autocomplete is of great help here. When in prompt, you can also see the result of your commands, including echo, without worrying about messages quickly going away.
  2. Usually Grub2 automatically loads all modules it needs, but you can help it or speed loading necessary modules when doing it explicitly. I see you load module part_msdos. This one is responsible to recognize MBR partitioning scheme. However you probably have GPT partitioning scheme with dedicated EFI partition. In this case insmod part_msdos is useless, instead you can use insmod part_gpt.
1 Like