Ubuntu 24.04 – Howto Autoinstall Ubuntu Server 24.04 through PXE Technology (Basic)

Hello World, 

In this post, we continue our first test and investigation about unattended installation of Ubuntu 24.04.  In our previous post, we have briefly explained how to perform an unattended installation of Ubuntu Desktop 24.04 ( see Ubuntu 24.04 – Howto Autoinstall Ubuntu Desktop 24.04 through PXE Technology (Basic)). 

In this post, we will focus on the Ubuntu Server 24.04 Edition. The general process is quite similar but it’s not exactly the same.  This post will not perform deep dive investigation.  Here, we are basically providing some instructions on how to deploy Ubuntu server 24.04 via PXE technology, and perform a basic automated installation.   

Let’s try to do this…..

Overview

Canonical has introduced a number of changes and deviations compared to the original Debian Linux Distribution.  One of the changes introduced concerns the new Ubuntu Installer and the technology used to perform automated or unattended installation.   

Debian based distribution usually uses preseed method to automate the installation of the operating system.   Ubuntu was using this technique as well.  However, recent Ubuntu releases are not using preseed method option anymore.  Ubuntu is now using yaml file and the autoinstall method to automate the installation of Ubuntu.   

More specifically,  you have to know that   

  • Ubuntu Server, Version 20.04 and later is using the new “Autoinstall” approach 
  • Ubuntu Desktop, Version 23.04 and later is using the new “Autoinstall” approach

To perform unattended installation against those releases, you will need to create an autoinstall configuration file used to perform the installation without any user interaction.  In this guide, we will provide some guidance on how to create the Autoinstall file and how to update the PXE Server configuration so the file is effectively used during the setup.  

Step by Step Guide

This section provides some guidance on how to create an autoinstall file.  The file provided here is really basic and should allow you to perform an unattended installation.  In this guide, we will not explain all the options and syntax used in the autoinstall file. You cand find more information about autoinstall for server on Ubuntu Documentation web site

You can use this post as a starting point. If you need to better control the installation process, feel free to update the Autoinstall file so he meets your specific requirements.  

Pre-requisites 

To successfully follow this specific guide, you will need to ensure that you have implemented the necessary PXE infrastructure that is needed.  We have described how to implement a PXE server within your network.  This information can be found at  Ubuntu 24.04 – Deploy Ubuntu 24.04 Server through PXE (BIOS & UEFI)

After following these instructions, you can move to the next step where you will be creating a simple auto install files… To automate the installation of Ubuntu Server 24.04 (in our example), we will need to create two files.  

We will need to create a yaml file called user-data and another file called meta-data

Creating the user-data file

We assume that you have setup the PXE Server as described in our previous post (see Ubuntu 24.04 – Deploy Ubuntu 24.04 Server through PXE (BIOS & UEFI)).  We will create our user-data file under /var/www/html/server 

sudo touch /var/www/html/server/user-data

This command will create an empty file.  We will populate the file with basic information.  Again, you can automate more settings but in this post we just want to demonstrate an basic unattended installation.  

#cloud-config
autoinstall:
  version: 1
  apt:
    disable_components: []
    fallback: offline-install
  keyboard:
    layout: be
    toggle: null
    variant: '' 
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
  package_update: false
  package_upgrade: false

 

In this example, the encrypted password in our example is set to ubuntu.   You can encrypt the password to be used in the file via openssl tool or the mkpasswd tool. 

Creating the meta-data file

We assume that you have setup the PXE Server as described in our previous post (see Ubuntu 24.04 – Deploy Ubuntu 24.04 Server through PXE (BIOS & UEFI)).  We will create our empty meta-data file under /var/www/html/server 

sudo touch /var/www/html/server/meta-data

This file is empty but still need to be presented in the correct location 

At the end of the process,  the server directory (/var/www/html/server) needs to be populated with the following files 

  • meta-data
  • user-data
  • ubuntu server iso file 

 

