Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]


Ubuntu

In this tutorial I will share step by step instructions to setup IPv4 UEFI PXE Boot Server to perform automated install of Ubuntu 20.04 using cloud-init.

 

Why not using kickstart to perform automated install in Ubuntu?

If you are coming from Red Hat or CentOS background then you are most likely familiar with using Kickstart for automated installation. Now we can also perform automated installation of Ubuntu 20.04 or older version using Kickstart but it is not completely supported. The official Ubuntu documentation talks about this very briefly with not much clear instructions on how this can be performed.

Now all the parameters in the Red Hat kickstart are not supported with Ubuntu, so you will end up using preseed for many things such as configuring partitions, networking etc.

But the biggest problem with using Kickstart for Ubuntu is that the normal Ubuntu Desktop and Live image do not support kickstart based installation so you have to use their legacy server release. These legacy server release images will be released only for Ubuntu 20.04 and will not be released for any future releases in Ubuntu as they want to promote their in-house cloud-init feature to perform the automated installation.

 

What is cloud-init or auto-install in Ubuntu?

This is a newly added feature in Ubuntu 20.04 which supersedes the preseeded mode of installation which was performed using debian-installer. The one big advantage of using cloud-init over debian-installer is that you don't need to specify answer to each installation option in cloud-init. By default cloud-init will consider the default value and proceed with the installation. It will fail only when there are no default values assigned unlike debian-installer (preseed) which will halt the installation for any and every missing input.

Although since this is a new feature so there is a lack of good documentation and debugging can be quite time consuming. You can read more about this on cloud-init official page.

 

Brief steps involved to configure PXE Boot Server with cloud-init

We will be performing the following steps to setup our PXE boot server to perform an automated installation of Ubuntu 20.04 using cloud-init.

  1. Download Ubuntu Image (We will use ubuntu-20.04.3-live-server-amd64.iso)
  2. Install and Configure TFTP
  3. Install and Configure DHCP
  4. Install and Configure HTTP
  5. Prepare cloud-init file
  6. Perform IPv4 UEFI PXE Boot

 

Lab Environment

I have two physical servers running with UEFI BIOS environment wherein on one server I have manually installed Ubuntu 20.04 which will act as our server where we will install all TFTP, DHCP and other services. While we will use the other server as our client where we will perform the PXE boot for automated installation.

The server specs are as follows:

  • IP Address: 10.43.138.8
  • Hostname: ubuntu
  • Release: Ubuntu 20.04.3 LTS
  • Version: 20.04.3 LTS (Focal Fossa)

 

Pre-requisite

  • You will need an active internet connection on the server where we will have to download and install some packages.
  • You can place the downloaded Ubuntu image either on this server where we can use HTTP to load the image on the client or you can also mount the image directly on the client. But in this case the configuration may slightly differ. In this article we will assume that you have downloaded the Ubuntu live-server ISO and placed on your server.

 

Steps to configure IPv4 UEFI PXE Boot Server using cloud-init on Ubuntu 20.04

Step-1: Install and Configure Apache Server

First of all, let's bring up our Apache server as we will need this to host our Ubuntu image and our configuration files required to perform PXE Boot.

# apt install apache2 -y

Next we created a new file ks-server.conf under /etc/apache2/sites-available/ with the following content:

# cat /etc/apache2/sites-available/ks-server.conf
<VirtualHost 10.43.138.8:80>
    ServerAdmin root@server1.example.com
    DocumentRoot /
    ServerName server.example.com
    ErrorLog ${APACHE_LOG_DIR}/ks-server.example.com-error_log
    CustomLog ${APACHE_LOG_DIR}/ks-server.example.com-access_log common
    <Directory /ks>
        Options Indexes MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    <Directory /images>
        Options Indexes MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

So, here basically we have configured virtual hosting for 2 directories i.e. /ks which will contain our cloud-init files and /images where we will place our ubuntu live-server iso image.

Next make sure these directories exist (you can create if not present) and have world readable permission:

root@ubuntu:~# ls -ld /images/
drwxr-xr-x 3 root root 4096 Jan  3 11:38 /images/

