Skip to content

Instantly share code, notes, and snippets.

@clemenko
Last active April 17, 2024 14:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemenko/8df23cb764b326defcb4624b58ab4da2 to your computer and use it in GitHub Desktop.
Save clemenko/8df23cb764b326defcb4624b58ab4da2 to your computer and use it in GitHub Desktop.
iPXE Netboot.xyz with Docker

iPXE with Netboot.xyz

Leverage Docker and Netboot.xyz to host Harvester/Rocky/Liberty installers and kickstart. We have been developing an Harvester Workshop and needed a better way to boot dozens of machines. Netboot.xyz was a simple way to do it. We used https://hub.docker.com/r/linuxserver/netbootxyz to simplify the install.

Then we created a custom menu and loaded the assets. After updating the DHCP settings on the network to point to the machine we are able to boot anything.

Netboot Docker docs : https://netboot.xyz/docs/docker

Deploy Netboot with Docker

  • install docker
  • create directories mkdir /opt/netboot/{config,assets}
  • deploy with docker compose -f docker_compose.yaml up -d
  • Add menu.ipxe to /opt/netboot/config/menus/menu.ipxe from below.
  • Add assets to /opt/netboot/assets/ directory, aka unpack ISOs to directory.

update dhcpd

Set the DHCPD next-server with netboot.xyz.kpxe or netboot.xyz.efi for uefi.

look at attached files

Take a look at the tree output below. I truncated to show the important files.

Video

https://youtu.be/BGDiaouqSSg

timezone America/New_York --utc
text
%addon com_redhat_kdump --disable
%end
rootpw --iscrypted --allow-ssh $6$VmlNLErACH.u627t$YM8zJROIhS4CxoR7Z6BVQsLcpM3mhoBUqcYLg.jIiwLXdxqRo0C2d7ATe7ltNVxw8WRW5FE5BPV3d1Nf8I4aa.
network --bootproto=dhcp --device=eth0 --noipv6 --activate
keyboard --xlayouts='us'
lang en_US.UTF-8
url --url="http://192.168.1.220/liberty/BaseOS"
repo --name="AppStream" --baseurl="http://192.168.1.220/liberty/AppStream"
%packages
@^server-product-environment
%end
firstboot --disabled
ignoredisk --only-use=vda
bootloader --location=mbr --timeout=1
zerombr
clearpart --all --initlabel
autopart --type=plain --fstype=xfs --nohome
%packages
@^minimal-environment
sudo
qemu-guest-agent
openssh-server
-alsa*
-microcode_ctl
-iwl*firmware
-dracut-config-rescue
-plymouth
%end
reboot
services:
netbootxyz:
image: lscr.io/linuxserver/netbootxyz
container_name: netbootxyz
environment:
- PUID=1000
- PGID=1000
- TZ=America/NewYork
volumes:
- /opt/netboot/config:/config
- /opt/netboot/assets:/assets
ports:
- 3000:3000
- 69:69/udp
- 80:80
restart: unless-stopped
#!ipxe
:global_vars
# set location of custom netboot.xyz live http assets
set live_endpoint http://192.168.1.220
:main_menu
clear menu
menu ipxe All The Things
item --gap Default:
item local ${space} Boot from local
item --gap Distributions:
item harvester ${space} Harvester Installer 1.3.0
item rocky ${space} Rocky - Graphical
item rocky_ks ${space} Rocky Basic KickStart
item liberty ${space} Liberty - Graphical
item liberty_ks ${space} Liberty Basic KickStart
choose --default ${menu} menu
echo ${cls}
goto ${menu} ||
:rocky
imgfree
kernel ${live_endpoint}/rocky/images/pxeboot/vmlinuz inst.repo=${live_endpoint}/rocky inst.graphical ip=dhcp ipv6.disable inst.geoloc=0 devfs=nomount initrd=initrd.magic
initrd ${live_endpoint}/rocky/images/pxeboot/initrd.img
boot
:rocky_ks
imgfree
kernel ${live_endpoint}/rocky/images/pxeboot/vmlinuz inst.repo=${live_endpoint}/rocky inst.ks=http://192.168.1.220/rocky/basic_ks.yaml ip=dhcp ipv6.disable inst.geoloc=0 devfs=nomount initrd=initrd.magic
initrd ${live_endpoint}/rocky/images/pxeboot/initrd.img
boot
:harvester
kernel ${live_endpoint}/harvester/harvester-v1.3.0-vmlinuz-amd64 ip=dhcp net.ifnames=1 console=tty1 rd.cos.disable root=live:${live_endpoint}/harvester/harvester-v1.3.0-rootfs-amd64.squashfs rd.noverifyssl harvester.install.iso_url=${live_endpoint}/harvester/harvester-v1.3.0-amd64.iso harvester.install.skipchecks=true install.harvester.longhorn.default_settings.guaranteedReplicaManagerCPU=2 install.harvester.longhorn.default_settings.guaranteedEngineManagerCPU=2
initrd ${live_endpoint}/harvester/harvester-v1.3.0-initrd-amd64
boot
:liberty
imgfree
kernel ${live_endpoint}/liberty/images/pxeboot/vmlinuz inst.repo=${live_endpoint}/liberty inst.graphical ip=dhcp ipv6.disable inst.geoloc=0 devfs=nomount initrd=initrd.magic
initrd ${live_endpoint}/liberty/images/pxeboot/initrd.img
boot
:liberty_ks
imgfree
kernel ${live_endpoint}/liberty/images/pxeboot/vmlinuz inst.repo=${live_endpoint}/liberty inst.ks=http://192.168.1.220/liberty/basic_ks.yaml ip=dhcp ipv6.disable inst.geoloc=0 devfs=nomount initrd=initrd.magic
initrd ${live_endpoint}/liberty/images/pxeboot/initrd.img
boot
:local
echo Booting from local disks ...
exit 1

