Adding Haiku to Grub2 menu

Grub2 is being adpoted my many of the linux distributions at the moment. Has anyone experience of adding their Haiku partition? I’ve poked around some of the Grub2 docs but I’m still lost.

Just add an entry at the end of /boot/grub/grub.cfg

Here’s mine (Ubuntu system):

END /etc/grub.d/40_custom

menuentry “haiku” {
set root=(hd0,3)
chainloader +1
}

Adapt “root= …” as necessary.

Enjoy!

I forgot to say that grub.cfg is not writeable by default. You have to make this file writeable before editing it.

I’m sorry, but this is the wrong way! Actually, grub.cfg is unwritable on purpose! It is generated using the scripts in /etc/grub.d/ on every update or kernel installation. So all your changes are lost after updating Grub 2!

The scripts are executed alphabetical. So you have to add a script an name it according to the desired position. E.g. if you like to be Haiku the first entry, name it 06_Haiku. If you want to have the entry at the bottom position, give it the highest number (e.g. 40_).

The content of the script must be the following:

#! /bin/sh -e

echo "Adding Haiku entry" >&2
menuentry "Haiku R1 alpha" {
    ## change to your partition, the first partition on your first hard drive
    ## is (hd0,1), the third partition on your 2nd hd is (hd1,3) and so on...
    set root=(hdX,Y)
    chainloader +1
}

After that, make the script executable by typing

$ chmod +x 40_Haiku

(or whatever you named it) and update Grub 2 using

$ sudo update-grub
or whatever your distribution uses.
1 Like

Thanks for your replies. kwurzel, thank you - that looks like what I’ve seen in the grub documentation but I couldn’t figure out how to use it for my situation. Much appreciated!!

Maybe I am missing something, but I get a “menuentry not found” error on running sudo update-grub from Kubuntu 9.10. It finds everything else just fine. The things from the os_prober script and the Linux kernels. As well as memtest. Any suggestions?

I had the same problem, add these two lines containing EOF and it should do the trick (replace X and Y according to your disk setup).

#! /bin/sh -e

echo "Adding Haiku entry" >&2
cat << EOF
menuentry "Haiku R1 alpha" {
    set root=(hdX,Y)
    chainloader +1
}
EOF

Could I ask the meaning of the >&2 ?
This was very helpful, and immediately allowed me to add Haiku to Grub but I’d like to get a better grasp of what that part of the script is doing.

why are You still messing around with GRUB?
try GAG (http://gag.sourceforge.net/).

GAG is quite good actually. I have used it on quite a few occasions. I think it even has an option for BeOS. :stuck_out_tongue:

Guru

and… in gpt?

…set root=(hdX,gptY)…

menuentry “Haiku R1 alpha” {
set root=(hdX,gptY)
chainloader +1
}

Thank you so much. I was having the same problems described above and this made GRUB2 recognize the HaikuOS partition.
Both the Arch wiki and the Haiku help pages regarding this should be updated with this info.

Oh, and sorry for reviving this thread!

Thanks for the pointer to GAG - It appears to be good even if relatively unknown and has had a BeOS icon for quite some time.