root@ubuntu:~# ls -ld /ks/
drwxr-xr-x 2 root root 4096 Jan 11 23:07 /ks/

Next start/restart and enable the apache service to start automatically on reboot:

# systemctl enable apache2 --now
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2

Check the status of the service to make sure it has started successfully:

# systemctl status apache2

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

If you face any issues then you can check the Error Log file which you have added in your virtual hosting configuration block under  /var/log/apache2/ directory.

root@ubuntu:/etc/apache2# ls -l /var/log/apache2/ks-server.example.com-*
-rw-r--r-- 1 root root 17891 Jan 11 23:10 /var/log/apache2/ks-server.example.com-access_log
-rw-r--r-- 1 root root 12859 Jan 11 21:59 /var/log/apache2/ks-server.example.com-error_log

Enable firewall for Apache web server:

# ufw allow Apache
Rules updated
Rules updated (v6)

Verify the status:

# ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache                     ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache (v6)                ALLOW       Anywhere (v6)

 

I have created one more sub-directory inside /images for my testing:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

Here is the content of /ks accessed via apache server, you can for now ignore those files. We will discuss about them in the next section:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

So we know that our apache server is working properly

 

Step-2: Prepare cloud-init autoinstall file

This is the most tricky part of automating ubuntu installation using cloud-init as unlike Red Hat, we don't have a sample cloud-init configuration file to start with. For example, in Red Hat or CentOS we used to pick /root/anaconda.cfg as our base template and then we used to modify the required parameters for our network installation. But here we don't have any such template to pick as default.

I have written a detailed article covering the steps required to create this autoinstall configuration file. So you can follow the same to create one for your environment.

Here is my sample /ks/user-data file which I will be using for this installation:

root@ubuntu:/srv/tftp# cat /ks/user-data
#cloud-config
autoinstall:
  apt:
    geoip: true
    preserve_sources_list: false
    primary:
    - arches: [amd64, i386]
      uri: http://in.archive.ubuntu.com/ubuntu
    - arches: [default]
      uri: http://ports.ubuntu.com/ubuntu-ports
  identity: {hostname: ubuntu-server, password: $6$iy4HsFNBff99T8fC$R/g0/WvD5c4P3gki0R7Aaf4yAbrKX00Bk/6Q6Ndh1pCmIlsvZkBnISYVQTM2t2nJ7Dzt039QWhg3s7fwpL9Mc.,
    realname: Deepak, username: deepak}
  keyboard: {layout: us, toggle: null, variant: ''}
  locale: en_US.UTF-8
  network:
    ethernets:
      eno49:
        critical: true
        dhcp-identifier: mac
        dhcp4: true
        nameservers:
          addresses: [127.0.0.1]
      eno50: {dhcp4: true}
      eno51: {dhcp4: true}
      eno52: {dhcp4: true}
      eno53: {dhcp4: true}
      eno54: {dhcp4: true}
      eno55: {dhcp4: true}
      eno56: {dhcp4: true}
    version: 2
  proxy: http://100.58.10.60:8000
  ssh:
    allow-pw: true
    authorized-keys: []
    install-server: true
  storage:
    config:
    - {ptable: gpt, serial: 3600508b1001c576619b6670156e25877, wwn: '0x600508b1001c576619b6670156e25877',
      path: /dev/sda, wipe: superblock, preserve: false, name: '', grub_device: false,
      type: disk, id: disk-sda}
    - {device: disk-sda, size: 536870912, wipe: superblock, flag: boot, number: 1,
      preserve: false, grub_device: true, type: partition, id: partition-0}
    - {fstype: fat32, volume: partition-0, preserve: false, type: format, id: format-0}
    - {device: disk-sda, size: 1073741824, wipe: superblock, flag: '', number: 2,
      preserve: false, grub_device: false, type: partition, id: partition-1}
    - {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1}
    - {device: disk-sda, size: 898538405888, wipe: superblock, flag: '', number: 3,
      preserve: false, grub_device: false, type: partition, id: partition-2}
    - name: ubuntu-vg
      devices: [partition-2]
      preserve: false
      type: lvm_volgroup
      id: lvm_volgroup-0
    - {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 214748364800B, wipe: superblock,
      preserve: false, type: lvm_partition, id: lvm_partition-0}
    - {fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-2}
    - {path: /, device: format-2, type: mount, id: mount-2}
    - {path: /boot, device: format-1, type: mount, id: mount-1}
    - {path: /boot/efi, device: format-0, type: mount, id: mount-0}
  updates: security
  version: 1

