Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@cpatrick08
Copy link

cpatrick08 commented Mar 11, 2020

I get the following error message.
100 1554 100 1554 0 0 28777 0 --:--:-- --:--:-- --:--:-- 28777
gpg: Signature made Tue 10 Mar 2020 10:38:21 AM CDT
gpg: using RSA key 3B4FE6ACC0B21F32
gpg: Can't check signature: No public key
gpg: Signature made Tue 10 Mar 2020 10:38:21 AM CDT
gpg: using RSA key 871920D1991BC93C
gpg: Can't check signature: No public key

@pmartycz
Copy link
Author

pmartycz commented Mar 12, 2020

@cpatrick08 you need to import signing keys from the Ubuntu keyserver

gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x3B4FE6ACC0B21F32 0x871920D1991BC93C

See https://ubuntu.com/tutorials/tutorial-how-to-verify-ubuntu#4-retrieve-the-correct-signature-key

@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