This project implements a simple AMD64 UEFI bootloader that immediately reboots the system.
Useful as a fall-back disk install in case machines that rely on PXE cannot be configured to auto-retry.
This project requires the following tools and libraries:
- GCC
- GNU-EFI
- Parted
- mtools
- QEMU + OVMF (for running locally)
sudo apt-get install gcc gnu-efi parted mtools qemu-system-x86 ovmfsudo dnf install gcc gnu-efi parted mtools qemu-system-x86 ovmfsudo pacman -S gcc gnu-efi parted mtools qemu ovmfTo build the project, simply run:
makeThis will create reboot.efi (the UEFI application) and reboot.img (a disk image containing the bootloader).
To test the bootloader in QEMU, run:
make run
The Makefile supports several variables that can be overridden:
INCLUDE_DIRS: Directories to search for header files (default:/usr/lib)LD_OBJ: Path to the UEFI crt0 object file (default:/usr/lib/crt0-efi-x86_64.o)EFI_LDS: Path to the UEFI linker script (default:/usr/lib/elf_x86_64_efi.lds)BIOS_FD: Path to the OVMF BIOS image for QEMU (default:/usr/share/OVMF/FV/OVMF.fd)
Example usage:
make INCLUDE_DIRS="/path/to/efi/headers" LD_OBJ="/path/to/crt0.o"To write the bootloader image to a physical disk (use with caution!):
sudo dd if=reboot.img of=/dev/sdX bs=4M status=progressReplace /dev/sdX with the appropriate disk device. Be absolutely certain you're writing to the correct disk, as this will overwrite all existing data.
The bootloader is a minimal UEFI application that calls the UEFI firmware's ResetSystem function to immediately reboot the system. The Makefile compiles this application and creates a GPT-formatted disk image containing an EFI System Partition with the bootloader installed.