Next we will create /ks/meta-data file with the hostname of our server which we will assign to the client. You can also just create an empty file and place it under /ks directory.

# cat > /ks/meta-data <<EOF
instance-id: ubuntu-server
EOF

 

Step-3: Install and Configure TFTP Server

Next we will install and configure TFTP server to host the PXE boot files required to trigger the network installation.

apt install tftpd-hpa -y

To list the content of the installed package you can use dpkg command:

# dpkg -L tftpd-hpa
/.
/etc
/etc/init
/etc/init/tftpd-hpa.conf
/etc/init.d
/etc/init.d/tftpd-hpa
/usr
/usr/sbin
/usr/sbin/in.tftpd
/usr/share
/usr/share/doc
/usr/share/doc/tftpd-hpa
/usr/share/doc/tftpd-hpa/README
/usr/share/doc/tftpd-hpa/README.Debian
/usr/share/doc/tftpd-hpa/README.security
/usr/share/doc/tftpd-hpa/changelog.Debian.gz
/usr/share/doc/tftpd-hpa/copyright
/usr/share/doc/tftpd-hpa/examples
/usr/share/doc/tftpd-hpa/examples/sample.rules
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz

You can check the default configuration for TFTP in /etc/default/tftpd-hpa file:

# cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"

So, by default the TFTP server will look into /srv/tftp, so if you want to use any alternate path then you can update the same here. Verify that this path already exist, if not you can create the same and assign 755 permission to this directory to make sure everyone can access it.

# ls -ld /srv/tftp/
drwxr-xr-x 5 tftp root 4096 Jan 11 23:59 /srv/tftp/

Nest start/restart and enable the service to automatically start on server reboot:

# systemctl enable tftpd-hpa --now
tftpd-hpa.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable tftpd-hpa

Check the status of the service to make sure it is started and running successfully:

# systemctl status tftpd-hpa

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

 

Step-4: Configure PXE Boot Server

Next to perform automated installation over network, we will need some PXE boot files. These files can be collected from the Ubuntu live-server image which we have already downloaded and kept on our server.

Mount the image to some temporary mount path to be able to access the content:

# mount /home/ubuntu-20.04.3-live-server-amd64.iso /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.

Next we will need vmlinuz and initrd file to perform the PXE. These files are available inside casper directory of the ubuntu image which we have mounted under /mnt:

root@ubuntu:/srv/tftp# cp -rvf /mnt/casper/{initrd,vmlinuz} /srv/tftp/
'/mnt/casper/initrd' -> '/srv/tftp/initrd'
'/mnt/casper/vmlinuz' -> '/srv/tftp/vmlinuz'

For UEFI BIOS Platform we would need grub confiuration file. Now the grub conf file to be used may differ based on your hardware architecture

  • For arm64 architecture, it is grubnetaa64.efi.signed.
  • For amd64 architecture, it is grubnetx64.efi.signed.

Since we are having amd64 environment so we will need grubnetx64.efi to boot our environment. The next important file required to configure UEFI PXE Boot is shim.efi.signed which is actually used by DHCP server to boot the TFTP server and then the control is passed on to grubnetx64.efi.

Download shim.signed package under /tmp folder:

root@ubuntu:/tmp# apt-get download shim.signed -y
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 shim-signed amd64 1.40.7+15.4-0ubuntu9 [448 kB]
Fetched 448 kB in 0s (1,036 kB/s)

root@ubuntu:/tmp# ls -l shim-signed_1.40.7+15.4-0ubuntu9_amd64.deb
-rw-r--r-- 1 root root 447804 Aug 14 02:13 shim-signed_1.40.7+15.4-0ubuntu9_amd64.deb

