Skip to content

Instantly share code, notes, and snippets.

@mmdriley
Created June 23, 2020 09:27
Show Gist options
  • Save mmdriley/b815defb2dfc5b08dc2cc731c70fe155 to your computer and use it in GitHub Desktop.
Save mmdriley/b815defb2dfc5b08dc2cc731c70fe155 to your computer and use it in GitHub Desktop.
Make a USB drive that can boot Ubuntu ISOs
# this goes at boot/grub/grub.cfg
# inspired by https://github.com/thias/glim
insmod all_video
set gfxpayload=keep
loadfont unicode
terminal_output gfxterm
# https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311
rmmod tpm
for isofile in /ubuntu-*.iso; do
# check if the glob didn't expand
if [ ! -e "${isofile}" ]; then break; fi
menuentry "${isofile}" "${isofile}" {
# title is $1
set isofile=$2
# loopback.cfg expects `iso_path` to be set
set iso_path="${isofile}"
export iso_path
loopback loop "${isofile}"
set root=(loop)
configfile /boot/grub/loopback.cfg
loopback --delete loop
}
done
menuentry "Shut down" {
halt
}
menuentry "Restart" {
reboot
}
#!/bin/bash
# Assume: a formatted volume with the label "IsoBoot"
# I used FAT32.
TARGET=/media/ubuntu/IsoBoot
sudo grub-install \
--target=x86_64-efi \
--uefi-secure-boot \
--efi-directory="${TARGET}" \
--boot-directory="${TARGET}/boot" \
--removable
(cd "${TARGET}" && curl -L -O 'https://releases.ubuntu.com/20.04/ubuntu-20.04-desktop-amd64.iso')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment