-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
name: Build UEFI Application | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up environment | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential gcc gnu-efi mtools grub-efi-amd64-bin | ||
sudo apt-get install -y build-essential gcc gnu-efi mtools parted ovmf qemu-system-x86 | ||
- name: Determine system paths | ||
id: system-paths | ||
run: | | ||
echo "INCLUDE_DIRS=$(dirname $(find /usr/include -name efi.h | head -n 1))" >> $GITHUB_OUTPUT | ||
echo "LD_OBJ=$(find /usr/lib -name crt0-efi-x86_64.o | head -n 1)" >> $GITHUB_OUTPUT | ||
echo "EFI_LDS=$(find /usr/lib -name elf_x86_64_efi.lds | head -n 1)" >> $GITHUB_OUTPUT | ||
echo "BIOS_FD=$(find /usr/share -name OVMF.fd | head -n 1)" >> $GITHUB_OUTPUT | ||
- name: Build UEFI application | ||
run: make all | ||
run: | | ||
make \ | ||
INCLUDE_DIRS="${{ steps.system-paths.outputs.INCLUDE_DIRS }}" \ | ||
LD_OBJ="${{ steps.system-paths.outputs.LD_OBJ }}" \ | ||
EFI_LDS="${{ steps.system-paths.outputs.EFI_LDS }}" \ | ||
BIOS_FD="${{ steps.system-paths.outputs.BIOS_FD }}" | ||
- name: Archive build artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: reboot-efi | ||
path: reboot.efi | ||
- name: Archive build artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: reboot-img | ||
path: reboot.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,84 @@ | ||
# re-bootloader | ||
# Re-Bootloader | ||
|
||
UEFI bootloader, which instantly reboots. | ||
This project implements a simple 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. | ||
|
||
## Dependencies | ||
|
||
This project requires the following tools and libraries: | ||
|
||
- GCC | ||
- GNU-EFI | ||
- Parted | ||
- mtools | ||
- QEMU + OVMF (for running locally) | ||
|
||
### Installing Dependencies | ||
|
||
#### Ubuntu/Debian: | ||
|
||
```sh | ||
sudo apt-get install gcc gnu-efi parted mtools qemu-system-x86 ovmf | ||
``` | ||
|
||
#### Fedora/CentOS: | ||
|
||
```sh | ||
sudo dnf install gcc gnu-efi parted mtools qemu-system-x86 ovmf | ||
``` | ||
|
||
#### Arch Linux: | ||
|
||
```sh | ||
sudo pacman -S gcc gnu-efi parted mtools qemu ovmf | ||
``` | ||
|
||
## Building | ||
|
||
To build the project, simply run: | ||
|
||
```sh | ||
make | ||
``` | ||
|
||
This will create `reboot.efi` (the UEFI application) and `reboot.img` (a disk image containing the bootloader). | ||
|
||
## Running | ||
|
||
To test the bootloader in QEMU, run: | ||
|
||
``` | ||
make run | ||
``` | ||
|
||
## Customization | ||
|
||
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`) | ||
- `DISK_BLOCK_COUNT`: Number of blocks in the disk image (default: 204800) | ||
- `DISK_BLOCK_SIZE_BYTES`: Size of each block in bytes (default: 512) | ||
|
||
Example usage: | ||
|
||
```sh | ||
make INCLUDE_DIRS="/path/to/efi/headers" LD_OBJ="/path/to/crt0.o" | ||
``` | ||
|
||
## Writing to a Disk | ||
|
||
To write the bootloader image to a physical disk (use with caution!): | ||
|
||
```sh | ||
sudo dd if=reboot.img of=/dev/sdX bs=4M status=progress | ||
``` | ||
|
||
Replace `/dev/sdX` with the appropriate disk device. Be absolutely certain you're writing to the correct disk, as this will overwrite all existing data. | ||
|
||
## How it Works | ||
|
||
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. |