11. April 2022

Creating Ubuntu OS Custom ISO

By H. Cemre Günay

As part of a customer project I had to do a complete offline installation of an Ubuntu server with various packages:

Linux:

  • nano
  • zip
  • unzip
  • tree
  • make
  • java (JRE & JDK)
  • ant
  • openssh
  • net-tools
  • htop
  • Python 3.6.9 (prereqs for Python are gcc openssl-devel bzip2-devel libffi-devel)

Python:

  • paramiko
  • pandas
  • ntc-templates

After a little research on the internet, I found out that downloading .deb files is not enough and you have to download other dependent packages. I don’t know exactly which ones, so I looked for another solution and found Cubic.

Cubic (Custom Ubuntu ISO Creator) is a GUI wizard to create a customized Live ISO image for Ubuntu based distributions.

Cubic permits effortless navigation through the ISO customization steps and features an integrated virtual command line environment to customize the Linux file system. You can create new customization projects or modify existing projects. Important parameters are dynamically populated with intelligent defaults to simplify the customization process.

Cubic runs on distributions based on Ubuntu 18.04.5 Bionic and above.

No sooner said than done, so I installed Cubic on my Ubuntu Server 20.04 LTS VM. First we start as usual with updating our system:

sudo apt update && sudo apt upgrade -y

Unless you have a desktop environment, you should do this now:

sudo apt install ubuntu-desktop -y

After installing our desktop environment, we reboot the system, log in and call a terminal session and add the appropriate Cubic repository, update & upgrade the environment again to then install Cubic:

sudo apt-add-repository ppa:cubic-wizard/release
sudo apt update && sudo apt upgrade -y
sudo apt install cubic

Once you have installed Cubic, you will find the program under applications.

Launch it and you will be greeted with a welcome screen. Enter a path to your desired project folger where all your customizations and final customized ISO will be stored.

On the next screen under Original ISO field, click on Select button to choose an ISO image. Cubic will automatically populate all details and metadata in visible input boxes. You can change details under Custom ISO field as per your requirements. By default, Cubic will assign a version number and date to your Custom ISO build.

Click the next button to see Cubic working on the original ISO to create an virtual environment for customization.

Once the process is finished, you will be taken to a terminal. This terminal alows you to run commands inside a sandboxed file system completely unaware and disconnected from any other file system present on your system. Any changes made inside the terminal affect root directory of its running processes and children only. Cubic passes all the changes made in the terminal to the Live ISO.

Inside the environment, we will begin by adding universe repository to increase the number of apps available to install:

sudo apt-add-repository universe
sudo apt update

After that start installing the needed packages from out list:

sudo apt install nano zip unzip tree make ant openssh-server gcc libssl-dev bzip2 libffi-dev -y

For the Java Packages install first JRE then JDK:

sudo apt install default-jre -y
sudo apt install default-jdk -y

For Python install the needed Version or just get it update by:

sudo apt update # to get it updated prior to your Ubuntu OS
# or 
sudo apt install python3.6

After that install the needed Pythong packages:

sudo apt install pyhton3-paramiko pyhton3-pandas python3-pip

To install ntc-templates type following command:

pip3 install ntc-templates

After you have finished installing all the packages hit again and update & upgrade command:

sudo apt update && sudo apt upgrade -y

Now we are done customizing our ISO and want to make it available to us. For this we click on next and look at the preparations:

The Kernel tab allows you to select a specific kernel for the customization live ISO.

The Preseed tab allows you to customize preseed files. These preseed files are used to automate installation. For example, if you are building ISO for users in a specific time zone, you can modify preseed files to choose that time zone and it will be automatically selected during installation. It is possible to completely automate installation process by choosing predetermined values for every field in the default installer.

The las tab Boot allows you to customize boot parameters and boot behaviour of the live ISO.

Then you can choose an compression size, I choose a larger size and a lower compression:

When your are finished with all steps, click on the Generate tab. You can always go to previous step during any stage of customization.

After the ISO image has been generated, a success window appears with the directory where the ISO image is located. You can optionally delete all project files, except the ISO image and checksum, if you do not want or need to edit this project again.

And that was it. Depending on how you want to use the ISO image, you can prepare a bootable USB stick with e.g. rufus or balenaEtcher or in a VMware environment simply attach the ISO to the VM. I hope this tutorial helped you, if you have any questions, please post them in the comments. 🙂