Extract the shim.signed package to get shimx64.efi.signed binary, rename it to bootx64.efi and store it inside /srv/tftp:

root@ubuntu:/tmp# dpkg-deb --fsys-tarfile /tmp/shim-signed*deb | tar x ./usr/lib/shim/shimx64.efi.signed -O > /srv/tftp/bootx64.efi

Next download grub-efi-amd64-signed package under /tmp folder:

root@ubuntu:/tmp# apt download grub-efi-amd64-signed
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 grub-efi-amd64-signed amd64 1.167.2+2.04-1ubuntu44.2 [482 kB]
Fetched 482 kB in 1s (865 kB/s)

root@ubuntu:/tmp# ls -l /tmp/grub-efi-amd64-signed_1.167.2+2.04-1ubuntu44.2_amd64.deb
-rw-r--r-- 1 root root 482356 May 21  2021 /tmp/grub-efi-amd64-signed_1.167.2+2.04-1ubuntu44.2_amd64.deb

Extract grub-efi-amd64-signed package to get grub-efi-amd64-signed, rename it to grubx64.efi and store it inside /srv/tftp directory:

root@ubuntu:/tmp# dpkg-deb --fsys-tarfile /tmp/grub-efi-amd64-signed*deb | tar x ./usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed -O > /srv/tftp/grubx64.efi

Grub also needs a font to be available over tftp:

root@ubuntu:/tmp# apt download grub-common
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 grub-common amd64 2.04-1ubuntu26.13 [1,875 kB]
Fetched 1,875 kB in 1s (1,568 kB/s)

Extract the grub-common*deb package to get unicode.pf2 and copy the same under /srv/tftp directory:

root@ubuntu:/tmp# dpkg-deb --fsys-tarfile grub-common*deb | tar x ./usr/share/grub/unicode.pf2 -O > /srv/tftp/unicode.pf2

List the content of /srv/tftp folder at this stage:

root@ubuntu:/tmp# ls -l /srv/tftp/
total 100248
-rw-r--r-- 1 root root      875 Jan  9 19:57 '~'
-rw-r--r-- 1 root root   955656 Jan 12 22:06  bootx64.efi
-rw-r--r-- 1 root root  1492864 Jan 12 22:03  grubx64.efi
-r--r--r-- 1 root root 86017541 Jan 12 22:01  initrd
-rw-r--r-- 1 root root  2395475 Jan 12 22:04  unicode.pf2
-r--r--r-- 1 root root 11772160 Jan 12 22:01  vmlinuz

 

Step-5: Create PXE configuration file

For UEFI PXE Boot we need a grub.cfg file which must be created under grub directory on the tftp path with the details of PXE boot files required for installation over network. Following is the content from my grub/grub.cfg file:

root@ubuntu:/srv/tftp# cat grub/grub.cfg
set default="0"
set timeout=-30

if loadfont unicode ; then
  set gfxmode=auto
  set locale_dir=$prefix/locale
  set lang=en_US
fi
terminal_output gfxterm

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
  clear
fi

function gfxmode {
        set gfxpayload="${1}"
        if [ "${1}" = "keep" ]; then
                set vt_handoff=vt.handoff=7
        else
                set vt_handoff=
        fi
}

set linux_gfx_mode=keep

export linux_gfx_mode

menuentry 'Install Ubuntu 20.04' {
        gfxmode $linux_gfx_mode
        linux vmlinuz  ip=dhcp  url=http://10.43.138.8/images/ubuntu20/ubuntu-20.04.3-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http://10.43.138.8/ks/ cloud-config-url=/dev/null fsck.mode=skip
        initrd initrd
}

