Linux Installation Using (i)PXE

I’ve recently embarked on learning about how to deploy Linux based Operating Systems over a network using (i)PXE. Some of it came easy. Some of it was hard. And some of it. I could use some help with.

My #!ipxe script is as follows.

#!ipxe

set url    http://10.0.0.15/
set initrd ${url}initrd/
set iso    ${url}iso/
set kernel ${url}kernel/
set ucode  ${url}ucode/

:MENU
menu
item exit                 Exit iPXE and continue BIOS boot
item --gap -- --------------- iPXE Install Menu ---------------
item arch                 Arch Linux 5.18.7
item bodhi                Bodhi 6.0.0
item centos               CentOS 7
item elementaryos         ElementaryOS 6.1
item fedora-s             Fedora 36 Server
item fedora-w             Fedora 36 Workstation
item kubuntu              Kubuntu 22.04 LTS
item lubuntu              Lubuntu 22.04 LTS
item manjaro              Manjaro 21.3.2
item mint                 Linux Mint 20.3
item popos                PopOS 22.04 LTS
item rocky                Rocky 9.0
item ubuntu-d             Ubuntu Desktop 22.04 LTS
item ubuntu-s             Ubuntu Server  20.04 LTS
item xubuntu              Xubuntu 22.04 LTS
item --gap -- -------------------------------------------------
choose target && goto ${target}

:arch
kernel ${kernel}arch/5.18.7/vmlinuz-linux
initrd ${ucode}arch/5.18.7/amd-ucode.img
initrd ${ucode}arch/5.18.7/intel-ucode.img
initrd ${initrd}arch/5.18.7/initramfs-linux.img
imgargs vmlinuz-linux initrd=amd-ucode.img initrd=intel-ucode.img initrd=initramfs-linux.img archiso_http_srv=${iso}archlinux-2022.07.01-x86_64/ ip=dhcp
boot

:bodhi
kernel ${kernel}bodhi/6.0.0/vmlinuz boot=casper ip=dhcp url=${iso}bodhi-6.0.0-64.iso initrd=initrd.gz
initrd ${initrd}bodhi/6.0.0/initrd.gz
boot

:centos
kernel ${kernel}centos/7/vmlinuz root=live:${iso}CentOS-7-x86_64-Minimal-2009.iso initrd=initrd.img
initrd ${initrd}centos/7/initrd.img
boot

:elementaryos
kernel ${kernel}elementaryos/6.1/vmlinuz boot=casper ip=dhcp url=${iso}elementaryos-6.1-stable.20211218-rc.iso initrd=initrd.lz
initrd ${initrd}elementaryos/6.1/initrd.lz
boot

:fedora-s
kernel ${kernel}fedora-s/36/vmlinuz inst.repo=${iso}Fedora-Server-dvd-x86_64-36-1.5 initrd=initrd.img
initrd ${initrd}fedora-s/36/initrd.img
boot

:fedora-w
kernel ${kernel}fedora-w/36/vmlinuz ip=dhcp root=live:${iso}Fedora-Workstation-Live-x86_64-36.iso rd.live.image initrd=initrd.img
initrd ${initrd}fedora-w/36/initrd.img
boot

:kubuntu
kernel ${kernel}kubuntu/22.04/vmlinuz ip=dhcp url=${iso}kubuntu-22.04-desktop-amd64.iso initrd=initrd
initrd ${initrd}kubuntu/22.04/initrd
boot

:lubuntu
kernel ${kernel}lubuntu/22.04/vmlinuz ip=dhcp url=${iso}lubuntu-22.04-desktop-amd64.iso initrd=initrd
initrd ${initrd}lubuntu/22.04/initrd
boot

:manjaro
kernel ${kernel}manjaro/21.3.2/vmlinuz-x86_64
initrd ${ucode}manjaro/21.3.2/amd_ucode.img
initrd ${ucode}manjaro/21.3.2/intel_ucode.img
initrd ${initrd}manjaro/21.3.2/initramfs-x86_64.img
imgargs vmlinuz-x86_64 initrd=amd_ucode.img initrd=intel_ucode.img initrd=initramfs-x86_64.img miso_http_srv=${iso}manjaro-kde-21.3.2-220704-linux515/ ip=dhcp
boot

:mint
kernel ${kernel}mint/20.3/vmlinuz ip=dhcp url=${iso}linuxmint-20.3-cinnamon-64bit.iso initrd=initrd.lz
initrd ${initrd}mint/20.3/initrd.lz
boot

:popos
kernel ${kernel}popos/22.04/vmlinuz.efi boot=casper ip=dhcp url=${iso}pop-os_22.04_amd64_intel_10.iso initrd=initrd.gz
initrd ${initrd}popos/22.04/initrd.gz
boot

:rocky
kernel ${kernel}rocky/9.0/vmlinuz inst.repo=${iso}Rocky-9.0-x86_64-minimal initrd=initrd.img
initrd ${initrd}rocky/9.0/initrd.img
boot

