3

Does anybody figured out the right way of providing autoinstall data with custom iso file via grub? Clearly Ubuntu 22.04 doesn't provide the nice way of definition of boot commands via casper (sort of interactive menu [after boot, F6 and so on..]) like Ubuntu 20.04 does.

Starting point:

  • Ubuntu 22.04 iso file downloaded from Ubuntu site.
  • custom iso file with user-data and meta-data

Custom iso contains:

  • user-data with 'answers' for installer
  • meta-data is an empty file

Iso file is created by this command: mkisofs -V cidata -lJR -o custom.iso user-data meta-data

So the mark 'cidata' (necessary as cloud-init documentation describes) is present. Now once the vm is created and started installer simply fails to find answer file and it starts with the installer guide instead. However user-data can be found in this path:

/var/lib/cloud/instances/nocloud/user-data.txt

This file contains the original data I've created.

Now the most important part is the GRUB, that looks like:

       `linux /casper/vmlinuz autoinstall quiet \"ds=nocloud;s=/\" ---
        initrd /casper/initrd
        boot`

This example should be just fine, however it is not. Even if I provide full path to the file - it is a no go. I also tried to provide answer files via http server, but result is the same.

That example:

       `linux /casper/vmlinuz autoinstall quiet ---
        initrd /casper/initrd
        boot`

Should be enough as well but it doesn't work either. Any ideas, anyone?

EDIT 26.5.2022 Found some working piece at least with http server. So working boot command is:

       `linux /casper/vmlinuz --- autoinstall quiet 'ds=nocloud-net;s=http://192.168.100.100/'
        initrd /casper/initrd
        boot`

Now further info about additional iso file. I think it's not being mounted properly. Since with this command:

       `linux /casper/vmlinuz --- autoinstall quiet
        initrd /casper/initrd
        boot`

I see a user-data.txt file in this path:

/var/lib/cloud/instances/nocloud/user-data.txt

That is fine, some logs however show:

cat /var/log/cloud-init-output.log Cloud-init v. 22.1-14-g2e17a0d6-0ubuntu1~22.04.5 finished at Thu, 26 May 2022 10:52:10 +0000. Datasource DataSourceNoCloudNet [seed=cmdline,/var/lib/cloud/seed/nocloud,/dev/sr1][dsmode=net]. Up 63.17 seconds

cat /var/log/cloud-init.log 2022-05-26 10:51:24,065 - subp.py[DEBUG]: Running command ['mount', '-o', 'ro', '-t', 'auto', '/dev/sr1', '/run/cloud-init/tmp/tmpb4d62dyf'] with allowed return codes [0] (shell=False, capture=True) 2022-05-26 10:51:35,825 - handlers.py[DEBUG]: finish: init-network/consume-user-data: SUCCESS: reading and applying user-data

So clearly something happens there. Nonetheless with boot commands listed above NO files are being downloaded from the addional iso file. Meaning that file: /var/lib/cloud/instances/nocloud/user-data.txt is EMPTY. If I do manually mount /dev/sr1 /mnt I can see my user-data.
Perhaps somehow mount the iso file with the GRUB cli and pointing the cloud-init to that? Certainly an option.. Will keep hacking..

karel
  • 122,292
  • 133
  • 301
  • 332
bizarreApple
  • 61
  • 1
  • 1
  • 7

7 Answers7

3

After a while the problem is solved. The correct boot command is:

   `linux /casper/vmlinuz autoinstall quiet ---
    initrd /casper/initrd
    boot`

and installer looks for user-data file indeed automatically. Do not really understand why providing 'ds=' section brakes it entirely. All you need is to generate iso file with cidata label containing at least two common files the user-data and meta-data. Also the content of user-file differs from what we have been using in Ubuntu 20.04, some bugs are gone which is good. As of today (26.5.2022) the Ubuntu autoinstall docs is sufficient so as the cloud-init doc.
Thanks Andrew Lowther for good point.

bizarreApple
  • 61
  • 1
  • 1
  • 7
0

Maybe try

menuentry "Try or Install Ubuntu Server" {
    set gfxpayload=keep
    linux   /casper/vmlinuz autoinstall quiet ds='nocloud;s=/cdrom/' ---
    initrd  /casper/initrd
}

