Created
April 1, 2021 11:49
-
-
Save Cellebyte/b46dfab9e720b4d5b2e830cde103e6f2 to your computer and use it in GitHub Desktop.
Building UEFI bootable mini image for ipa.
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
#!/usr/bin/env bash | |
declare -r TEMP_MOUNT="$(mktemp -d)" | |
declare -r TITLE="Python Ironic Agent" | |
declare -r DESTINATION="${1:-out.iso}" | |
declare -r KERNEL="${2:-kernel}" | |
declare -r INITRAMFS="${3:-initramfs}" | |
echo "TEMP_MOUNT = ${TEMP_MOUNT}" | |
dd if=/dev/zero of=${DESTINATION} bs=1M count=514 | |
sgdisk --new=1:1MiB:513MiB ${DESTINATION} | |
sgdisk --change-name 1:efi ${DESTINATION} | |
sgdisk --typecode 1:ef00 ${DESTINATION} | |
sgdisk --print ${DESTINATION} | |
LOOPBACK=$(sudo losetup --partscan --find --show ${DESTINATION}) | |
sudo partprobe ${LOOPBACK} | |
sudo mkfs.fat -F 32 -n EFIBOOT "${LOOPBACK}p1" | |
sudo mount "${LOOPBACK}p1" ${TEMP_MOUNT} | |
sudo bootctl --esp-path=${TEMP_MOUNT} install | |
sudo cp ${KERNEL} "${TEMP_MOUNT}/vmlinuz" | |
sudo cp ${INITRAMFS} "${TEMP_MOUNT}/initrd" | |
sudo bash -c "cat <<EOT >> ${TEMP_MOUNT}/loader/entries/default.conf | |
title ${TITLE} | |
linux /vmlinuz | |
initrd /initrd | |
options nofb nomodeset vga=normal BOOTIF=None --- | |
EOT | |
" | |
cat ${TEMP_MOUNT}/loader/entries/default.conf | |
sudo umount -R ${TEMP_MOUNT} | |
sudo losetup -d ${LOOPBACK} | |
rm -rf "${TEMP_MOUNT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment