2

I am trying to duel boot x86_64 machine running freeBSD 10.1 using grub. FreeBSD Grub2-efi installation seems going fine but there was no grub.cfg. I manually created grub.cfg. Below are configs I tried and results I got.

My setup :

gpart show -l
=>        6  146239733  da0  GPT  (558G)
          6         10       - free -  (40K)
         16        128    1  (null)  (512K)
        144     262144    2  efi  (1.0G) -----> MY ESP
     262288    1048576    3  rootfs  (4.0G) ----> freebsd+ grub are here
    1310864    2097152    4  swap  (8.0G)
    3408016    1048576    5  nextroot  (4.0G) 

Grub installation command:

grub-install --target=x86_64-efi --efi-directory=/efi/ --bootloader-id=grub --boot-directory=/boot/ --modules="part_gpt part_msdos"

Config 1:

    menuentry "FreeBSD" {
        insmod ufs2
        insmod bsd
        set root=(hd0,3)
        kfreebsd /boot/loader.efi
   }

Result: it's complaining 'invalid a.out header'.

Config 2:

    menuentry "FreeBSD" {
        insmod ufs2
        insmod bsd
        set root=(hd0,3)
        kfreebsd /boot/loader
   }

Result:Blank screen with white blurr on top. Is it video problem?

Config 3:

menuentry "FreeBSD" {
    insmod ufs2
    insmod bsd
    insmod gfxterm
    insmod font
    insmod videotest
    insmod videoinfo
    set gfxmode=auto
    set kernvt="vt"
    set root=(hd0,3)
    kfreebsd /boot/boot1.efi
}

Result again: blank screen with fast changing blur on top.

Config 4:

menuentry "FreeBSD" {
    insmod ufs2
    insmod bsd
    insmod gfxterm
    insmod videotest
    insmod videoinfo
    set gfxmode=auto
    set kernvt="vt"
    set root=(hd0,3)
    chainloader /boot/boot1.efi
}

result: signature not matching. Not booting

I am not sure what I'm missing. Can someone please review my grub.cfg? Is there any obvious thing I'm missing? I highly appreciate if anyone can share grub config using for UEFI booting grub on x86.

  • 1
    You can't put loader.efi as an argument to kfreebsd. Grub expects to find the name of FreeBSD kernel there, not a boot loader. The FreeBSD kernel is an a.out binary; EFI programs are PE (Portable Executable) binaries, thus the error message. – Johan Myréen Mar 28 '17 at 6:43
  • @JohanMyréen Thanks for your inputs. I have removed .efi . But I am getting blurry screen. By any chance do you have any working grub.cfg for freebsd? – Satpal Parmar Apr 1 '17 at 3:19
  • No, I'm sorry, I'm not that familiar with Freebsd. You could try changing the line kfreebsd /boot/loader.efi to chainloader /boot/loader.efi in you original menuentry (while retaining the .efi suffix). This tells grub2-efi to load and run the Freebsd EFI boot loader (a EFI program just like grub2-efi). The kfreebsd keyword is for loading the BSD kernel directly, and should take a kernel image file as parameter. It may not be possible to load the kernel directly under UEFI, you will have to use the Freebsd specific EFI boot loader. But I'm not sure about that. – Johan Myréen Apr 1 '17 at 16:59
2

From Linux OS , add the new FreeBSD entry to your /etc/grub.d/40_custom then regenerate the grub.cfg file:

rm /boot/grub/grub.cfg

Add the following line to your /etc/grub.d/40_custom :

menuentry "FreeBSD" {
insmod ufs2
set root=(hd0,gpt3)
kfreebsd /boot/loader
}

Run grub-mkconfig:

grub-mkconfig -o /boot/grub/grub.cfg

Edit

You must create a bios-boot partition (size = 1 M)

From FreeBSD , after installing grub from ports collection , install it correctly using the following command:

grub-install --modules=part_gpt /dev/ada0

Use gpart show command to get the right device.

Run the grub-mkconfig -o /boot/grub/grub.cfg command , it will generate a grub.cfg for you.

| improve this answer | |
  • Thanks for your inputs @GAD3R. As I said I am installing freebsd port of grub2-efi from FreeBSD. Post installation I do not see any grub.cfg or grub-mkconfig utility. I have also seen other people reporting missing grub.cfg. Not sure what is the reason. I currently not have access to Linux machine to experiment. I appreciate if you can share generated config here. Thanks again. – Satpal Parmar Mar 30 '17 at 15:05
  • Please run grub-mkconfig without option , to verify it – GAD3R Mar 31 '17 at 20:25
  • In my case i have added FreeBSD to Grub installed through linux system – GAD3R Mar 31 '17 at 20:26
  • To save time you can boot linux or freeBSD with supergrubdisk supergrubdisk.org , from freebsd , mount the ESP partition e,g: /mnt/esp then run grub-install as montionned on your question with the following option --efi-directory=/mnt/esp not the --efi-directory=/esp/ ( do not forget the bios-boot partition. Grub will not correctly installed without it) – GAD3R Apr 1 '17 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.