Skip to content

Instantly share code, notes, and snippets.

@pmartycz
Last active June 1, 2023 17:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmartycz/74da258f6d876862b88caa9b4026b1c2 to your computer and use it in GitHub Desktop.
Save pmartycz/74da258f6d876862b88caa9b4026b1c2 to your computer and use it in GitHub Desktop.
Ubuntu mini.iso with UEFI support
#!/bin/sh -eu
# Downloads, verifies and unpacks Ubuntu mini.iso fixing lack of UEFI support
# See https://bugs.launchpad.net/ubuntu/+source/debian-installer/+bug/1429030
# Thanks to https://www.nemotos.net/?p=2057
require() {
hash "$@" || die "Some of the required commands are missing"
}
download() {
echo "Downloading image"
curl -f --fail-early --create-dirs -o "$image" -OO \
"$image_url" "$checksums_url" "$checksums_url".gpg
}
verify() {
echo "Verifying image"
gpg --verify "$checksums".gpg "$checksums" || die "Signature verification failed" \
"See https://ubuntu.com/tutorials/how-to-verify-ubuntu#4-retrieve-the-correct-signature-key"
sha256sum -c --ignore-missing "$checksums" || die "Checksum verfication failed"
}
unpack() {
echo "Unpacking image to $dist/"
7z x -o"$dist" "$tempdir/$image"
7z x -o"$dist" "$dist/boot/grub/efi.img"
}
die() {
printf >&2 '%s\n' "$@"
exit 1
}
! [ $# -eq 1 ] && die "Usage: $0 <dist>"
require 7z curl gpg sha256sum
dist=$1
base_url=http://archive.ubuntu.com/ubuntu/dists/$dist/main/installer-amd64/current
case $dist in
precise|trusty|xenial|bionic|eoan)
base_url=$base_url/images
;;
*)
base_url=$base_url/legacy-images
esac
image=netboot/mini.iso
image_url=$base_url/$image
checksums=SHA256SUMS
checksums_url=$base_url/$checksums
tempdir=$(mktemp -d mini.iso.XXXXXXXXXX) && trap 'rm -rf "$tempdir"' EXIT
(cd "$tempdir" && download && verify) && unpack
@BLuFeNiX
Copy link

BLuFeNiX commented Jul 2, 2020

Need to use this for focal:

base_url=http://archive.ubuntu.com/ubuntu/dists/${dist}/main/installer-amd64/current/legacy-images

@pmartycz
Copy link
Author

pmartycz commented Jul 2, 2020

@BLuFeNiX Thanks, I've updated the URL in the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment