Tuesday, 7 April 2020

Creating and Installing a Server Respun Ubuntu Desktop ISO


Whilst Canonical release 'server' images of Ubuntu getting them to boot or install on Intel mini PCs can be difficult especially if the mini PC is limited by the BIOS enforcing a 32-bit bootloader. As a result there have been many requests for 'isorespin.sh' to respin an Ubuntu server ISO. However the structure of a server ISO is different to a desktop ISO and as a result is incompatible with the script. So I've always suggested as a workaround to first respin and install the desktop ISO and then purge the desktop packages and install the required server packages.

But what if you try and respin a desktop ISO as a server ISO?

Well this is possible however you need to add the package 'casper' in order to boot it. You also need to create a user as part of respinning otherwise you won't be able to login.

The problem is that even after successfully booting a 'pseudo' server ISO installing it is rather tedious.

Therefore I'm developing a text based script to simplify the installation and I've documented the current status below.

First you need to respin the Ubuntu desktop ISO using 'isorespin.sh' with the following options:

isorespin.sh \
-i ubuntu-18.04.4-desktop-amd64.iso \
--atom \
-e ubuntu-desktop \
-p "ubuntu-server casper gdisk network-manager linux-generic-hwe-18.04" \
-f linservin.sh \
-c "useradd -c ubuntu -d /home/ubuntu -m -g users -s /bin/bash ubuntu" \
-c "sed -i '/^root/ a ubuntu ALL=(ALL:ALL) ALL' /etc/sudoers" \
-c "passwd -de ubuntu"

To explain further the options included are:
'-i ubuntu-18.04.4-desktop-amd64.iso' is the desktop ISO I've currently been testing with.
'--atom' for an Intel Atom based device. Alternatively use '--apollo' for those relevant devices that don't boot the standard desktop ISO or '-b rEFInd' to include the 'rEFInd' boot manager.
'-e ubuntu-desktop' to purge (remove) the packages tagged with task 'ubuntu-desktop' which will remove the graphical interface.
'-p ubuntu-server' to install all the packages included in the metapackage 'ubuntu-server'.
'-p casper' to provice the scripts required to boot the ISO.
'-p gdisk' is required by my installation script in order to format the storage.
'-p network-manager' again required by the installation script in order to have internet access.
'-p linux-generic-hwe-18.04' as it was removed during the desktop purge.
(Note: these packages have been combined into one '-p' option)
'-f linservin.sh' includes my installation script (see below).
-c "useradd ..." this command creates the user 'ubuntu' for the respun ISO. Any user can be created.
-c "sed ..." allows the 'ubuntu' user 'sudo' access.
-c "passwd ..." allows a password of choice to be created on initial boot.

A further '--debug' option can be added so that the resultant logfile shows details of all the package dependencies used in the purge and install commands. Full documentation on the options can be found here.

My 'Linuxium server install' script 'linservin.sh' can be downloaded by clicking on this link.

Using the above options creates the 'pseudo' server ISO. I've uploaded a respun ISO here which you can use for testing and I've renamed it as 'linuxium-atom-ubuntu-18.04.4-server-amd64.iso' just to avoid confusion.

Next create a 'LiveUSB' by writing the ISO to a USB using 'dd':
dd if=linuxium-atom-ubuntu-18.04.4-server-amd64.iso of=/dev/sdX bs=4M
where 'X' is the drive letter for the USB.


Then boot from the 'LiveUSB' using 'Try Ubuntu without installing' and you'll have a 'live' server ISO which you can use similar to any live ISO. Also don't try clicking the 'Install Ubuntu' option as this will fail as the required packages have already been removed by the purge command.

Prior to attempting an installation you must have a working internet connection as packages are required to be downloaded. It is not important whether it is by ethernet or wifi and the 'nmcli' command can be used to configure a connection.

Finally to install the server ISO simply run 'linservin.sh' which is included on the ISO in 'usr/local/bin':


The script can also be run with options:
linuxium@LINUXIUM:~$ linservin.sh -h
Usage: /usr/local/bin/linservin.sh [ OPTIONS ]
where OPTIONS include '-h' for 'help'
'-v' for 'version'
'-c' for 'check' (version)
'-y' run automatically with best guessed values (dangerous)
linuxium@LINUXIUM:~$
which are self explanatory.

The script then shows the variables it will use for the installation together with values it determines may be the most appropriate and then allows you to select what you want:


It will then ask for confirmation to start the installation (bearing in mind this will completely overwrite the existing hard drive of the device) and it requires a (case sensitive) 'Y' to continue.

The following video shows the installation on an Intel Compute Stick (STCK1A32WFC):



Importantly the installer will detect whether the bootloader is 32-bit for 64-bit and install GRUB accordingly.

The installation progress is recorded in a logfile 'linservin.log' which is also copied to the installed filesystem and is available under '/var/log/installer'.

If the 'server' ISO proves popular I'm considering adding a '--server' option to 'isorespin.sh' to facilitate the respinning of server ISOs. Otherwise feedback is appreciated to improve the current 'linservin.sh' script.

Please donate if you find the script useful using the following link http://goo.gl/nXWSGf as everything helps with development costs.

2 comments:

Phield said...

the iso which u've shared above is not accesible. could you share new iso? thank you

Linuxium said...

@Phield: I had to remove it as I ran out of hosting space and nobody appeared to be using it. You are the first to comment!

You can always make your own by respinning an ISO using the commands described above.

Post a Comment

All comments now moderated so that spam can be deleted.