:ubuntu-d
kernel ${kernel}ubuntu-d/22.04/vmlinuz ip=dhcp url=${iso}ubuntu-22.04-desktop-amd64.iso initrd=initrd
initrd ${initrd}ubuntu-d/22.04/initrd
boot

:ubuntu-s
kernel ${kernel}ubuntu-s/20.04.3/vmlinuz ip=dhcp url=${iso}ubuntu-20.04.3-live-server-amd64.iso initrd=initrd
initrd ${initrd}ubuntu-s/20.04.3/initrd
boot

:xubuntu
kernel ${kernel}xubuntu/22.04/vmlinuz ip=dhcp url=${iso}xubuntu-22.04-desktop-amd64.iso initrd=initrd
initrd ${initrd}xubuntu/22.04/initrd
boot

:exit
exit

They work. Every one of them.


The problem I’m having right now is every Debian based distro I have is derrived from Ubuntu and uses something called “casper” for netboot which was by far the easiest to configure.

However, any Debian distro that doesn’t rely on casper I have been searching and searching, and Googling, asking people questions and
I have only come up with incomplete solutions that don’t integrate well into the existing script.

Affected OS’s I’ve tried include Debian, PeppermintOS, ParrotOS, VyOS, and Kali Linux. I have no idea how to netboot these operating systems. The only vague solutions I see are netinstall .ISO’s that rely on Internet and public repo’s to download packages. I really want to host it locally but I can’t find any easy solutions anywhere.

All input is appreciated.

2 Likes

Various “netinstall” media can be pointed at any source of packages, such as for example a directory on a regular iso mount point

@Windows7ge I would like to learn how to deploy Linux-based Operating systems over a network using (I)PXE. I was wondering if there were books or websites you found helpful in understanding this subject matter?

1 Like

I’ve been trying that actually with no success. In the case of debian-11.4.0-amd64-netinst.iso I haven’t figured out how to point the kernel to either a .ISO file or directory consisting of decompressed .ISO contents on a HTTP server.

If I take this for example:

:debian
kernel ${kernel}debian/11.4.0/vmlinuz initrd=initrd.gz
initrd ${initrd}debian/11.4.0/initrd.gz
boot

This starts a Debian installation menu immediately. Unlike Linux distros like CentOS or Fedora it’s menu doesn’t show me any way of mounting a network hosted repo. It wants a local media CD which I don’t have nor want to use.

Screenshot from 2022-07-20 10-00-07

No combination of kernel arguments in my other scripts seem to sway the behavior. I can’t get the kernel to notice the full .ISO or open file directory on the HTTP/FTP server.

The problem with knowing and learning how to set this up is that it requires several separate components and no one website tells you how to configure all of them.

  1. You have to know how to install a Linux Server.
  2. You have to know how to install Apache2.4 and DNSMASQ or ISC_DHCP_SERVER
  3. You have to know how to write an embeded PXE script.
  4. You have to know how to compile iPXE from source code.
  5. You have to know how to use SSH & SFTP.
  6. You have to be familiar with FTP & HTTP.
  7. You have to write the back-end script that composes the screenshot in the original post.
  8. You have to know what .ISO files are and how to open them.
  9. You have to know what a kernel is. Where to find it. And how to extract it.
  10. You have to know what initrd is. Where to find it. And how to extract it.
  11. You have to understand navigating file directories and how to tell a script what path to follow to a file.
  12. You have to understand script kernel arguments.

Then, and only then, can you boot from the network, chainlload iPXE, get to this menu, pick your OS, watch the kernel do it’s thing before promptly Kernel Panicking because you forgot a “/” somewhere. :confused:

I plan on writing a beginning to end tutorial on how to setup this entire server because I had to go to several dozen websites. Often just for a single line or two of executable code to act as a band-aid. Talk to people on several forums, and do an absolute crap-ton of trial & error guess work. I’m somewhere around 90-odd hours into this project and I only have 15 verified OS’s working but I know the current compatibility list is much greater.

I intend to post the finished tutorial on another forum but if there’s interest for it I’m willing to post it here as well if there’s a tutorial sub-forum. I don’t spend that much time here.

2 Likes

There’s that “Execute shell” option (near bottom of your screenshot) that lets you do whatever-you-want as a once off, but there’s also this more official way of customizing the Debian installer:

https://www.debian.org/releases/etch/i386/ch04s07.html.en
https://www.debian.org/releases/etch/i386/apb.html.en
https://www.debian.org/releases/etch/i386/apbs02.html.en#preseed-dhcp
https://www.debian.org/releases/etch/i386/apbs04.html.en#preseed-mirror
https://www.debian.org/releases/etch/i386/apbs05.html.en#preseed-hooks

I will have to invest time later into this. I understand that almost anything can be accomplished from shell but the goal of what I’m doing here is to have the script run everything needed to get to the installer ready to install. If that’s not possible with Debian then I’ll have to investigate the available options independently.

