1

I need to run a script before the operating system starts. The script reads a text file (on file-system FAT32), if the result is "A", then launch OS1, elseif the result is "B", then launches OS2 (another operating system). I thought of Grub, but I do not know how it could be done. Alternatively, I could use EFI Shell, but in the firmware of my computer there is no EFI Shell. How can I do? Thank you all.

3
  • 2
    Welcome to Super User! An interesting question, but what problem are you trying to solve, if you don't mind my asking? If it's something along "reboot in X/Y on user intervention/programmatically" there might be ways of doing that depening on your setup :)
    – bertieb
    May 9 '18 at 8:26
  • When the operating system is running, it writes a text file to a FAT32 partition (via a script), depending on whether an event has occurred or not, let's say it writes "A" or "B" (a flag). This can be done by all operating systems installed on the machine. If "A" is written, then on the next reboot (or on re-ignition), OS1 must start, if instead "B" is written, then another operating system must start, say OS2 (not OS2 Warp :-)). That's all. Management must necessarily be pre-boot
    – Luciano
    May 9 '18 at 8:45
  • 1
    @Luciano UEFI provides this feature out of the box. With Linux you have to run efibootmgr -n <number> (print numbers by running efibootmgr). With Windows you have to figure it out yourself, I haven't used it yet.
    – gronostaj
    May 9 '18 at 9:19
1

You can download EFI Shell from the TianoCore project. It's an open source release based on the Intel implementation.

Download that binary, place in on the EFI System Partition and add an UEFI boot entry. The easiest way to do that is using Linux: (as root)

cd /efi/boot
wget https://github.com/tianocore/edk2/raw/master/ShellBinPkg/UefiShell/X64/Shell.efi
efibootmgr -c -p 1 -l shell.efi -L "EFI Shell"

Then set it as default boot option through your UEFI configuration interface or using efibootmgr:

efibootmgr -o $(efibootmgr | grep 'EFI Shell' | sed -r -e 's/^Boot0+//' -e 's/\*.*//')
3

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.