Ubuntu 20.04 installer downloads ISO more than once

I have been working through the example posted by Andrew Lowther at Automated 20.04 Server Installation using PXE and live server image . For example using a linux cmdline similar to:

linux /vmlinuz ip=dhcp url=http://${pxe_default_server}/tftp/ubuntu-20.04-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http://${pxe_default_server}/tftp/

....and got things working (Thanks Andrew!)

Another question I have after working with this a bit. As one can see, the installer is going to downlaoad the ISO from http://${pxe_default_server}/tftp/ubuntu-20.04-live-server-amd64.iso in that example. In my httpd logs, I can see that the ISO gets downloaded 3 times over the network when doing one automated install. Is there a way I can make it not do that?

192.168.1.225 - - [06/Apr/2021:22:09:47 +0000] "GET /ubuntu-20.04.1-live-server-amd64.iso HTTP/1.1" 200 958398464 "-" "Wget"
192.168.1.225 - - [06/Apr/2021:22:13:24 +0000] "GET /ubuntu-20.04.1-live-server-amd64.iso HTTP/1.1" 200 958398464 "-" "Cloud-Init/20.2-45-g5f7825e2-0ubuntu1~20.04.1"
192.68.1.225 - - [06/Apr/2021:22:16:50 +0000] "GET /ubuntu-20.04.1-live-server-amd64.iso HTTP/1.1" 200 958398464 "-" "Cloud-Init/20.2-45-g5f7825e2-0ubuntu1~20.04.1"

Thanks!


I saw this got an answer on Discourse, but I thought I'd share what I found.

Adding cloud-config-url=/dev/null to the kernel arguments does prevent cloud-init from downloading the ISO, and the ISO is only downloaded once. The full grub line is now

linux /vmlinuz ip=dhcp url=http://${pxe_default_server}/tftp/ubuntu-20.04-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http://${pxe_default_server}/tftp/ cloud-config-url=/dev/null

why this happens

When using PXE, the url= parameter must be added to the kernel arguments to specify the location of the ISO file. I believe casper handles this and the argument must be in the form url=*.iso

cloud-init will also parse the url kernel argument and attempt to use it (twice, apparently). From https://github.com/canonical/cloud-init/blob/fc5d541529d9f4a076998b7b4a3c90bb4be0000d/doc/sources/kernel-cmdline.txt

when 'cloud-init start' runs, it will check to see if if one of 'cloud-config-url' or 'url' appear in key/value fashion in the kernel command line ... Cloud-init will then read the contents of the given url.

As the Discourse post points out, the cloud-config-url is checked first, so you can use a kludge to avoid the extra downloads.