PXE

Der PXE-Server benötigt mindestens TFTP und syslinux, um ein Pre-Boot-Environment zu verteilen. Die ISO-Installationsmedien werden ausgepackt und zur Verteilung auf einen Webserver gelegt (TFTP geht hier nicht).

Achtung

Eine VM, die per PXE installiert wird, benötigt mit CentOS 7 mind. 1.5 GB, mit CentOS 8 mind. 2 RAM - ansonsten erhält man nach dem Laden des Pre-Boot Environments die Fehlermeldungen „/dev/root does not exist“ und „… write erorr: No space left on device“ (womit der Hauptspeicher gemeint ist).

Links

Installation und Konfiguration

Vorhandenen DHCP-Server um Einträge für PXE erweitern - im Beispiel wird auf dem ISC DHCP-Server der zu suchende PXE-Server mit der IP 10.80.32.58 angegeben:

/etc/dhcp/dhcpd.conf
# PXE: Server to request the bootfile from
next-server 10.80.32.58;
filename "pxelinux.0";

syslinux installieren - dieses Paket liefert ein minimales Betriebssystem mit einem Auswahlmenü für PXE:

yum -y install syslinux

Boot-Dateien auf dem TFTP-Server bereitstellen. Ein ln -s funktioniert hier nicht:

ln /usr/share/syslinux/chain.c32 /var/lib/tftpboot
ln /usr/share/syslinux/mboot.c32 /var/lib/tftpboot
ln /usr/share/syslinux/memdisk /var/lib/tftpboot
ln /usr/share/syslinux/menu.c32 /var/lib/tftpboot
ln /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
ln /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot

ISOs zur Verfügung stellen

CentOS

Ein zu verteilendes ISO-File holen und mounten:

mkdir -p /mnt/centos-iso
wget http://mirror.nsc.liu.se/centos-store/7.4.1708/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso -O /tmp/CentOS-7-x86_64-Minimal-1708.iso
mount -o loop /tmp/CentOS-7-x86_64-Minimal-1708.iso /mnt/centos-iso

Boot-Images (hier die BIOS- und nicht die UEFI-Version) aus den ISO-Files holen und an die richtige Stelle legen:

mkdir -p /var/lib/tftpboot/isolinux/CentOS-7-x86_64-Minimal-1708
cp -a /mnt/centos-iso/isolinux/initrd.img /var/lib/tftpboot/isolinux/CentOS-7-x86_64-Minimal-1708/
cp -a /mnt/centos-iso/isolinux/vmlinuz /var/lib/tftpboot/isolinux/CentOS-7-x86_64-Minimal-1708/
restorecon -Fvr /var/lib/tftpboot/

Das ausgepackte ISO in die DocumentRoot eines vorhandenen oder auf dem PXE/Deployment-Server zu installierendem Webserver legen. Wichtig: die versteckte .treeinfo-Datei muss ebenfalls mitkopiert werden.

