# How to use GRUB2 efi loader in mfsbsd



## ruchir15 (Jun 11, 2021)

I have created mfsbsd (https://github.com/mmatuska/mfsbsd) based custom in memory OS.
I am currently facing a issue around UEFI based firmware boot up .i.e. issue somewhat related to this https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209821

Now, I am thinking if the problem is in freebsd UEFI loader can we use GRUB-2 loader in mfs ?
I was researching around it on internet. and thinking to follow this

https://unix.stackexchange.com/questions/563053/booting-mfsbsd-via-pxe-with-uefi 

The GRUB-2.efi port for the same have been discontinued (https://www.freshports.org/sysutils/grub2-efi) 
So I decided to download the tar and install it on a freebsd12 machine. 

I got the tarball from here wget https://ftp.gnu.org/gnu/grub/grub-2.06.tar.gz * 
I ran configure command, .
i.e. cd grub-2.0 sh .
/configure it gives me message 
like 
******************************************************* 
GRUB2 will be compiled with following components: Platform: i386-pc With devmapper support:
 No (need libdevmapper header) With memory debugging: No With disk cache statistics: 
No With boot time statistics: No efiemu runtime: 
Yes grub-mkfont: No (need freetype2 library) grub-mount: 
No (need FUSE library) starfield theme: 
No (No build-time grub-mkfont) With libzfs support: Yes 
Build-time grub-mkfont: No (need freetype2 library) Without unifont (no build-time grub-mkfont) With liblzma from -llzma (support for XZ-compressed mips images) With stack smashing protector: No 
******************************************************* 
I tried : ./configure --with-platform=x86_64 configure: error: platform "x86_64-efi" is not supported for target CPU "i386" however intention is to build it for a amd-64 freebsd12 machine with UEFI. 

however I could find the necessary switches for the same. I tried to search on internet however I could not find any reference for same 
Could you help me how could I install grub2-efi on a freebsd-12 machine 

Or any suggestion around this problem to solve ?


----------



## Alain De Vos (Jun 11, 2021)

Do you really need efi or what does it gives you more.
I think you can use and do almost anything. You just must must edit the mfbsd code accordingly ...


----------



## ruchir15 (Jun 11, 2021)

Alain De Vos said:


> Do you really need efi or what does it gives you more.
> I think you can use and do almost anything. You just must must edit the mfbsd code accordingly ...


There is no issue in BIOS base loader boot up.
However the  site where I trying to boot this does not have BIOS base loader support on their hardware.
They only have support for UEFI.

We tried to use the freebsd loader.efi however it just hangs on boot up process.


----------



## scottro (Jun 11, 2021)

By any chance does the machine offer FreeBSD as an option if you choose boot from on startup.  In other words, on my laptop, for example, if I hit F12 when the machine starts, I get an option of what I can boot and FreeBSD is one of those. You might even be able to add it by using efibootmgr on whatever Linux might be sharing this machine.
There is also rEFInd which works for many people. 

I use the grub configuration suggested by patovm04 in his post about making a single ZFS partition at https://forums.freebsd.org/threads/...gside-another-os-sharing-the-same-disk.75734/


----------



## Alain De Vos (Jun 11, 2021)

mfbsd is to load a memory disk of bsd , for instance for diskless installations.
I don't see how this in any way can bind to efi.
There is nothing wrong with efi, but i have difficulty to see it as a requirement.


----------



## ruchir15 (Jun 14, 2021)

Alain De Vos : yes mfsbsd is loaded into memory and this bug is around it,
the efi loader of freebsd around EFI_STAGING _SIZE, in memory ramfs.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209821(comment 37 )

so I am trying to work around it using grub2 based loader. 

PS: no issues in legacy bios based loader.


----------



## forlfs (Jun 18, 2022)

try this
./configure --with-platform=efi


----------

