I was successfully able to follow the tutorial you provided and create a custom Ubuntu 22.04 Server ISO to install additional software as indicated in an offline situation. For example, I created an ISO that installed a package called nala. However, I was unsuccessful when attempting to install gnome-desktop as you desire. During the installation, the process stalled at the same point as you, and after two hours, I gave up and stopped the installation. With a total number of 1323 packages downloaded for ubuntu-desktop, this is a lot of packages to install. (BTW, this total can be seen by looking in the var/cache/apt/archives/ directory in the edit folder that you've chrooted into and run the chroot_script.sh shell script.)
So this process works, but I think the gnome-desktop package and dependencies are simply too large and too many to realistically install in this manner in a VM. Perhaps an installation on bare metal instead of a VirtualBox VM would be different, but I didn't try.
Now with that said, what I'm actually gathering from your question is that you ultimately want a Desktop installation, but you want to take advantage of autoinstall. If so, there is another alternative to creating an autoinstall of Ubuntu Desktop. This technique is similar to the above, except that you're actually adding the squashfs filesystem from the Ubuntu Desktop ISO to the Server ISO instead of installing the ubuntu-desktop package into the Server installation. With this technique, Subiquity from the Server ISO is used for the installation of everything.
The basic steps (very loosely outlined) are as follows:
- Unpack Server ISO to a directory (for example:
server-iso-extracted)
- Unpack Desktop ISO to a directory (for example:
desktop-iso-extracted)
- If needed or desired:
- Unsquash
desktop-iso-extracted/casper/filesystem.squashfs from Desktop ISO
- chroot into it
- Run any custom scripts
- Re-squash
filesystem.squashfs
- Copy re-squashed
filesystem.squashfs to the unpacked Server ISO directory into: server-iso-extracted/casper/filesystem.squashfs
- Add
user-data and meta-data files to sub-directory in unpacked Server ISO directory. For example: server-iso-extracted/nocloud/
- Update
grub.cfg for autoinstall, which is found in server-iso-extracted/boot/grub/grub.cfg
- Update
server-iso-extracted/casper/install-sources.yaml in the unpacked Server ISO directory to use filesystem.squashfs for installation.
- Repack Server ISO
A working user-data file for this technique is as follows:
#cloud-config
autoinstall:
version: 1
# The following credentials will create a default user. username: ubuntu - password: ubuntu
identity:
hostname: ubuntu-desktop
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
user-data:
timezone: America/Los_Angeles
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
refresh-installer:
update: no
keyboard:
layout: us
toggle: null
variant: ''
locale: en_US.UTF-8
# cloud-init is not installed by default in the Desktop ISO. Therefore, it either needs to be installed within the ISO or installed with the following lines:
# late-commands:
# - curtin in-target --target=/target -- apt install -y cloud-init
A working casper/install-sources.yaml is as follows:
- description:
en: This version installs a Desktop environment
where humans are not expected to log in.
id: desktop
locale_support: none
name:
en: Ubuntu Desktop
path: filesystem.squashfs
size: 568651776
type: fsimage
variant: server
default: true
A working boot/grub/grub.cfg file is as follows:
set timeout=30
loadfont unicode
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
menuentry "Try or Install Ubuntu Server" {
set gfxpayload=keep
linux /casper/vmlinuz autoinstall ds=nocloud;s=/cdrom/nocloud/ ---
initrd /casper/initrd
}
grub_platform
if [ "$grub_platform" = "efi" ]; then
menuentry 'Boot from next volume' {
exit 1
}
menuentry 'UEFI Firmware Settings' {
fwsetup
}
else
menuentry 'Test memory' {
linux16 /boot/memtest86+.bin
}
fi
The above info and steps were gathered from the scripts at the following link:
Ubuntu 22.04 Desktop Autoinstall
Michael Tandy is the author, and I've used his script. It works, but I found one discrepancy. In his user-data file, he writes the following, which indicates the user/password credentials have no effect:
# The following credentials have no effect - the user will be set up by gnome-initial-setup
password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
realname: Ubuntu user
username: ubuntu
Although what he states is true with regards to his set of scripts, this doesn't have to be the case. The reason the user and password have no effect is because cloud-init is not installed. By default, it's installed in a Server installation, but not a Desktop installation. (Remember, this technique and set of scripts is installing filesystem.squashfs, not ubuntu-server-minimal.squashfs or ubuntu-server-minimal.ubuntu-server.squashfs.) Therefore, user and password can be made to work by installing cloud-init into the Desktop filesystem, thus avoiding gnome-initial-setup from prompting you during first boot to create the default initial user. This can be done in two ways:
One is with a late-command in your user-data file as follows:
late-commands:
- curtin in-target --target=/target -- apt-get install -y cloud-init
The other is by chrooting into the unsquashed filesystem.squashfs and installing it via your custom script, similar to the tutorial you provided a link to. Since you want an offline installation, I'd simply install it early on into filesystem.squashfs.
More info and inspiration can be found at the following links: