Creating an EFI partition with all the convenient tools
(rEFInd, Grub, memtest, …)
Hardware is of type x86_64.
Secure boot is not used (no key management, or signing of binaries).
Following script fragments are using FreeBSD commands.
For example the tar command is based on
libarchive and is able to process
multiple archive format, including zip files.
The $EFI environment variable is to be defined and point to
the EFI directory in the mounted ESP partition.
When using hypervisor such as Bhyve, the provided
UEFI is not able to store data in NVRAM, so configuring boot information
is not possible, it will be necessary to store the boot loader
at the default emplacement EFI/BOOT/bootx64.efi. In our case shim
can be use to reconstruct a boot configuration (using BOOT.CSV)
add menu entries for bootloaders: iPXE, Grub, and Super Grub
hide from scan efi programs corresponding to our bootloaders
and installed tools
Installing theme in rEFInd
1
tar xvfz multi-loaders.tgz -C${EFI}/refind/
rEFInd is configured using the refind.conf file, we will
load the default configuration and the additional theme before
applying our custom configuration (here selecting a subset of tools).
version=0.13.0
file=refind-bin-${version}.zip
project=refind
path=projects/${project}/files/${version}/${file}
curl -L-s http://sourceforge.net/${path}/download |
tar xvfz - -C${EFI}--strip-components 1 refind-bin-${version}/refind
# Rename sample as default configuration# so it can be included in `refind.conf` with: `include refind.dflt.conf`mv-i${EFI}/refind/refind.conf-sample ${EFI}/refind/refind.dflt.conf
# Add a fallback entry for `shim`echo"refind_x64.efi,rEFInd Boot Manager,,This is the boot entry for rEFInd" |
iconv -f UTF-8 -t UTF-16LE >${EFI}/refind/BOOT.CSV
# For current version see and ajust `version` from# https://packages.ubuntu.com/groovy/amd64/grub-efi-amd64-bin/downloadversion=2.04-1ubuntu35_amd64
package=grub-efi-amd64-bin
origin=grub2
file=${package}_${version}.deb
path=pool/main/${origin%"${origin#?}"}/${origin}/${file}mkdir-p${EFI}/grub
curl -s http://fr.archive.ubuntu.com/ubuntu/${path} |
tar Oxfz - data.tar.xz |
tar xzvf - --strip-components 6 -C${EFI}/grub/ '*/monolithic/'
# For current version see, and ajust `version` from# https://packages.ubuntu.com/groovy/amd64/shim/downloadversion=15+1552672080.a4a1fbe-0ubuntu2_amd64
package=shim
origin=shim
file=${package}_${version}.deb
path=pool/main/${origin%"${origin#?}"}/${origin}/${file}mkdir-p${EFI}/shim
curl -s http://fr.archive.ubuntu.com/ubuntu/${path} |
tar Oxfz - data.tar.xz |
tar xzvf - --strip-components 4 -C${EFI}/shim/ usr/lib/shim
# Remove ubuntu fallback entryrm${EFI}/shim/BOOTX64.CSV