Puget Systems print logo
Read this article at https://www.pugetsystems.com/guides/1654
Dr Donald Kinghorn (Scientific Computing Advisor )

Note: Auto-Install Ubuntu with Custom Preseed ISO

Written on January 30, 2020 by Dr Donald Kinghorn


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)

root@i9:/ # cat /etc/debian_version

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.

kinghorn@i9:~/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

Looking for a GPU Accelerated Workstation?

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

Configure a System!

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 Support/Labor Warranty

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

Tags: Notes, Ubuntu, Install

Don, hope all is well!!!

I really would like to move my options trading backend system to Linux eventually but the most important change I would like to make is running my monte carlo simulations under linux using NVidia CUDA. The kicker is I have written everything in .net core C# and managed C++ to run on windows. The good thing is that ,net core runs under Linux and therefore it would be great if I could access CUDA from .net core using the same managed C++ code that runs under windows.
Is this a tall order and could you point me in the right direction??

I really have no interest in learning Python but I am willing to invest in Linux as it is way cheaper for multiple servers as compared to windows.

Posted on 2020-02-05 22:49:01
Donald Kinghorn

Doing well thanks! Hope the same for you :-)
There is CUDA.net and some other way to do "managed" CUDA but I have never messed with any of that. There are some good examples floating around of monte carlo code for GPU too.

You might not like this, but my recommendation would be to learn a little Python and then try PyTorch. It is a great framework and it is suitable for general scientific programming. (not just ML/AI stuff) It's the nicest way I have found to build code that will run well on CPU and GPU. The resulting code would be pretty portable across OS too. You don't really have to go to Linux (even though I generally recommend it).

Python is not too bad and you don't really need to know it very deeply to make good use of it. It's the packages that you import (like Pytorch) that make it powerful.
Microsoft has a course that they released recently ( I haven't watched any of the videos yet) They link to YouTube from this blog post https://cloudblogs.microsof...

Posted on 2020-02-10 20:36:54
Brian Button

Don, this was a really excellent writeup. I could use a little help. I guess I am looking for someone who is interested in a consulting gig. Got any suggestions?

We are building an ISO that can be used to create servers for the next few years. Getting this to work with 20.04 has eluded us so far. When I saw the preseed files in your article, I realized we still don't know everything we are ignorant about. It seems like a narrow specialty. Where would I go to find a specialist? Willing to pay . . .

Posted on 2021-01-06 22:11:15
Donald Kinghorn

Hi Brian, we do offer consulting from Puget Labs ... I might be able to help with this if the info in this post is not enough to get you going. Send an email to info@pugetsystems.com and ask that it be forwarded to me. I may be able to easily get you on the right track.

The biggest problem with the approach I took in this post is the reliance on the Debian installer. Ubuntu has dropped that installer and started working on a new method. I'm not sure why they did this? Maybe someone was bored, or they actually needed to replace the Debian installer to fit more with their "cloud first" strategy.

The Debian installer is still available by using the "Legacy Server" build. They hide that so you have to search for it outside of Canonical to find it :-( http://cdimage.ubuntu.com/u... when you go to that page they throw up a questionnaire asking you why you want to use it. Arrrggg! When you install from the legacy installer you get an actual "Ubuntu Server" install, when you install from the newer "ubuntu server" ISO you get the "Cloud Image" with the cloud-init-tools etc. ... at the end of the day it's mostly the same though

The biggest problem I had with the new installer is that it was, or at least seemed to be, incomplete. I couldn't really make a useful ISO. However, this may have changed since I tried it!

Posted on 2021-01-08 16:28:58
Brian Button

Donald, warm thanks for your comments and helpful hints. That 'legacy' server build was a life saver. I enjoyed telling them why I needed it. (I might go back and tell them again.) From there, I had to add apt repos, a GUI desktop and some other things in the image but that seems to be working . . . so far.

Some challenges remain, none fatal. For example, 'chromium-browser' is only available with a Snap installer -- and Snap installers don't work inside of chroot. So things like that will have to be done once per system.

BTW, I bought a Puget tower a loooooong time ago (mid Windows 7) and still use it for photo and video editing. Great machine!

We are making this (www.button.network). It calls for a local server. Our application is a little Covid-hampered but maybe things will get on track. I may send you that email if things go off the rails. ;-)

Posted on 2021-01-08 22:39:54
Donald Kinghorn

Great, I'm glad that helped :-) They will probably get the "new way" working well eventually but it's hard to beat the deb installer and a preseed. I don't have any ideas for the Snap problem ...

I do all of my installs from "legacy" and then use "tasksel" to add a desktop if needed. Quick and easy and works on nearly any hardware configuration.

ButtonNet looks great! That could be useful in many ways ... it adds a nice privacy layer too. I could see someone doing a mobile rig with your server for events.

Posted on 2021-01-11 23:52:44
Brian Button

Donald, thanks. We got this far on 16.04 and then used the holidays to upgrade to 20.04. We ran into several significant differences in software but I think we have hammered through all of them. The Chromium browser is only needed for one feature, putting vids/pics up on an HD screen. I suspect we will relegate that to a separate script.

Here is a more analytical page on ButtonNet, that I used for a meeting a while back. (http://www.button.network/w... You will see some more user-experience videos therein. We have one remaining puzzle: hardware assist for video transcoding. You can see the deficiency in our second usage video. Everything blazes except for the freshly uploaded video.

I think our system (https://www.amazon.com/Indu... is technically capable of performing hardware-assisted transcoding (using ffmpeg) but I sure cannot figure out the incantation. Spent five hours on it yesterday. Suggestions or referrals welcome. I am willing to pay consulting on this if necessary.

Posted on 2021-01-15 15:26:16

Hey Don, Excellent article, very thanks, i search a solution for auto install Ubuntu 20.04 LTS Desktop on a hdd disk since usb iso (with my custom parameter, gparted, crypted, account ...) , on internet many article and txt.cfg modified but not work for me, on your article you modified grub.cfg and text.cfg you don't have a equivalent on ks.cfg and ks.preseed ? i not found a good solution for the moment Thanks

Posted on 2021-02-07 11:30:17
Donald Kinghorn

I didn't use any kickstart stuff for this but I think Cubic would be handy for that too (that is such a nice tool for doing this!) . I haven't used this since shortly after I wrote this post. I decided to not use the auto install ISO and just do setup from scripts after a simple server install.

Maybe after the next Ubuntu release I'll look at using the new installer automation again. When I looked at it last year it didn't seem very usable!

Another way to handle things like this is to use Ansible for post install config.

Posted on 2021-02-08 17:49:56

This worked pretty well for me, thanks.

One change I had to make was removing d-i pkgsel/include string build-essential dkms. That caused a failure on the software install step, for some reason.

Posted on 2021-08-17 11:53:05
Donald Kinghorn

Glad this was of use for you. I'll miss the Debian installer! I haven't tried any automation with the new installer yet. Hopefully by the release of 22.04 LTS it will be reasonable to use.

Posted on 2021-08-17 21:34:42