Note: Auto-Install Ubuntu with Custom Preseed ISO

Introduction

This note describes creating an ISO image for a fully automatic, customized Ubuntu 18.04 server install.

The Ubuntu 18.04 install ISO used as the base for the customization is the Ubuntu Alternative Download image that uses the Debian installer. In my Experience, installing Ubuntu on a wide variety of hardware has been very reliable using this installer rather than the "live" server ISO (which often fails because of GPU initialization).

Download Install ISO with (or visit the link above),

wget http://cdimage.ubuntu.com/releases/18.04.3/release/ubuntu-18.04.3-server-amd64.iso

Creating a custom install ISO requires mounting an existing install image, modifying several files, and possibly the installer boot image itself, followed by generating a new ISO image. This process is somewhat tedious and requires many steps aside from the actual customizations. Fortunately there are tools available to help with these "distractions".

For this work I used a program called "cubic" that provides a simple GUI interface that helps to maintain focus on the important customization tasks. It will take care of setting up a build directory with the mounted ISO image, give a list of the files that typically need to be modified (and an editor), and then generate the customized ISO image.

It will also provide a root shell to a "chroot" (change root) environment to directly modify the installer runtime image. I did not need this feature since I'm using the simple Debian installer and have no reason to modify that, but it would be a convenient way to modify a "live" installer image.

Install and run cubic (on an Ubuntu desktop system)

apt-add-repository ppa:cubic-wizard/release
apt update
apt install cubic

then run cubic. You will need to sudo to root and then will be greeted with,

A quirk of the interface is that "actions" are commands in the header bar, (`Next` is your friend).

Create a directory for your ISO build i.e. mkdir iso-build and "Select" that directory.

Then "Select" the install ISO file to be modified i.e. ubuntu-18.04.3-server-amd64.iso. Cubic will loopback mount the ISO image create a directory structure, copy the contents of the ISO to this directory and execute a "chroot" to the installer image and give you a root shell in that chroot. You can modify that installer image by adding files or editing existing ones. For example you could add extra repos to /etc/apt/sources.list or sources.list.d.

Im my case this "chroot" is the debian installer image for Ubuntu. If you were doing this with a "live" installer image you could install packages that would then transfer to an install using this ISO. I will only install packages from a `preseed` file. It doesn't make much sense to to make changes in this "chroot" for what I am doing.

In the "chroot" for the installer I'm using you can see that it is a small Debian system (this is what runs to install Ubuntu)

[email protected]:/ # cat /etc/debian_version
buster/sid

Doing "Next" logs out of the "chroot" and gives a convenient list of directories/files that make sense to change for modifying the ISO install behavior.

Create Preseed FIle

From the "Preseed Files" panel a new file can be added (or edits made to existing files). At this point you can use the editor in cubic or just sudo to a root shell on your system and make needed changes directly with out using cubic. The ISO files are in "original-iso-mount" in the cubic working directory that you started from.

[email protected]:~/Downloads/ISO/iso-build/original-iso-mount$ ls

boot  dists  doc  EFI  install  isolinux  md5sum.txt  pics  pool  preseed  README.diskdefines  ubuntu

I will add the following auto-inst.seed file to the preseed directory,

If you use this preseed file be sure that you read and understand every line in it!

I built this preseed file using the example at https://help.ubuntu.com/lts/installation-guide/amd64/apbs04.html along with lots of experimentation!

auto-inst.seed (GitHub Gist)

Edit grub and isolinux config

In order to use this new preseed file you will need to edit boot/grub/grub.cfg and isolinux/text.cfg.These are in the "original-iso-mount" directory (conveniently mounted and listed by cubic).

For grub.cfg I've added the following stanza,

menuentry "Auto Install Ubuntu Server From Preseed" {
  set gfxpayload=keep
  linux /install/hwe-vmlinuz  boot=casper file=/cdrom/preseed/auto-inst.seed auto=true priority=critical locale=en_US  quiet ---
  initrd  /install/hwe-initrd.gz
}

file=/cdrom/preseed/auto-inst.seed auto=true priority=critical locale=en_US are telling the installer to use my auto-inst.seed preseed, do an auto install, only ask critical questions during the install and set the localization to en_US. The localization is needed here as a boot parameter since the first questions the installer asks about language happen before the preseed starts.

In the isolinux/txt.cfg file the following changes need to be made,

Change the "default" selection from "install" to "auto-install"

default auto-install

and add a menu entry

label  auto-install
  menu label ^Auto Install Ubuntu Server From Preseed
  kernel /install/hwe-vmlinuz
  append  boot=casper file=/cdrom/preseed/auto-inst.seed vga=788 initrd=/install/hwe-initrd.gz auto=true priority=critical locale=en_US  quiet ---

Note that I am using the "HWE" (Hardware Enablement) kernel.

Generate ISO file

After making the file changes above you can click "Generate" in cubic and it will create the new ISO image tagged with the current date and original ISO file name. ubuntu-18.04.3-2020.01.29-server-amd64.iso

I highly recommend that you test the new ISO install image in a virtual machine before running it on real hardware. You may have some debugging to do!

Happy computing! –dbk @dbkinghorn


CTA Image
Looking for a GPU Accelerated Workstation?

Puget Systems offers a range of powerful and reliable systems that are tailor-made for your unique workflow.

Configure a System!
CTA Image
Labs Consultation Service

Our Labs team is available to provide in-depth hardware recommendations based on your workflow.

Find Out More!

Why Choose Puget Systems?

Built specifically for you

Rather than getting a generic workstation, our systems are designed around your unique workflow and are optimized for the work you do every day.

Fast Build Times

By keeping inventory of our most popular parts, and maintaining a short supply line to parts we need, we are able to offer an industry leading ship time.

We’re Here, Give Us a Call!

We make sure our representatives are as accessible as possible, by phone and email. At Puget Systems, you can actually talk to a real person!

Lifetime Labor & Tech Support

Even when your parts warranty expires, we continue to answer your questions and even fix your computer with no labor costs.

Click here for even more reasons!

Puget Systems Hardware Partners

Gray Intel Logo

Gray AMD Logo

Gray NVIDIA Logo

Gray Samsung Logo

Tags: , ,