Skip to content

Instantly share code, notes, and snippets.

@depau
Last active February 16, 2018 22:25
Show Gist options
  • Save depau/8fd2aa3b53435884e7b5356192280296 to your computer and use it in GitHub Desktop.
Save depau/8fd2aa3b53435884e7b5356192280296 to your computer and use it in GitHub Desktop.
EFI/Linux kernel bundler for Arch
#!/bin/bash
# Update last line with paths to Secure Boot keys
rootdev="$(mount | grep " on / " | awk '{ print $1 }')"
rootfstype="$(mount | grep " on / " | awk '{ print $5 }')"
echo -e "$(</usr/lib/os-release)\nVERSION_ID=rolling" > /tmp/os-release
cat /boot/intel-ucode.img /boot/initramfs-linux.img > /tmp/initrd.img
echo "options root=$rootdev rootfstype=$rootfstype rd.luks.options=discard rw quiet splash" > /tmp/cmdline.txt
objcopy \
--add-section .osrel="/tmp/os-release" --change-section-vma .osrel=0x20000 \
--add-section .cmdline="/tmp/cmdline.txt" --change-section-vma .cmdline=0x30000 \
--add-section .linux="/boot/vmlinuz-linux" --change-section-vma .linux=0x40000 \
--add-section .initrd="/tmp/initrd.img" --change-section-vma .initrd=0x3000000 \
"/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/tmp/linux-bundle.efi"
mkdir -p /boot/efi/EFI/Linux
sbsign --key DB.key --cert DB.crt --output /boot/efi/EFI/Linux/archlinux.efi /tmp/linux-bundle.efi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment