Home Server, iPXE, Linux, Synology, Tech

Install Ubuntu via iPXE for UEFI

Install Ubuntu via iPXE for UEFI:

Prerequisites:
• iPXE
• TFTP
• NFS
• DHCP Server

First of all, let us download the needed ISO files for this project.
Ubuntu Desktop 22.04.2 LTS
Ubuntu 22.10 live server

iPXE:

iPXE can serve as a network boot server for both BIOS and UEFI systems. It’s open source, it can use many protocols to download the required boot files (TFTP, FTP, HTTP, HTTPS and NFS), but it needs compiling. In this case we will use a live installer on our synology virtual machine to compile iPXE and transfer it to our NAS.
Creating a iPXE shared folder:
Let’s create a shared folder to keep our iPXE boot files organized.

On your Synology, go to Control Panel and select Shared Folder.
Control Panel

Click Create and click Create Shared Folder.
Create shared folder
Fill out the name for the folder and click Next.
Shared folder creation wizard

In this case, encryption is not needed, click Next again.
On the next screen, click Next.
Confirm Settings

This is what your settings should look like. Click Next again.
In the following screen, leave the settings as is, (administrator and your own account should have read/write access). And click Apply.

Enable TFTP:
In Control Panel, go to File Services.
File Services

Go to tab Advanced, Enable TFTP Service and Click Select.
Select the Shared Folder you just created. Click Select and Apply.
Enable TFTP
Next, we are going to enable NFS. Go to tab NFS and select Enable NFS and Apply.
Enable NFS
Go back to Shared Folder in Control Panel, select your shared folder for iPXE and click Edit.
Go to tab NFS Permissions and click Create.
Create an NFS rule
In the Hostname or IP field, put an asterisk (*)
Privilege should be Read only
Select Allow connections from non-privileged ports and select Allow users to access mounted subfolders. Click Save.
Edit Shared folder iPxe
You should see something like this. Click Save again to apply the permissions on your shared folder.
Copy your Ubuntu Desktop and Ubuntu Server ISO files to the iPXE shared folder.

iPXE folder with Ubuntu image
Creating a ubuntu virtual machine on your nas to boot in live mode:
Go to Package Center and look for Virtual Machine Manager.
Package Center
Virtual Marchine Manager
If not installed, install Virtual Machine Manager.
When Virtual Machine Manager is installed, open it.
On the left side, go to Virtual Machine and on top of the window, click on Create.
Select Linux and click Next.
Select your storage and click Next.
Create Virtual Machine - specifications
Give your virtual machine a name, assign a CPU and Memory. Click Next.
Assign 30GB of diskspace and click Next.
Create Virtual Machine - Storage
For network, select Virtual network and click Next.
Create Virtual Machine - Configure Network
On the next screen for ISO file for bootup, click Browse and select ubuntu-22.04.2-desktop-amd64.iso and click Select.
Select ISO

Leave the rest of the settings and click Next.
Create Virtual Machine - Other Settings
For the power management permissions. Give your own user Allow rights and click Next.
Everything should look like this. Click Done.
Create Virtual Machine - Summary
The virtual machine will be created and will automatically boot.
Select the virtual machine and click Connect. A new browser window will open and your virtual machine will show.

Installing required Dependencies for building iPXE on Ubuntu Desktop Live:
Open the terminal.
Open Terminal
$ sudo apt-add-repository universe
Add Universe Repository
Press Enter.
Press Enter
$ sudo apt install build-essential liblzma-dev isolinux git
Install essentials

Press Y to continue.
Cloning iPXE Git Repository:
First navigate to ~/Downloads
cd to downloads
$ git clone https://github.com/ipxe/ipxe.git
git clone
Check if the Git Repository was downloaded.
$ ls -l
ls -l
Navigate to ipxe/src/
$ cd ipxe/src/
navigate to ipxe/src
List the directory again.
$ ls -l
Enabling iPXE NFS, HTTPS, and FTP Protocol Support:
$ nano config/general.h
Scroll to * Download protocols
config/general.h
Change #undef to #define for DOWNLOAD_PROTO_HTTPS, DOWNLOAD_PROTO_FTP and DOWNLOAD_PROTO_NFS.
changed undef to define
Press CTRL – X, Y and enter.
Creating an iPXE embedded Boot Configuration File:
$ nano bootconfig.ipxe
nano bootconfig.ipxe
bootconfig.ipxe
192.168.0.185 is the IP-address of my server, change it to the IP-address of your own server.
Press CTRL – X, Y and enter.
Compiling iPXE for UEFI-Based Motherboards:
$ make bin-x86_64-efi/ipxe.efi EMBED=bootconfig.ipxe
make bin
The ipxe.efi firmware is being compiled. This could take a minute or two to complete.

Uploading the required file to the NAS:
$ cp bin-x86_64-efi/ipxe.pxe ~/Downloads/
cp bin to downloads
Open Firefox, go to the webinterface op your NAS and open File Station.
open Files in Ubuntu, navigate to the Downloads folder and drag ipxe.efi into File Station in Firefox.
ipxe.efi
Shut down the virtual machine and go back to the usual web-interface in your browser.
Put ipxe.efi in the iPXE folder we created.
ipxe.efi

Create a new folder by clicking on Create. Name the folder config (!!!all small letters!!!) and click OK.
Create a new folder in iPXE
Name the folder Config
If not installed yet, in Package Center, install Tekst Editor.
Text Editor
Once installed, open Text Editor.
Click File – New.
Edit the file as shown below and save it in iPXE/Config as boot.ipxe
Edit boot.ipxe

Enable DHCP and PXE on Synology NAS:
Select your LAN-device, click Enable DHCP server.
Enable DHCP Server
Next, click Edit.
DHCP Server details


Fill out the Primary and Secondary DNS. Click on Create.
Primary and Secondary DNS
Fill start and end IP address and as gateway, Netmask is 255.255.255.0 take the IP-address of your router. Address lease time is 3600 seconds. Click Create and click OK.
Now activate the subnet.
Activate the subnet
On tab PXE, Enable PXE and click Select.
Enable PXE
Choose ipxe.efi and click select. Next click Apply.
Choose ipxe.efi
Click Apply
Mounting the ISO files on your NAS:
Go to File Station and navigate tot he iPXE folder we created.
Right click on the ubuntu desktop and ubuntu server ISO files we copied and click Mount Virtual Drive.
Mount Virtual Drive

Make sure to select Mount automatically on startup and click on Mount.
Mount automatically at startup
Now our iPXE folder should look like this:
How iPXE folder should look like

Open Text Editor and edit boot.ipxe.
Our file should look like this:
boot.ipxe before editing
Then, we modify it like this:
boot.ipxe after editing
clearing up boot.ipxe

Set server_ip: IP-address of your NAS.
Set base: IP-address/volume pool/iPXE  192.168.0.185/volume1/iPXE
Make sure set os_name is equal to the folder name in iPXE. We use this to define the nfs-path to download the files we need to install the Operating Systems.
Example nfsroot: nfsroot=192.168.0.1:/volume1/iPXE/ubuntu-22.10-live-server-amd64

Tagged , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *