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