Let us understand the individual option used in our kernel menu

  • url: provide the ubuntu live-server image link
  • autoinstall: This will make sure that the server installer will not ask for any confirmation before writing to the disks
  • ds=nocloud-net: Means the instance is booting on a cloud of some sort, however do not expect the cloud metadata service to be available! This helps cloud-init not wait for the metadata service to appear. You can pass a custom metadata network service by passing the s= parameter
  • s=<seedlocation>: This allows you to set the 'seed location'. The value can be a url of 'file:///' format, or of 'http://' format. If you want to use http or another network based seed, then 'nocloud-net' must be used as the data source, rather than 'nocloud'. meta-data and user-data will be read from <seedlocation>meta-data and <seedlocation>user-data respectively. For more details you can read UEC/Images/KVMKernelOptions and NoCloud
  • cloud-config-url: 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.
  • ip=dhcp: This will assign the address via DHCP server
  • fsck.mode=skip: By default ubuntu installer will perform integrity check of the ISO which takes up some time so we will disable that.
IMPORTANT NOTE:
For UEFI based environment, it is important that you escape the semi-colon used in ds=cloud-net\;s or else for some reason the autoinstall doesn't work.

 

Step-7: Install and configure DHCP

We will also need one DHCP server to provide our client with an IP Address. So let's go ahead and install required package:

# apt install isc-dhcp-server -y

This will install the dhcp package on your Ubuntu host. Next you can update /etc/dhcp/dhcpd.conf file to with the configuration details. Here is a sample input file from my setup:

allow bootp;
allow booting;
max-lease-time 1200;
default-lease-time 900;
log-facility local7;

option ip-forwarding    false;
option mask-supplier    false;

   subnet 10.43.138.0 netmask 255.255.255.224 {

       option routers 10.43.138.30;
       option domain-name-servers 127.0.0.1;
       range 10.43.138.20 10.43.138.26;
       next-server 10.43.138.8;
       filename "bootx64.efi";
   }

Here we have basically defined our subnet and netmask value. You can get this using different linux commands such as:

root@ubuntu:/srv/tftp# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.43.138.30    0.0.0.0         UG    20100  0        0 eno49
10.43.138.0     0.0.0.0         255.255.255.224 U     100    0        0 eno49
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eno49

Here eno49 is our primary interface which has 10.43.138.0 as the subnet and 255.255.255.224 as the netmask value. The option routers contain the gateway of your server IP, which we can again get using following command:

root@ubuntu:/srv/tftp# ip route
default via 10.43.138.30 dev eno49 proto static metric 20100
10.43.138.0/27 dev eno49 proto kernel scope link src 10.43.138.8 metric 100
169.254.0.0/16 dev eno49 scope link metric 1000

Here 10.43.138.30 is our default gateway which will act as a router for all incoming DHCP request.

The filename directive is used to define the PXE file which will be used to perform the autoinstall i.e. bootx64.efi for UEFI BIOS Environment. If you had created any sub directory inside /srv/tftp such as /srv/tftp/pxelinux then you should add filename as "pxelinux/bootx64.efi"

We have defined a range between 10.43.138.20 and 10.43.138.26 to assign the IP address to our destination nodes which will be installed over the network. This range must be free and must not be in use by any other server.

Next enable and start the DHCP server service:

# systemctl enable isc-dhcp-server.service --now
Synchronizing state of isc-dhcp-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable isc-dhcp-server

Check the status of DHCP service to make sure it is started successfully:

root@ubuntu:/srv/tftp# systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - ISC DHCP IPv4 server
     Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-01-12 09:22:41 IST; 4h 12min ago
       Docs: man:dhcpd(8)
   Main PID: 57854 (dhcpd)
      Tasks: 4 (limit: 154489)
     Memory: 4.5M
     CGroup: /system.slice/isc-dhcp-server.service
             └─57854 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

 

Step-8: Configure firewall

We already configured firewall for Apache as I wanted to show you the screenshot of apache server. But just to consolidate, add the following rule to allow Apache service:

# ufw allow Apache

Add the following rule to allow TFTP

# ufw allow from any to any proto udp port 69

Add the following rule to allow DHCP

# ufw allow bootps
# ufw allow from any to any port 53

Check the status ( I have some more firewall rules for other features):

# ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache                     ALLOW       Anywhere
69/udp                     ALLOW       Anywhere
67/udp                     ALLOW       Anywhere
53/udp                     ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache (v6)                ALLOW       Anywhere (v6)
69/udp (v6)                ALLOW       Anywhere (v6)
67/udp (v6)                ALLOW       Anywhere (v6)
53/udp (v6)                ALLOW       Anywhere (v6)

 

