Ubuntu 22.04 Autoinstall method
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.txtThis 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.2022Found some working piece at least with http server. So working boot command is:
`linux /casper/vmlinuz --- autoinstall quiet 'ds=nocloud-net;s= 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.txtThat 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..
5 Answers
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.
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.
1I 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.
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.
1The 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
3