mkdir -p /var/www/html/iso/CentOS-7-x86_64-Minimal-1708
cp -a /mnt/centos-iso/* /var/www/html/iso/CentOS-7-x86_64-Minimal-1708/
cp /mnt/centos-iso/.discinfo /mnt/centos-iso/.treeinfo /var/www/html/iso/CentOS-7-x86_64-Minimal-1708/
restorecon -Fvr /var/www/html/

Aufräumen:

umount /mnt/centos-iso
rm -f /tmp/CentOS-7-x86_64-Minimal-1708.iso

Ubuntu

Ein zu verteilendes ISO-File holen und mounten:

cd /tmp/
wget https://releases.ubuntu.com/20.10/ubuntu-20.10-live-server-amd64.iso
mkdir -p /mnt/ubuntu-iso
mount -o loop /tmp/ubuntu-20.10-live-server-amd64.iso /mnt/ubuntu-iso/

Boot-Images (hier die BIOS- und nicht die UEFI-Version) aus den ISO-Files holen und an die richtige Stelle legen:

mkdir -p /var/lib/tftpboot/isolinux/ubuntu-20.10-live-server-amd64
cp -a /mnt/ubuntu-iso/casper/vmlinuz /var/lib/tftpboot/isolinux/ubuntu-20.10-live-server-amd64/
cp -a /mnt/ubuntu-iso/casper/initrd /var/lib/tftpboot/isolinux/ubuntu-20.10-live-server-amd64/
restorecon -Fvr /var/lib/tftpboot/

Das ISO in die DocumentRoot eines vorhandenen oder auf dem PXE/Deployment-Server zu installierendem Webserver legen.

mkdir -p /var/www/html/iso/ubuntu-20.10-live-server-amd64
cp -a /tmp/ubuntu-20.10-live-server-amd64.iso /var/www/html/iso/ubuntu-20.10-live-server-amd64/
restorecon -Fvr /var/www/html/

Aufräumen:

umount /mnt/ubuntu-iso
rm -f /tmp/ubuntu-20.10-live-server-amd64.iso

Um das Setup der Maschine zu automatisieren (autoinstall), braucht es eine user-data sowie eine meta-data Datei. Weitere Informationen dazu findet man unter: https://ubuntu.com/server/docs/install/autoinstall-reference

Boot-Menü

Ordner für die Bootmenüs anlegen:

mkdir -p /var/lib/tftpboot/pxelinux.cfg

Boot-Menü erstellen/erweitern. Hier ein Text-basiertes Beispiel mit Untermenüs:

/var/lib/tftpboot/pxelinux.cfg/default
default menu.c32

# starten des Standardeintrages nach 2 Minuten
timeout 1200

# Boot-Prompt ausblenden (0) oder anzeigen (1)
prompt 0

# Öffnen des Boot mit ESC ermöglichen (0) oder Funktion deaktivieren (1)
noescape 0

menu title *** PXE Boot ***

# Definition der einzelnen Booteinträge:
# LABEL      : Eindeutige Bezeichnung ded Booteintrages
# MENU LABEL : Anzeige im Bootmenü
# KERNEL     : das zu bootende Kernel-Image
# APPEND     : Kerneloptionen

LABEL a
    MENU LABEL Boot from local disk
    MENU DEFAULT
    localboot

MENU BEGIN centos
        MENU TITLE Install CentOS 8 x86_64 (automated)
        LABEL Previous
        MENU LABEL ^Previous Menu
        MENU EXIT
        MENU SEPARATOR
        MENU INCLUDE pxelinux.cfg/centos8-automated.menu
MENU END

MENU BEGIN centos
        MENU TITLE Install CentOS 8 x86_64 (manually)
        LABEL Previous
        MENU LABEL ^Previous Menu
        MENU EXIT
        MENU SEPARATOR
        MENU INCLUDE pxelinux.cfg/centos8-manually.menu
MENU END

MENU SEPARATOR

MENU BEGIN centos
        MENU TITLE Install CentOS 7 x86_64 (automated)
        LABEL Previous
        MENU LABEL ^Previous Menu
        MENU EXIT
        MENU SEPARATOR
        MENU INCLUDE pxelinux.cfg/centos7-automated.menu
MENU END

MENU BEGIN centos
        MENU TITLE Install CentOS 7 x86_64 (manually)
        LABEL Previous
        MENU LABEL ^Previous Menu
        MENU EXIT
        MENU SEPARATOR
        MENU INCLUDE pxelinux.cfg/centos7-manually.menu
MENU END

MENU SEPARATOR

MENU BEGIN ubuntu
    MENU TITLE Install Ubuntu (automated)
    LABEL Previous
    MENU LABEL ^Previous Menu
    MENU EXIT
    MENU SEPARATOR
    MENU INCLUDE pxelinux.cfg/ubuntu-automated.menu
MENU END
centos8-automated.menu
LABEL a
    MENU LABEL ^a) CentOS 8.0.1905 DVD
    KERNEL isolinux/CentOS-8-x86_64-1905-dvd1/vmlinuz
    APPEND initrd=isolinux/CentOS-8-x86_64-1905-dvd1/initrd.img inst.repo=http://10.80.32.58/iso/CentOS-8-x86_64-1905-dvd1 inst.ks=http://10.80.32.58/iso/centos8.ks

LABEL b
    MENU LABEL ^b) CentOS 8.1.1911 DVD
    KERNEL isolinux/CentOS-8.1.1911-x86_64-dvd1/vmlinuz
    APPEND initrd=isolinux/CentOS-8.1.1911-x86_64-dvd1/initrd.img inst.repo=http://10.80.32.58/iso/CentOS-8.1.1911-x86_64-dvd1 inst.ks=http://10.80.32.58/iso/centos8.ks

LABEL c
    MENU LABEL ^c) CentOS 8.2.2004 Minimal
    KERNEL isolinux/CentOS-8.2.2004-x86_64-minimal/vmlinuz
    APPEND initrd=isolinux/CentOS-8.2.2004-x86_64-minimal/initrd.img inst.repo=http://10.80.32.58/iso/CentOS-8.2.2004-x86_64-minimal inst.ks=http://10.80.32.58/iso/centos8.ks
centos8-manually.menu
LABEL a
    MENU LABEL ^a) CentOS 8.0.1905 DVD
    KERNEL isolinux/CentOS-8-x86_64-1905-dvd1/vmlinuz
    APPEND initrd=isolinux/CentOS-8-x86_64-1905-dvd1/initrd.img inst.repo=http://10.80.32.58/iso/CentOS-8-x86_64-1905-dvd1

LABEL b
    MENU LABEL ^b) CentOS 8.1.1911 DVD
    KERNEL isolinux/CentOS-8.1.1911-x86_64-dvd1/vmlinuz
    APPEND initrd=isolinux/CentOS-8.1.1911-x86_64-dvd1/initrd.img inst.repo=http://10.80.32.58/iso/CentOS-8.1.1911-x86_64-dvd1

LABEL c
    MENU LABEL ^c) CentOS 8.2.2004 Minimal
    KERNEL isolinux/CentOS-8.2.2004-x86_64-minimal/vmlinuz
    APPEND initrd=isolinux/CentOS-8.2.2004-x86_64-minimal/initrd.img inst.repo=http://10.80.32.58/iso/CentOS-8.2.2004-x86_64-minimal
ubuntu20-automated.menu
LABEL a
    MENU LABEL ^a) Ubuntu Desktop 20.10
    KERNEL isolinux/Ubuntu-20-10-Live-Server-amd64/vmlinuz
    INITRD isolinux/Ubuntu-20-10-Live-Server-amd64/initrd
    APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=http://10.80.32.58/iso/ubuntu-20.04.1-live-server-amd64/ubuntu-20.04.1-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://10.80.32.58/iso/ubuntu-20.04.1-live-server-amd64/

usw.

Built on 2024-04-18