Click on Picture for better Resolution

Updating the PXE Server Config Files

It is time to update the pxe and grub bootloader configuration file so they know where to find and download the autoinstall files needed to automate the installation.  Let’s proceed….  

Update the PxeLinux.cfg 

You will need to update the default file (located under /tftp/bios/pxelinux.cfg/).  You will add a new section (Ubuntu 24.04 Server – Autoinstall).  In this section, we have specified additional parameters pointing to the autoinstall.yaml file.   

 

DEFAULT menu.c32
MENU TITLE ULTIMATE PXE SERVER - By Griffon - Ver 2.0
PROMPT 0 
TIMEOUT 0

MENU COLOR TABMSG 37;40 #ffffffff #00000000
MENU COLOR TITLE 37;40 #ffffffff #00000000 
MENU COLOR SEL 7 #ffffffff #00000000
MENU COLOR UNSEL 37;40 #ffffffff #00000000
MENU COLOR BORDER 37;40 #ffffffff #00000000

LABEL Ubuntu Server 24.04 - Interactive
kernel /boot/casper/linux
initrd /boot/casper/initrds 
append root=/dev/ram0 ramdisk_size=1500000 ip=dhcp cloud-config-url=/dev/null iso-url=http://192.168.1.160/server/u2404.iso ---

LABEL UBUNTU 24.04 Server- AutoInstall
kernel /boot/casper/linux
initrd /boot/casper/initrds
append ip=dhcp iso-url=http://192.168.1.160/server/u2404.iso ds="cloud-net;s=http://192.168.1.160/server/" autoinstall debug cloud-config-url=http://192.168.1.160/server/user-data ---

Note :  Update this file to reflect the ip address you would be using.  In our example, the pxe server is using the ip address 192.168.1.160 but you can use any ip address on your internal network.

Update the Grub.cfg 

You will need to update the grub.cfg file (located under /tftp/grub/).  You will add a new section (Ubuntu Server 24.04 – Autoinstall).  In this section, we have specified additional parameters pointing to the autoinstall.yaml file.   

if loadfont /grub/font.pf2 ; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxtermterminal_output gfxterm
fi
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
set timeout=5

menuentry "Ubuntu Server 24.04 - Interactive" {
set gfxpayload=keep
linux /boot/casper/linux ip=dhcp iso-url=http://192.168.1.160/server/u2404.iso ---
initrd /boot/casper/initrds
}

menuentry "Ubuntu Server 24.04 - AutoInstall" { 
set gfxpayload=keep
linux /boot/casper/linux ip=dhcp iso-url=http://192.168.1.160/server/u2404.iso ds="cloud-net;s=http://192.168.1.160/server/" autoinstall debug cloud-config-url=http://192.168.1.160/server/user-data ---
initrd /boot/casper/initrds

}

Note :  Update this file to reflect the ip address you would be using.  In our example, the pxe server is using the ip address 192.168.1.160 but you can use any ip address on your internal network.

Post Setup 

If everything is working as expected, the target host will boot in pxe mode and the installation will proceed with no Wizard showing up. It might take some time before it completed ( +/- 30 min).  The system will reboot automatically.  At this stage, you will be prompted for a login and a password.  Again, in our example, we have used the following credentials 

  • user = ubuntu 
  • password = ubuntu  

If everything is working as expected, you will be able to login to your newly installed Ubuntu Server 

Click on Picture for better Resolution

Final Notes 

This is it for this post ! 

We have only scratched the surface here but with this post, you should be able to perform an unattended installation of Ubuntu Server 24.04 while using PXE technology. This post is not about to explain all the options and settings of autoinstall.  We only wanted to test and demonstrate how autoinstall could be used.  Following these instructions, you should be able to automate your install.  Use this post as a starting point and if you customize further your uanttended installation, do not hesitate to share it 🙂

Till next time 

See ya

 

Leave a Reply