EFI config and boot from legacy and reverse

hello guys

my question is actually 3 questions in one, but i'll be happy to get at least part of it done

does anybody know how to change efi boot options from  system that does not run in EFI mode. all my attempts at using efibootmgr failed, and i'm not even sure it is supposed to be feasible. i have an ubuntu and a FreeBSD installed and ready to use, and i can boot live cds or install mostly anything else if required

$ sudo modprobe efivars ; echo MODPROBE_RET=$? ; sudo efibootmgr MODPROBE_RET=0 Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables. Try 'modprobe efivars' as root. $ lsmod | grep -i efi $
i'm using this command in grub : "chainloader (${root})/efi/.../something.efi" and already tried many variations

i am NOT interested in alternate solutions involving to replace existing files with grub files. i already know how to do that and i'm trying to set it up the clean way

has anybody succeeded in booting and EFI kernel from a grub2 installed in a regular mbr ? how ? i'm also interested in a legacy grub solution if needed.

i've been successful at setting the EFI partition as the root partition (which i can tell because if i use a wrong filename it properly complains that the file does not exist),

but actually booting yields "error : invalid signature" on every efi kernel installed while all those kernels work in EFI mode (currently 2 versions of refind, and a windoze 8 loader work but i had the same problem with other boot loaders)

has anybody succeded in booting a regular mbr from an EFI grub ? any glitches ? i have not given it a try, and i believe this part should be easy enough and not a priority so i'm only interested in your experience and i might no give any feed back on that part

as a side note, i wanted to test this in qemu, but i noticed that changes made to the filesystem when i'm running linux are not visible in qemu when accessing the block device unless i wait for a LONG time. calling sync does not help. i'm interested in both the reason and/or possible workarounds. i noted the same behavior wth usb keys. you have to unmount the partition an physically remove the device before the changes are picked.

the ultimate goal would be to install grub2-efi and grub2 on the mbr with stage 2 located on the efi partition, if possible share the same config among the grub instances, and do a little grub-scripting to autodetect EFI and possibly non-EFI systems, and if possible have a way to set this up from a non-efi live system

this is partly for educational reasons, so please don't discuss the usefullness of it all

thanks everyone
LVL 27
Who is Participating?
skullnobrainsAuthor Commented:
time to close this question...

change efi boot options from  system that does not run in EFI mode

this is not possible as far as i know, but it is fairly easy to install efi shells into an existing efi system. i'm unsure if this would work with safe boot enabled.

booting and EFI kernel from a grub2 installed in a regular mbr

as stated above, tianocore is an easy way. other options such as coreboot should also work

booting a regular mbr from an EFI grub

i had no time to work with bios emulators, but refind works with some firmwares


if anybody stumbles on this thread, feel free to post additional information or ask questions. i may not be around so it might take a few weeks before i answer
You can't boot or simulate an efi system if you don't have the hardware. So either you will have to get a new mainboard with efi, or just do it in theory.
skullnobrainsAuthor Commented:

You can't boot or simulate an efi system if you don't have the hardware

i assume you are only answering to my 2nd question

i understand the point. nevertheless, grub's efi runtime can boot macos EFI, and i'm looking into modified versions that may work with windows.

qemu also has EFI bios emulation using a third party bios emulator

i do have EFI hardware, and i'm looking for solutions that work both using the hardware and chain-booting from cms.

if that is actually impossible, i need to know precisely why, but for now, i do not see a reason why it would not work. it's fairly possible that it has not been done yet, though.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

skullnobrainsAuthor Commented:
update on my second question : booting an EFI kernel from a grub2 installed in a regular mbr

this works using tianocore

here is a link to the precompiled binaries, which i used successfully. read the sources and compile them yourself if you are concerned about security.

steps are the following
- extract the .img in the archive to your EFI partition
- extract "memdisk" from a syslinux package ( should be /boot/syslinux/memdisk if you are using syslinux )
- configure your bootloader to load the "memdisk" kernel using the image file as initrd. sample configs for grub2 and syslinux are provided in the archive. i copy-pasted the block corresponding to the loader from the sample, and it worked verbatim so i'm not including it here. you'll have to edit the paths if you do not store the files at the root of the EFI partition.

i tested this working chain and many others : once refind fires up, everything that boots through the system's EFI + refind should boot also using tianocore + refind
mbr:grub2 > grub2 stage2 on gpt linux partition > memdisk + tianocore on the EFI partition > refind > windows 8

this does ot work in qemu or is too slow, but using qemu with efi emulated hardware is simpler anyway. this let me successfully boot my locally installed windows in virtualbox (on a ubuntu host, but it should work from any other os host)

NOTE : this does not help with the first question as the bcfg (EFI shell v2), bcfgedit (windows), efibootmgr (likely every unix-like OS) commands you can run in this case change stuff inside tianocore instead of the system's NVRAM. i have not tested wether these changes are persistent or not. if not a .nsh script might be the way to go

for those who are interested in other ways of achieving a similar goal. i was successfull in getting some things to work using boot sectors from coreboot and clover. chameleon might also be helpful. some of these solutions work without changing the bios for another one, but not all, and i do not have anything worthy to post but those interested should start googling boot132
skullnobrainsAuthor Commented:
just keeping this question open as a work in progress. the EFI -> legacy is more difficult then i expected : it requires lots of bios emulation to get something workable (int13h and acpi being bare minimum). not too much time but looking into coreboot components (bios emulators) that could be compiled as EFI
skullnobrainsAuthor Commented:
accepting my own comment for obvious reasons
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.