Posts
Search
Contact
Cookies
About
RSS

Installing EFI Shell as an emergency rescue

Added 27 Oct 2017, 1 a.m. edited 18 Jun 2023, 1:12 a.m.
After managing to trash the EFI entry (in nvram) for my OS because of a user unfriendly BIOS, I thought it was about time I checked out what EFI Shell could do for me. EFI Shell is a CLI (command line interface) - a kind of mini DOS if you like, that allows you to do many EFI related tasks and even boot OS's. If you're using Linux you'll probably find your ESP (EFI System Partition) mounted under /boot/EFI (and in windows - well good luck to you ...! you might find it easier to make a USB stick like SystemRescueCd) Given that a FAT filing system isn't the worlds most robust this might be a good time to check the fstab is mounting this partition read only - and in fact there really isn't any need to have it mounted at all unless you directly want to change something specific to the EFI - even grub configs in the ESP point towards your root or boot partition... You'll need the actual EFI Shell executable
wget https://svn.code.sf.net/p/edk2/code/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi
and you might find useful some extra drivers (although most stuff you'll do in the ESP probably)
http://efi.akeo.ie/downloads/efifs-0.7/x64/
I only bothered with exfat (which I sometimes use on usb sticks), ext and iso9660 you'll want to make a directory structure for EFI shell something like this
/boot/efi/EFI/efishell/:
drivers shell.efi shell.efi.other

/boot/efi/EFI/efishell/drivers:
exfat_x64.efi ext2_x64.efi iso9660_x64.efi
It's defiantly useful to add this as an EFI entry
efibootmgr -c -d /dev/sda -p 1 -L "efi shell" -l "\EFI\efishell\shell.efi"
This will make it bootable from whatever poor boot menu your EFI BIOS has (if it even does...) Just in case something goes wrong with that but EFI grub is somehow still working, you can also boot into the EFI Shell via grub put the following at the end of /etc/grub.d/40_custom
menuentry "EFI Shell" {
 insmod chain
 set root='(hd0,gpt1)'
 chainloader /EFI/efishell/shell.efi
}
Of course you'll have to run update-grub to make that active. Once in EFI Shell you'll want to boot into another OS first change to the fs0: device (this should usually be your ESP) just like DOS you type the name followed be a colon and hit enter from there there are a number of command you can use (ls etc) which you can discover with the help command once you've changed to a directory like EFI\void you can run that boot loader by typing its name (grubx64.efi) and et voila up should come Linux I've barely touched the surface here, but there should be just enough information to get you started (if not to hose your system completely!) Enjoy!