Step-9: Perform PXE Boot using cloud-init

Now we are done with our configuration and we are ready to perform the automated installation using autoinstall configuration file.

Boot your client node and perform a network based installation. Now the shortcut button to boot over network may vary for different hardware but on most cases we are expected to press F12 to boot from network:

If your PXE Boot Server configuration is proper, then the UEFI PXE  boot files should be download successfully:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

 

Next we see our boot screen with the menuentry content to start the automated installation using cloud-init configuration file:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

 

Once we press Enter, the installation should start. Next the installer will pick the image from url we added in our grub file and if everything is good, then the installation will start:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

 

Now we wait for some time for the installation to complete and then we finally have our login prompt:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

 

And we are also able to login successfully using the user we created in our autoinstall configuration file:

Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]

 

Step-10: Verify target node connectivity

Try to connect to the target node using SSH:

root@ubuntu:/srv/tftp# ssh 10.43.138.21
The authenticity of host '10.43.138.21 (10.43.138.21)' can't be established.
ECDSA key fingerprint is SHA256:4Xa1BbBKpdlUHgU922qG948a6eiaWtIi2MU5pvLZWag.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.43.138.21' (ECDSA) to the list of known hosts.
root@10.43.138.21's password:

root@ubuntu:/srv/tftp# ssh deepak@10.43.138.21
deepak@10.43.138.21's password:
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-94-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed 12 Jan 2022 07:13:21 PM UTC

  System load:            0.0
  Usage of /:             5.2% of 195.86GB
  Memory usage:           0%
  Swap usage:             0%
  Temperature:            44.0 C
  Processes:              362
  Users logged in:        1
  IPv4 address for eno49: 10.43.138.21
  IPv6 address for eno49: 2001:1:1:1442:217:a4ff:fe77:32
  IPv4 address for eno50: 10.43.138.23
  IPv6 address for eno50: 2001:1:1:1442:217:a4ff:fe77:34


45 updates can be applied immediately.
To see these additional updates run: apt list --upgradable


Last login: Wed Jan 12 19:05:03 2022
deepak@ubuntu-server:~$

So, our automate installation using PXE Boot Server configured with cloud-init is successful.

 

Troubleshooting autoinstaller related issues

It is possible you may face issues with the autoinstall configuration file, in which case you will most likely get a shell to debug the issue. You can navigate inside /var/log/installer/ where you can find all the autoinstaller log files which are quiet detailed and is helpful is troubleshooting.

# ls -l /var/log/installer/
total 812
-rw------- 1 root root   2017 Jan 12 11:24 autoinstall-user-data
drwxr-xr-x 2 root root   4096 Jan 12 11:21 block
-rw-r--r-- 1 root root     23 Jan 12 11:23 casper-md5check.json
-r-------- 1 root root   3856 Jan 12 11:23 curtin-install-cfg.yaml
-r-------- 1 root root 109362 Jan 12 11:24 curtin-install.log
-rw-r--r-- 1 root root 558728 Jan 12 11:24 installer-journal.txt
-rw-r--r-- 1 root root     66 Jan 12 11:23 media-info
lrwxrwxrwx 1 root root     31 Jan 12 11:21 subiquity-client-debug.log -> subiquity-client-debug.log.2649
-rw-r--r-- 1 root root    352 Jan 12 11:21 subiquity-client-debug.log.2649
lrwxrwxrwx 1 root root     30 Jan 12 11:21 subiquity-client-info.log -> subiquity-client-info.log.2649
-rw-r--r-- 1 root root    180 Jan 12 11:21 subiquity-client-info.log.2649
-rw-r--r-- 1 root root   3300 Jan 12 11:22 subiquity-curtin-install.conf
lrwxrwxrwx 1 root root     31 Jan 12 11:21 subiquity-server-debug.log -> subiquity-server-debug.log.2634
-rw-r--r-- 1 root root 108401 Jan 12 11:24 subiquity-server-debug.log.2634
lrwxrwxrwx 1 root root     30 Jan 12 11:21 subiquity-server-info.log -> subiquity-server-info.log.2634
-rw-r--r-- 1 root root  12388 Jan 12 11:24 subiquity-server-info.log.2634

 

