Generate an ISO image for automated Ubuntu 20.04 desktop installations. This script uses the traditional preseed method.
Check out the usage information below for arguments. The basic idea is to take an unmodified Ubuntu ISO image, extract it, add some kernel command line parameters and a preseed file, then repack the data into a new ISO. Creating the preseed file itself is outside the scope of this tool.
There is an example preseed file example.seed
in this repository which will install Ubuntu using US English settings and UTC time zone with a user named "User" and password "ubuntu". You could modify that file to create your own custom configuration. Unlike the server version of this script, there is currently no way to provide the preseed configuration on a separate volume during the installation - it must be baked into the ISO image.
This script can use an existing ISO image or download the latest daily 64-bit image from the Ubuntu project. Using a fresh ISO speeds things up because there won't be as many packages to update during the installation.
By default, the source ISO image is checked for integrity and authenticity using GPG. This can be disabled with -k
.
Tested on a host running Ubuntu 20.04.1.
- Utilities required:
p7zip-full
mkisofs
orgenisoimage
Usage: ubuntu-preseed-iso-generator.sh [-h] [-k] [-v] [-p preseed-configuration-file] [-s source-iso-file] [-d destination-iso-file]
๐ This script will create fully-automated Ubuntu 20.04 Focal Fossa installation media.
Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-p, --preseed Path to preseed configuration file.
-k, --no-verify Disable GPG verification of the source ISO file. By default SHA256SUMS-<current date> and
SHA256SUMS-<current date>.gpg in <script directory> will be used to verify the authenticity and integrity
of the source ISO file. If they are not present the latest daily SHA256SUMS will be
downloaded and saved in <script directory>. The Ubuntu signing key will be downloaded and
saved in a new keyring in <script directory>
-s, --source Source ISO file. By default the latest daily ISO for Ubuntu 20.04 will be downloaded
and saved as <script directory>/ubuntu-original-<current date>.iso
That file will be used by default if it already exists.
-d, --destination Destination ISO file. By default <script directory>/ubuntu-preseed-<current date>.iso will be
created, overwriting any existing file.
user@testbox:~$ bash ubuntu-preseed-iso-generator.sh -p example.seed -d ubuntu-preseed-example.iso
[2021-03-13 10:05:10] ๐ถ Starting up...
[2021-03-13 10:05:10] ๐ Created temporary working directory /tmp/tmp.rrehvj78Bk
[2021-03-13 10:05:10] ๐ Checking for required utilities...
[2021-03-13 10:05:10] ๐ All required utilities are installed.
[2020-12-23 14:06:07] ๐ Downloading current daily ISO image for Ubuntu 20.04 Focal Fossa...
[2020-12-23 14:08:01] ๐ Downloaded and saved to /home/user/ubuntu-original-2021-03-13.iso
[2020-12-23 14:08:01] ๐ Downloading SHA256SUMS & SHA256SUMS.gpg files...
[2020-12-23 14:08:02] ๐ Downloading and saving Ubuntu signing key...
[2020-12-23 14:08:02] ๐ Downloaded and saved to /home/user/843938DF228D22F7B3742BC0D94AA3F0EFE21092.keyring
[2020-12-23 14:08:02] ๐ Verifying /home/user/ubuntu-original-2021-03-13.iso integrity and authenticity...
[2020-12-23 14:08:09] ๐ Verification succeeded.
[2020-12-23 14:08:09] ๐ง Extracting ISO image...
[2021-03-13 10:05:23] ๐ Extracted to /tmp/tmp.rrehvj78Bk
[2021-03-13 10:05:23] ๐งฉ Adding preseed parameters to kernel command line...
[2021-03-13 10:05:23] ๐ Added parameters to UEFI and BIOS kernel command lines.
[2021-03-13 10:05:23] ๐งฉ Adding preseed configuration file...
[2021-03-13 10:05:23] ๐ Added preseed file
[2021-03-13 10:05:23] ๐ท Updating /tmp/tmp.rrehvj78Bk/md5sum.txt with hashes of modified files...
[2021-03-13 10:05:23] ๐ Updated hashes.
[2021-03-13 10:05:23] ๐ฆ Repackaging extracted files into an ISO image...
[2021-03-13 10:05:35] ๐ Repackaged into /home/user/ubuntu-preseed-example.iso
[2021-03-13 10:05:35] โ
Completed.
[2021-03-13 10:05:35] ๐ฝ Deleted temporary working directory /tmp/tmp.rrehvj78Bk
Now you can boot your target machine using ubuntu-preseed-example.iso
and it will automatically install Ubuntu using the configuration from example.seed
.
This script is based on this minimal safe bash template, and steps found in this Ask Ubuntu answer.
MIT license.