There’s a 1000 different Linux distros. I’ll have to start a compatibility list.

Before deciding the distribution is at fault, I would try and dig a little deeper … from your config files it looks like you are not booting the proper kernel to start with … the output you show does not look like the netboot install, that should ask you to chosse from which mirror you want to install …
Can you try booting with the netinstall kernel?
You probably will need to create a full local dedian mirror to make it work though …

Oh I don’t doubt it could be something simple that I’m missing. It’s been that way with nearly every distro I currently have working. I’ve just put in a large amount of time, done a lot of Googling, asked for help on the Debian forum (no response yet) and have tried to make sense of any Debian documentation I can understand. Nothing’s working. If someone knows something I just haven’t figured out yet I’m open to all suggestions/advice.

I was experimenting with both the netboot & full DVD .ISO versions of Debian 11.4.0. I can’t recall what one is in use right now since I didn’t label them. :stuck_out_tongue:

I’ve just gone ahead and extracted vmlinuz & initrd.gz specifically from the netinst.iso version /install.amd (not zen or gtk) and moved them to the necessary directories for my config.

The setup displayed was identical to the before-mentioned kernel/initrd.gz. No options about downloading from mirrors appeared.

I’ll try zen & gtk as they both have their own kernel and initrd.gz files but I’m not getting my hopes up at this point.

Let’s try and get some initial things sorted out …
The kernel you find in the NetInst Iso will not work when booted from pxe as it still expects local media to be available:

Network install from a minimal CD
A network install or netinst CD is a single CD which enables you to install the entire operating system. This single CD contains just the minimal amount of software to install the base system and fetch the remaining packages over the Internet.

What's better for me — the minimal bootable CD-ROM or the full CDs? It depends, but we think that in many cases the minimal CD image is better — above all, you only download the packages that you selected for installation on your machine, which saves both time and bandwidth. On the other hand, the full CDs are more suitable when installing on more than one machine, or on machines without a free Internet connection.

What types of network connections are supported during installation? The network install assumes that you have a connection to the Internet. Various different ways are supported for this, like analogue PPP dial-up, Ethernet, WLAN (with some restrictions), but ISDN is not — sorry!


What you want to use when booting from pxe is the netboot specific kernel as described here:
https://wiki.debian.org/PXEBootInstall#Provide_the_boot_image

So, you need to download the netboot.tar.gz file from a a mirror and get the initrd and vmlinuz files from there. Given you’ve already set up your pxe infrastructure you shouldn’t need anything else, but just in case refer to that page for pointers …

https://deb.debian.org/debian/dists/bullseye/main/installer-amd64/current/images/netboot/netboot.tar.gz

[email protected] ~ % tar tvzf Downloads/netboot.tar.gz| grep -e "initrd\|amd64/linux"
-rw-r--r--  0 root   root 29964202 Jul  5 17:57 ./debian-installer/amd64/initrd.gz
-rw-r--r--  0 root   root  6844288 Jul  5 17:57 ./debian-installer/amd64/linux

Well, you were completely correct that I was using the wrong kernel. Would have been nice if Debian made it easier to locate and perform.

As you eluded to though the next problem is the installer doesn’t like me trying to use a local server for installation. It’s insisting on public repos. Says it failed to download a file from the mirror no matter which way I type the server IP or directory to the installation files.

Amen

You should look into the http server log and see what files it expects where, I am afraid creating a (minimal) local mirror will be the quickest way to go about it … but the amd64 size is650GB … I think your best bet will be to set up aptcacherng, choose an internet mirror during the install and then setting up your local server as proxy … the first time it will pull packages from internet, then you’ll be able to replicate as needed:

1 Like

Have you ever heard of KDE Neon? KDE Neon uses Ubuntu as its base. It also uses Casper, so it should be easy to add to your script. I have included a link to the organization if you want to check it out. https://neon.kde.org/

Because of the intended purpose of why I’m making this, building a repo proxy server would be well outside the scope of the project. So I’m just going to make a compromise so I can include the OS.

item debian               Debian 11.4.0 (Requires Internet)

Now if I could just find answers to other Debian distros that don’t use casper… I was hoping a solution for Debian itself could be applied to other Debian based distros but that ended up not being the case. Back to Google I suppose.

I want to say it’s a spin-off of Kubuntu but I see Google says fairly otherwise:

The primary difference between the two operating systems is that Kubuntu maintains stable releases and LTS version of Ubuntu while KDE neon focuses on updating developer editions of KDE applications without maintaining stable releases of Ubuntu unless the root user actively chooses to upgrade their systems.

So KDE Neon is actually treated quite differently. It isn’t just a different desktop. I’ll definitely add it to the list. :slight_smile:

I’d like to add some more server distros but haven’t gotten around to it yet.

Google is always your friend, you may find inspiration by looking at this:

1 Like

@Shadowbane Maybe this will be of some use to you. It’s more of a rough draft than anything else but should still take you a step in the right direction.