When user-data and meta-data in root dir of iso.

0

I tried it with packer on vSphere. you can check the tutorial (link below) where he used Packer's cd_files to create a temporary ISO file containing the cloud-config files and mount it as an additional CD drive. N.B: in the tutorial, you will find ubuntu 20.04, but it works just fine if you change the iso path to your ubuntu 22.04 instance. https://tekanaid.com/posts/hashicorp-packer-build-ubuntu20-04-vmware

0

set timeout=-1
menuentry "Install Ubuntu Server 22 " {
    set gfxpayload=keep
    linux   /casper/vmlinuz quiet autoinstall ds=nocloud\;s=/cdrom/nocloud/ ---
    initrd  /casper/initrd
}

On the thumbdrive there is in the root a dir "nocloud" with a modified 'user-data' file.

Lex
  • 1
0

The layout from the root from the thumbdrive looks like this:

.disk
boot
casper
dists
EFI
install
nocloud
pool
autorun.ico
autorun.inf
boot.catalog
md5sum.txt

I made my thumbdrive with the original ISO Ubuntu 22.04 and written with Rufus. The thumbdrive is used to install servers unattended. I used this earlier for Ubuntu 20.04, before that I was using kickseed and d-i answers

Lex
  • 1
0

So for anyone looking for HTTP autoinstall on 22.04 vs 20.04.

This is used in a Hashicorp Packer build but these are the same commands you would run on the CLI anyway.

GRUB -> 20.04:

boot_command    = [
                     "<wait>",
                     "<esc><esc><esc>",
                     "<enter><wait>",
                     "/casper/vmlinuz ",
                     "initrd=/casper/initrd ",
                     "ip=${var.vm_nic1_ip_address}::${var.vm_nic1_ip_gateway}:${var.vm_nic1_ip_netmask}:${var.vm_name}:::${var.vm_nic1_nameservers[0]}:${var.vm_nic1_nameservers[1]} ",
                     "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/${local.ai_target_dir} ",
                     "boot",
                     "<enter><wait>"
                    ]

i.e

  1. Boot ISO
  2. Press <esc> key 3 times
  3. Prompt to exit from GUI interactive: Press to confirm 'yes'
  4. Type /casper/vmlinuz initrd=/casper/initrd ip=192.168.0.1::192.168.0.254:255.255.255.0:testdeploysrv01.local.com:::8.8.8.8:8.4.4.4 autoinstall ds=nocloud-net;s=http://192.168.0.250:9090/testdeploysrv01.local.com boot
  5. Press <enter>
  • 192.168.0.1 = temp IP to assign the booting server (if you don't have DHCP)
  • 192.168.0.354 = IP gateway for this subnet
  • 255.255.255.0 = subnet mask
  • testdeploysrv01.local.com = FQDN of the booting server
  • 8.8.8.8 = DNS 1
  • 8.4.4.4 = DNS 2

GRUB -> 22.04:

locals {

Autoinstall targets

## ai = autoinstall

ai_target_dir = "${var.vm_name}/" ai_data_source = "ds=&quot;nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/${local.ai_target_dir}&quot;" ai_boot_ip_addr = "ip=${var.vm_nic1_ip_address}::${var.vm_nic1_ip_gateway}:${var.vm_nic1_ip_netmask}:${var.vm_name}:::${var.vm_nic1_nameservers[0]}:${var.vm_nic1_nameservers[1]}" }

boot_command = [ "<wait>", "c", "<wait>", "linux /casper/vmlinuz autoinstall --- ${local.ai_boot_ip_addr} ${local.ai_data_source}", "<enter><wait>", "initrd /casper/initrd ", "<enter><wait>",
"boot", "<enter><wait>", ]

0

With Packer and ubuntu 22 iso file, I use this boot command and it works with the additional cdrom added by packer for autoinstall

vm_boot_command = [
        "<esc>c<wait>",
        "linux /casper/vmlinuz autoinstall quiet ds=nocloud ipv6.disable=1 ---",
        "<enter><wait>",
        "initrd /casper/initrd<enter><wait>",
        "boot<enter>"
]