Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Grub2, Scripted detection of UEFI at boot? Is it possible?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
DingbatCA
Guru
Guru


Joined: 07 Jul 2004
Posts: 384
Location: Portland Or

PostPosted: Fri Feb 15, 2019 5:35 pm    Post subject: Grub2, Scripted detection of UEFI at boot? Is it possible? Reply with quote

Building up a USB pen drive to launch iPXE. I have loaded grub2 on, and it works in both UEFI and Legacy mode. I am trying to figure out if I can get grub to automatically choose the correct ipxe based on UEFI/Legacy.

The "iPXE Automagic" is my example, but I have no clue how to detect UEFI/Legacy. Any one have some ideas?
Code:

timeout=5
menuentry "iPXE Automagic" {
  if UEFI
    search --no-floppy --set=root -f /ipxe.efi
    chainloader ($root)/ipxe.efi chain file:($root)/mycode.ipxe
  else
    search --no-floppy --set=root -f /ipxe.lkrn
    linux16 ($root)/ipxe.lkrn
    initrd16 ($root)/mycode.ipxe
}

menuentry "iPXE UEFI" {
  search --no-floppy --set=root -f /ipxe.efi
  chainloader ($root)/ipxe.efi chain file:($root)/mycode.ipxe
}

menuentry 'iPXE Legacy' {
  search --no-floppy --set=root -f /ipxe.lkrn
  linux16 ($root)/ipxe.lkrn
  initrd16 ($root)/mycode.ipxe

Best I have found thus far is the lsacpi -1 grub command. A UEFI bios might have a "BGRT" table, which is where the UEFI vendor logo sits. But I have no clue how to get grub to act on that.
Back to top
View user's profile Send private message
DingbatCA
Guru
Guru


Joined: 07 Jul 2004
Posts: 384
Location: Portland Or

PostPosted: Mon Feb 18, 2019 4:22 pm    Post subject: Reply with quote

Took a different path. Using syslinux for Legacy booting. Using GRUB to cover UEFI. It's not as clean of a solution, but it works for my needs.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum