Now that Ubuntu 20.04 LTS is out, it was time to update my bootable USB drive
with a bunch of ISO images.
Except I got tired of editing grub.cfg
by hand. So I wrote a
script.
Now all I have to do is plug in my USB drive, download a new
ISO into it, run make
in the
/boot/grub subdirectory, and presto! It works.
What the script does:
- finds all ISO files in ../../ubuntu/*.iso
- extracts /boot/grub/grub.cfg from inside the ISO image (yes, I wrote an ISO 9660 filesystem parser in Python)
- extracts the kernel command line
- adds the iso-scan/filename=… argument to make it boot from an ISO image
- generates a new grub.cfg with a menu listing all Ubuntu versions and all image variants (desktop vs server)
This works for all Ubuntu ISO images based on casper, which is a tool Ubuntu uses to produce their LiveCD images.
Notably it doesn’t work for older Ubuntu server images based on debian-installer.
I don’t know about other distributions and Ubuntu variants. Ubuntu variants ought to work, but my script might generate wrong titles for them.