The mini.iso for the Ubuntu distribution is legacy since version 20.04LTS (Focal Fossa). This is a bad news for those (like me) that formerly used this distribution to produce lightweight virtual machines for development, teaching, testing, etc. A distribution of the mini.iso for Ubuntu 20.04 is indeed still available here, but there is no guarantee that its availability will continue after Focal Fossa. An askubuntu post on the topic (there are several) is here.
So I decided to find a way to do without the mini.iso, and I wrote this script that takes to the ''tasksel'' step starting from a cloud image in the ubuntu repository. You have many options here about the image format to use: I refer to the .ova file that you find in focal/current. Using a mix of VBOxMangage commands and the cloud-init tools you obtain a tasksel dialog to proceed with you customization. Surprise, it is faster than the procedure based on the mini.iso.
Customization is carried out by editing the bash variables on top of the script. Namely:
VMimagethe location of the OVA imageVMnamethe name of your VM (as in the VirtualBox dashboard)VMhostnamethe hostnameVMusernamethe name of the initial userVMtimezonethe timezone (if you do not touch this line it will be the same as your host machine)VMlocalethe localization (if you do not touch this line it will be the same as your host machine)VMkeyboardthe console keyboard (if you do not touch this line it will be the same as your host machine)
If you do not touch at all you obtain a customizable running VM.
Jump to the next section if in hurry. This one is mainly written for those that want to adapt it.
The first part of the script creates a vm-config.sh file that will be later uploaded to the running VM and, there, executed to configure it. We will describe its function later.
Next the Virtual Machine is created: download the .ova, create the VM, configure networking, and prepare the drives.
The following step creates the cloud-init configuration files (user-data and meta-data): they will be used by the cloud-init support inside the VM (remember, it is created from a cloud image) to configure it from the inside. In the two files you find the name of the host, the name of the (unique) user, and its RSA public key for authentication. The files are packaged in a .iso file (a virtual DVD) that is attached to the VM, and threfore available to cloud-init.
At this point the script launches the VM, and waits for your prompt to start the successive steps. This is extremely in-elegant: any suggestion is welcome.
When the VM is up and running you hit return and the installation proceeds uploading the configuration script prepared in the very first step, and lauching it execution. It perform a fix in the /etc/hosts file, asks for the password of the unique user (see the $VMusername variable), performs the localization, and updates the software packages, installing a bundle of packages excluded from cloud images and the tasksel tool, which is immediately launched
Preconditions: you have a Linux box with VirtualBox installed and at least an RSA public key available in $HOME/.ssh (if not, then it is time to generate it!).
Launch VirtualBox, next create a directory and download the script. Check if the variables fit your case, next launch it with
$ ./UbuntuMini.sh
After less than one minute (30" on my Lenovo Legion Laptop) a Virtual Terminal appears showing the boot sequence on the VM. Stay on the terminal from which you launched the script, and press return only when the Virtual Terminal shows the login screen.
You will be asked to confirm the connection to the VM (type yes) and, after a few seconds, to set the password for the user (twice).
After a few minutes (four on my laptop) of unattended operation you are presented with the tasksel dialog. Here you can select (up/down arrows and the space key to select) the bundles you want to install. Highlight the <ok> using the TAB key when finished. The installation will proceed, unattended. When finished, the control returns to the host computer. It is advisable to restart the VM before using it.
You can connect with the VM also using ssh password-less from a host terminal:
$ ssh -p 2222 user@localhost
replacing user with the username you indicated in the configuration step.
I have tried a few desktop installations, that are a valuable test since they need that the display manager and the rest are correctly installed, and they work fine. As a lightweight customizable desktop installation I suggest the Xubuntu minimal desktop, available from tasksel.
Enjoy :-)