use rocky native

mkdir /opt/netboot
yum install tftp-server nginx -y
sed -i 's#/var/lib/tftpboot#/opt/netboot#g' /usr/lib/systemd/system/tftp.service
sed -i -e '0,/\/usr\/share\/nginx\/html;/{s//\/opt\/netboot;\n        location \/ { autoindex on; autoindex_exact_size off; }/}' -e '/sendfile/s/on/off/' /etc/nginx/nginx.conf
systemctl daemon-reload
systemctl enable tftp nginx --now

Then copy the following to /opt/netboot along with OS specific files.

[root@ipxe netboot]# tree -L 1
.
├── harvester
├── liberty
├── menu.ipxe
├── netboot.xyz-undionly.kpxe
├── netboot.xyz.efi
├── netboot.xyz.kpxe
└── rocky
[root@netboot netboot]# tree -L 3
.
├── assets
│   ├── harvester
│   │   ├── harvester-v1.3.0-amd64.iso
│   │   ├── harvester-v1.3.0-initrd-amd64
│   │   ├── harvester-v1.3.0-rootfs-amd64.squashfs
│   │   └── harvester-v1.3.0-vmlinuz-amd64
│   ├── liberty
│   │   ├── AppStream
│   │   ├── BaseOS
│   │   ├── EFI
│   │   ├── EULA
│   │   ├── RPM-GPG-KEY-SUSE_Liberty_Linux
│   │   ├── RPM-GPG-KEY-SUSE_Liberty_Linux_v3
│   │   ├── basic_ks.yaml
│   │   ├── extra_files.json
│   │   ├── images
│   │   ├── isolinux
│   │   └── media.repo
│   └── rocky
│   ├── AppStream
│   ├── BaseOS
│   ├── EFI
│   ├── LICENSE
│   ├── images
│   ├── isolinux
│   └── media.repo
├── config
│   ├── endpoints.yml
│   ├── log
│   │   └── nginx
│   ├── menus
│   │   ├── menu.ipxe
│   │   ├── netboot.xyz-undionly.kpxe
│   │   ├── netboot.xyz.efi
│   │   ├── netboot.xyz.kpxe
│   ├── menuversion.txt
│   └── nginx
│   ├── nginx.conf
│   └── site-confs
└── docker_compose.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment