3

I am trying to set up an automated installation environment for ubuntu 22.04. We have this already working in production for 20.04 and previous LTS releases for many years. We use pxe/isolinux and a tftp and dhcp server to perform the network and cd boot. And some trickery to get uefi working.

I am unable to find working vmlinuz and initrd images which allow me to start an automated ubuntu 22.04 installation using preseeding and the debian installer (d-i).

I use the following to install 20.04, this does not work on 22.04:

linuxefi /path/to/2004/amd64/linux auto=true priority=critical url=http://example.com/ubuntu/2004/amd64/seed_ub_uefi.cfg console-setup/layoutcode=us interface=auto
initrdefi /path/to/2004/amd64/initrd.gz

I have tried extracting the vmlinuz and initrd.gz images from 22.04 ubuntu CD iso images. However no matter what I try it even fails to find a root filesystem. I am guessing the images do not have d-i and preseed functionality built in anymore?

If such images don't exist how would I go about creating my own? I don't feel too happy migrating to whatever automated installation method canonical wants to enforce. Our whole infrastructure is based on the previously mentioned method and we install multiple OSes in a similar way.

I asked this on serverfault but have had no response so far so I figured this would be a more appropriate place to ask.

aseq
  • 131
  • 1
  • 4
  • I have made a chat to allow discussion about this if wanted: [here it is](https://chat.stackexchange.com/rooms/135858/discussion-on-question-by-aseq-how-to-use-d-i-and-preseeding-on-22-04-to-automat). – Zanna Apr 27 '22 at 09:03

2 Answers2

2

Ubuntu has discontinued preseed as of 20.04 according to this https://discourse.ubuntu.com/t/server-installer-plans-for-20-04-lts/13631

(I'm pretty sure Canonical is trying to keep up with Apple in terms of breaking all the things in the name of progress without regard to users and customers.)

Here is my workaround, which I just got working...

  1. I created a preseed.cfg file with all the things. In my case this preseed.cfg file is generated as a JINJA template to pull secrets in from a secrets store.

  2. Then I created a docker container to serve my preseed.cfg file. It looks kinda like this:

FROM REDACTED_INTERNAL_PATH/base:latest as runtime
USER root
RUN apt-get install nginx sudo -y && \
    rm /var/www/html/index.nginx-debian.html && \
    rm -rf /etc/update-motd.d/* && \
    echo "%service   ALL=NOPASSWD: /etc/init.d/nginx" > /etc/sudoers.d/service
COPY preseed.d/entrypoint.sh /opt/
COPY preseed.d/html/*.cfg /var/www/html/
USER service
ENTRYPOINT [ "/opt/entrypoint.sh" ]

3.I have a makefile that builds and runs this docker container to serve my preseed.cfg file. 4. I then use something like the following in packer to boot the 22.04 virtual machine:

variable iso_url {
  type    = string
  default = "https://releases.ubuntu.com/22.04/ubuntu-22.04-live-server-amd64.iso"
}
variable iso_checksum {
  type    = string
  default = "84aeaf7823c8c61baa0ae862d0a06b03409394800000b3235854a6b38eb4856f"
}
variable cpus {
  type    = number
  default = 2
}
variable memory_size {
  type    = number
  default = 4096
}
variable disk_size {
  type    = number
  default = 61440
}
variable ssh_username {
  type    = string
  default = "<redacted>"
}
variable ssh_password {
  type    = string
  default = "<redacted>"
}

packer {
  required_plugins {
    parallels = {
      version = ">= 1.0.1"
      source  = "github.com/hashicorp/parallels"
    }
  }
}

source "parallels-iso" "ubuntu" {
  boot_command = [
    "<esc><esc><enter><wait>",
    "/install/vmlinuz noapic ",
    "preseed/url=http://{{ .HTTPIP }}:8080/preseed.cfg <wait>",
    "debian-installer=en_US ",
    "auto locale=en_US",
    "kbd-chooser/method=us <wait>",
    "hostname={{ .Name }} <wait>",
    "fb=false",
    "debconf/frontend=noninteractive <wait>",
    "keyboard-configuration/modelcode=SKIP ",
    "keyboard-configuration/layout=USA ",
    "keyboard-configuration/variant=USA ",
    "console-setup/ask_detect=false <wait>",
    "initrd=/install/initrd.gz -- <enter><wait>",
  ]
  boot_wait              = "10s"
  guest_os_type          = "ubuntu"
  vm_name                = "ubuntu_base"
  iso_checksum           = var.iso_checksum
  iso_url                = var.iso_url
  parallels_tools_flavor = "lin"
  shutdown_command       = "echo 'shutdown -P now' > shutdown.sh; echo 'vagrant'|sudo -S sh 'shutdown.sh'"
  ssh_username           = var.ssh_username
  ssh_password           = var.ssh_password
  ssh_timeout            = "30s"
  ssh_wait_timeout       = "10000s"
  prlctl                 = [
    ["set", "{{.Name}}", "--3d-accelerate", "off"],
    ["set", "{{.Name}}", "--adaptive-hypervisor", "on"],
    ["set", "{{.Name}}", "--memsize", var.memory_size],
    ["set", "{{.Name}}", "--cpus", var.cpus],
    ["set", "{{.Name}}", "--efi-boot", "off"],
  ]
}

build {
  sources = ["source.parallels-iso.ubuntu"]

  provisioner "shell" {
    scripts = [ ### REDACTED ###]
  }

  post-processor "vagrant" {
  }
}
  • Thanks for the information. It does give me some helpful pointers. However what I prefer would be to try and rebuild the boot images (initrd/kernel) to add support for preseeding again. – aseq Jul 05 '22 at 22:50
2

I have preseeding almost working in a 22.04 "built from scratch" ISO. In my ISO build chroot I still install the

ubiquity 
ubiquity-casper 
ubiquity-frontend-gtk
ubiquity-slideshow-ubuntu ubiquity-ubuntu-artwork

apt packages and preseeding almost works with my preseed file from 20.04. For some reason I must press continue on the "Download updates while installing Ubuntu screen", when I didn't have to in 20.04.

Edit: I was able to make it fully automated by adding to my preseed file

ubiquity ubiquity/download_updates boolean false
ubiquity ubiquity/use_nonfree boolean false
  • I did try and build an iso but it is a major pita. Do you have any pointers as to how you did that? – aseq Jun 29 '23 at 02:20
  • 1
    @aseq I have a project I am working on I hope to share, but this project was very helpful for me: https://github.com/mvallim/live-custom-ubuntu-from-scratch – user3113138 Jun 29 '23 at 04:07