Summary

In this tutorial I covered the step by step instructions to install and configure IPv4 UEFI PXE boot server to perform automated installation of Ubuntu 20.04 using cloud-init configuration file. We were successfully able to bring up our Linux server using autoinstall configuration file from cloud-init without any manual intervention.

Now cloud-init autoinstall configuration file is a vast topic and I have just covered basic automated installation steps, I am yet to analyse the parts where we can further customise the user-data file to add or remove packages, execute pre and post scripts or commands etc which I will be slowly covering in upcoming articles.

Let me know your success or failures using the comment section.

 

Further Reading

Netbooting the server installer on amd64
SecureBoot-compatible UEFI netboot over IPv4 and IPv6
UEFI PXE netboot / install procedure
Netbooting the Live Server Installer via UEFI PXE on Arm (aarch64, arm64) and x86_64 (amd64)

 

Deepak Prasad

Deepak Prasad

Deepak Prasad is the founder of GoLinuxCloud, bringing over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, Networking, and Security. His extensive experience spans development, DevOps, networking, and security, ensuring robust and efficient solutions for diverse projects.

Certifications and Credentials:

  • Certified Kubernetes Application Developer (CKAD)
  • Go Developer Certification
  • Linux Foundation Certified System Administrator (LFCS)
  • Certified Ethical Hacker (CEH)
  • Python Institute PCAP (Certified Associate in Python Programming)
You can connect with him on his LinkedIn profile and join his Facebook and LinkedIn page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

6 thoughts on “Setup IPv4 UEFI PXE Boot Server Ubuntu 20.04 [cloud-init]”

  1. Hi Deepak
    I followed the step and able to boot successfully but its getting stopped at this screen.
    https://assets.ubuntu.com/v1/ef037190-subiquity_welcome_page.png
    I am using Ubuntu 22.04 Server Live ISO and below is my grub file

    title Ubuntu 22.02
         root (nd)
            kernel  /images/ubuntu22.04-server/vmlinuz ip=dhcp url=http://X.X.X.X/ubuntu22.04-server/ubuntu-22.04.1-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http=//X.X.X.X/ks/user-data cloud-config-url=/dev/null fsck.mode=skip
           initrd  /images/ubuntu22.04-server/initrd
    Reply
  2. Thanks for this tutorial!
    I’ve tried this but still cannot do autoinstallation successfully.
    It just started a normal installation flow and ask me to pick an option.
    I used Ubuntu 20.04.6 live server version for both server and image.
    Menu entry setting:

    menuentry 'Install Ubuntu 20.04' {
            gfxmode $linux_gfx_mode
            linux vmlinuz ip=dhcp url=http://10.35.173.222/images/ubuntu-20.04.6-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http://10.35.173.222/ks/ cloud-config-url=/dev/null fsck.mode=skip console=ttyS1,57600n8
            initrd initrd
    }
    Reply
  3. Hey Admin
    when i start installation automation from init cloud i see the interface of ubuntu up and nothing happen on background.
    what i am gonna do?

    thats the conf on conf.cfg

    menuentry 'Install Ubuntu 20.04' {
            gfxmode $linux_gfx_mode
            linux vmlinuz  ip=dhcp  url=http://10.189.199.128/images/ubuntu20/ubuntu-20.04.4-desktop-amd64.iso autoinstall ds=nocloud-net\;s=http://10.189.199.128/ks/user-data cloud-config-url=/dev/null fsck.mode=skip
            initrd initrd
    }
    Reply
  4. hey
    i did it by the book and when i try to boot from pxe i get message
    minimal bash-like line editing is support. for the first word , TAB lists possible
    command completions. anywhere else TAB lists possible device or file completions.
    NBP filename is bootx64.efi
    NBP filesize is 955656 bytes

    and is enter to grub>

    can you help me please?

    Reply
    • It would mean that there is problem with your TFTP. Try disabling the firewall and check the TFTP files are accessible by world

      Reply

Leave a Comment