Installationsserver mit DHCP, PXE, etc.
23. Juni 2009 | Von Ralf Spenneberg | Kategorie: AdminFedora 11 ist erschienen. Dies nutze ich als Gelegenheit, unseren Installationsserver auf der Basis von DHCP, PXE etc. zu erläutern. Dieser Server ist bei uns für die zentrale Bereitstellung sämtlicher Distributionen (Fedora, Opensuse, CentOS, Debian und Ubuntu) zuständig. Nach Auswahl aus einem PXE-Boot-Menü wird automatisch die entsprechende Distribution installiert. Hierzu nutzen wir:
- Kickstart (Fedora, CentOS)
- AutoYast (OpenSuse)
- FAI – Fully Automatic Installer (Debian, Ubuntu)
Installationsquellen:
Zunächst benötigen wir die Installationsquellen. Wir nutzen für den Zugriff auf die Installationsquellen drei verschiedene Methoden: NFS, HTTP und FTP. Die Installationsquellen werden auf einem Debian System zur Verfügung gestellt. Es kann jedoch jedes System eingesetzt werden. Dabei haben wir zunächst den vsftpd-Server installiert. Dieser wurde so konfiguriert, dass sein Anonymous-Root-Verzeichnis in /home/ftp ist. Dieses Verzeichnis wurde auch per NFS freigegeben und der Apache Webserver greift über einen symbolischen Link auf dieses Verzeichnis zu.
Hier muss nun die aktuelle Distribution geladen werden. Dies kann auf unterschiedliche Arten erfolgen. Wir nutzen hier rsync:
rsync -Pa –delete ftp-stud.hs-esslingen.de::fedora/linux/releases/11/Fedora/i386/os/ fc11
Dieser Befehl lädt die aktuelle Distribution einmalig per Rsync in das lokale Verzeichnis fc11. Anschließend müssen natürlich auch noch die Updates geladen werden. Hierzu nutzen wir auch Rsync. Diesmal wird es aber über einen Cron-Job täglich aufgerufen:
rsync -Pa –delete ftp-stud.hs-esslingen.de::fedora/linux/updates/11/i386/ /home/ftp/pub/updates/11/i386/
Puh, es sind schon etwa 2100 Updates!
DHCP-Server:
Als DHCP-Server nutzen wir den ISC-dhcpd. Dieser muss nun für die Installation per PXE dem Client die erforderlichen Informationen liefern. Dazu verwenden wir feste Zuordnungen der MAC-Adressen zu den IP-Adressen, so dass immer jeder Rechner im Schulungsraum dieselbe IP-Adresse erhält:
option domain-name "example.com"; option domain-name-servers 192.168.0.254; option subnet-mask 255.255.255.0; default-lease-time 600; max-lease-time 7200; subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.200 192.168.0.220; option routers 192.168.0.254; filename "/pxelinux.0"; next-server 192.168.0.254; host station1 { hardware ethernet 00:11:11:d0:93:b2; fixed-address 192.168.0.1;} }
Der Client wird nun per PXE gebootet, erhält von dem DHCP-Server eine IP-Adresse und wird den bei next-server angegebenen TFTP-Server kontaktieren und die Datei pxelinux.0 herunterladen. Diese Datei ist Bestandteil des Syslinux-Paketes.
TFTP-Server:
Als TFTP-Server setzen wir den Atftpd-Server ein, der über den Inetd-Daemon auf dem Debian-System gestartet wird:
#:BOOT: TFTP service is provided primarily for booting. Most sites # run this only on machines acting as "boot servers." tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd -v -v -v -v /srv/tftp
In dem Verzeichnis /srv/tftp wird nun die Datei pxelinux.0 aus dem Syslinux-Paket kopiert. Außerdem legen wir dort weitere Verzeichnisse an. In dem Verzeichnis msgs/ hinterlegen wir eine Datei, die als Boot-Menü ausgegeben wird. Das Verzeichnis f11/ wird den Installationskernel für Fedora11 enthalten. Im Verzeichnis pxelinux.cfg/ wird die Konfiguration für pxelinux.0 hinterlegt.
Datei pxelinux.cfg/default:
Diese Datei enthält die Konfiguration für PXELinux. Hier könnten auch für jeden Rechner spezifische Konfigurationsdateien entsprechend der MAC-Adresse hinterlegt werden. Der PXELinux-Client sucht zunächst entsprechend seiner MAC (hier 88:99:AA:BB:CC:DD) und seiner IP-Adresse (hier: 192.0.2.91 -> C000025B) nach Konfigurationsdateien:
/pxelinux.cfg/01-88-99-aa-bb-cc-dd /pxelinux.cfg/C000025B /pxelinux.cfg/C000025 /pxelinux.cfg/C00002 /pxelinux.cfg/C0000 /pxelinux.cfg/C000 /pxelinux.cfg/C00 /pxelinux.cfg/C0 /pxelinux.cfg/C /pxelinux.cfg/default
Wir verwenden für alle Clients die gleiche Datei default:
display /msgs/ost.msg default system prompt 1 timeout 100 label system localboot 0 label f11 kernel /f11/vmlinuz append load_ramdisk=1 initrd=/f11/initrd.img noipv6 network ks=http://server.example.com/kickstart/f11-server.cfg
Datei msgs/ost.msg
Damit bei dem PXE-Boot der Anwender auch weiss, was er installieren kann, gibt es ein kleines Menü (msgs/ost.msg):
^L ^O09Willkommen im ^O0cOpenSource Training^O09 Schulungszentrum!^O07 ^O0a ## ## ## ## ## ## ## ## ## ## ################## ################## ################## ################## ^O07 Geben Sie die Installationsoption ein: system - Bootet das installierte System (default) f[8,9,10,11] - Installiert Fedora 8 bis 10 suse92,10,101,102,103,110,111 - Installiert SuSE Linux 9.2 bis 11.1 etch,lenny - Installiert Debian Etch oder Lenny centos5 - Installiert CentOS 5 unattended - Installiert Windows XP memtest - Memory Test
Die eingestreuten Steuerungscodes erzeugen eine farbige Darstellung.
Verzeichnis f11/
Nun benötigen wir noch den Installationskernel und die initiale Ramdisk für die Installation des Fedora 11. Hierzu legen wird in dem Wurzelverzeichnis des TFTP-Servers das Verzeichnis f11/ an und kopieren aus der Fedora Distribution die folgenden Dateien:
cp images/pxeboot/vmlinuz images/pxeboot/initrd.img /srv/tftp/f11/
Kickstart-Datei
Nun benötigen wir nur noch die angegebene Kickstart-Datei. Diese muss auch über den Webserver unter dem angegebenen Pfad erhältlich sein. Bei uns werden sie auf dem Installationsserver in dem Verzeichnis /kickstart hinterlegt. Der Webserver verfügt über einen symbolischen Link.
install url --url http://server.example.com/pub/fc11 lang de_DE.UTF-8 #langsupport --default=de_DE.UTF-8 en_US.UTF-8 de_DE.UTF-8 keyboard de-latin1-nodeadkeys xconfig --startxonboot --defaultdesktop kde network --bootproto dhcp --noipv6 rootpw --iscrypted $1$P9pSvtoZ$5eI2wRoUyszaiC3VSjeT90 firewall --disabled selinux --permissive authconfig --enableshadow --enablemd5 timezone --utc Europe/Berlin bootloader --location=mbr --append="rhgb quiet" clearpart --all part /boot --fstype "ext3" --size=100 part / --fstype "ext3" --size=4000 part swap --size=1000 part pv.7 --size=100 --grow volgroup VolGroup00 pv.7 logvol /usr --fstype ext3 --name=LogVol02 --vgname=VolGroup00 --size=10016 logvol /tmp --fstype ext3 --name=LogVol03 --vgname=VolGroup00 --size=4000 logvol /home --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=3008 logvol /var --fstype ext3 --name=LogVol01 --vgname=VolGroup00 --size=30000 %packages @ X Window System @ KDE (K Desktop Environment) @ Administration Tools @ Legacy Software Support @ MySQL Database @ Printing Support @ Server Configuration Tools @ System Tools @ Text-based Internet @ Web Server @ Windows File Server @ Development Libraries @ Development Tools @ Editors @ German Support @ Graphical Internet e2fsprogs grub lvm2 #checkpolicy #selinux-policy-strict #selinux-policy-targeted %post useradd student echo "kennwort" | passwd --stdin student cd /etc/yum.repos.d rm -f fedora-core.repo rm -f fedora-updates.repo lftpget ftp://server.example.com/pub/repos/fedora-core.repo lftpget ftp://server.example.com/pub/repos/fedora-updates.repo
Das Post-Installationsskript legt einen weiteren Benutzer student an. Sowohl student als auch root erhalten das Kennwort kennwort. Außerdem lädt es modifzierte Konfigurationsdateien für Yum, die den lokalen Installationsserver nutzen.
Die automatische Installation kann dann sehr schön in den Protokollen verfolgt werden:
Jun 23 13:56:51 localhost dhcpd: DHCPDISCOVER from 00:11:11:d0:93:b2 via eth0 Jun 23 13:56:51 localhost dhcpd: DHCPOFFER on 192.168.0.1 to 00:11:11:d0:93:b2 via eth0 Jun 23 13:56:53 localhost dhcpd: DHCPREQUEST for 192.168.0.1 (192.168.0.254) from 00:11:11:d0:93:b2 via eth0 Jun 23 13:56:53 localhost dhcpd: DHCPACK on 192.168.0.1 to 00:11:11:d0:93:b2 via eth0 Jun 23 13:56:53 localhost in.tftpd[14532]: connect from 192.168.0.1 (192.168.0.1) Jun 23 13:56:53 localhost atftpd[14532]: Advanced Trivial FTP server started (0.7) Jun 23 13:56:53 localhost atftpd[14532]: started by inetd Jun 23 13:56:53 localhost atftpd[14532]: logging level: 9 Jun 23 13:56:53 localhost atftpd[14532]: directory: /srv/tftp/ Jun 23 13:56:53 localhost atftpd[14532]: user: nobody.nogroup Jun 23 13:56:53 localhost atftpd[14532]: log file: syslog Jun 23 13:56:53 localhost atftpd[14532]: server timeout: 300 Jun 23 13:56:53 localhost atftpd[14532]: tftp retry timeout: 5 Jun 23 13:56:53 localhost atftpd[14532]: maximum number of thread: 100 Jun 23 13:56:53 localhost atftpd[14532]: option timeout: enabled Jun 23 13:56:53 localhost atftpd[14532]: option tzise: enabled Jun 23 13:56:53 localhost atftpd[14532]: option blksize: enabled Jun 23 13:56:53 localhost atftpd[14532]: option multicast: enabled Jun 23 13:56:53 localhost atftpd[14532]: address range: 239.255.0.0-255 Jun 23 13:56:53 localhost atftpd[14532]: port range: 1758 Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.0 to 192.168.0.1:2070 Jun 23 13:56:53 localhost atftpd[14532]: tsize option -> 11822 Jun 23 13:56:53 localhost atftpd[14532]: Aborting transfer Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.0 to 192.168.0.1:2071 Jun 23 13:56:53 localhost atftpd[14532]: blksize option -> 1456 Jun 23 13:56:53 localhost atftpd[14532]: End of transfer Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.cfg/01-00-11-11-d0-93-b2 to 192.168.0.1:57089 Jun 23 13:56:53 localhost atftpd[14532]: File /srv/tftp//pxelinux.cfg/01-00-11-11-d0-93-b2 not found Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.cfg/C0A80001 to 192.168.0.1:57090 Jun 23 13:56:53 localhost atftpd[14532]: File /srv/tftp//pxelinux.cfg/C0A80001 not found Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.cfg/C0A8000 to 192.168.0.1:57091 Jun 23 13:56:53 localhost atftpd[14532]: File /srv/tftp//pxelinux.cfg/C0A8000 not found Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 ... gekürzt Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.cfg/C to 192.168.0.1:57097 Jun 23 13:56:53 localhost atftpd[14532]: File /srv/tftp//pxelinux.cfg/C not found Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /pxelinux.cfg/default to 192.168.0.1:57098 Jun 23 13:56:53 localhost atftpd[14532]: tsize option -> 5924 Jun 23 13:56:53 localhost atftpd[14532]: blksize option -> 1440 Jun 23 13:56:53 localhost atftpd[14532]: End of transfer Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving /kbd-de to 192.168.0.1:57099 Jun 23 13:56:53 localhost atftpd[14532]: tsize option -> 256 Jun 23 13:56:53 localhost atftpd[14532]: blksize option -> 1440 Jun 23 13:56:53 localhost atftpd[14532]: End of transfer Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:53 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:53 localhost atftpd[14532]: Serving //msgs/ost.msg to 192.168.0.1:57100 Jun 23 13:56:53 localhost atftpd[14532]: tsize option -> 858 Jun 23 13:56:53 localhost atftpd[14532]: blksize option -> 1440 Jun 23 13:56:53 localhost atftpd[14532]: End of transfer Jun 23 13:56:53 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:57 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:57 localhost atftpd[14532]: Serving //f11/vmlinuz to 192.168.0.1:57101 Jun 23 13:56:57 localhost atftpd[14532]: tsize option -> 3035056 Jun 23 13:56:57 localhost atftpd[14532]: blksize option -> 1440 Jun 23 13:56:58 localhost atftpd[14532]: End of transfer Jun 23 13:56:58 localhost atftpd[14532]: Server thread exiting Jun 23 13:56:58 localhost atftpd[14532]: Creating new socket: 192.168.0.254:1030 Jun 23 13:56:58 localhost atftpd[14532]: Serving //f11/initrd.img to 192.168.0.1:57102 Jun 23 13:56:58 localhost atftpd[14532]: tsize option -> 18985802 Jun 23 13:56:58 localhost atftpd[14532]: blksize option -> 1440 Jun 23 13:57:06 localhost atftpd[14532]: End of transfer Jun 23 13:57:06 localhost atftpd[14532]: Server thread exiting
Die Protokolle auf dem Webserver sehen folgendermaßen aus. Das hier eine andere Client-IP-Adresse protokolliert wird, hängt bei uns damit zusammen, dass die Installationsquellen und der DHCP/TFTP-Server auf unterschiedlichen Systemen installiert sind. Bei dem Zugriff auf die Installationsquellen werden die PXE-Clients bereits genattet. Hier auf die IP 192.168.255.200.
192.168.255.200 - - [23/Jun/2009:13:57:23 +0200] "GET /kickstart/f11-server.cfg HTTP/1.0" 200 1642 "-" "anaconda/11.5.0.59" 192.168.255.200 - - [23/Jun/2009:13:57:23 +0200] "GET /pub/fc11/images/updates.img HTTP/1.0" 404 308 "-" "anaconda/11.5.0.59" 192.168.255.200 - - [23/Jun/2009:13:57:23 +0200] "GET /pub/fc11/images/product.img HTTP/1.0" 404 308 "-" "anaconda/11.5.0.59" 192.168.255.200 - - [23/Jun/2009:13:57:23 +0200] "GET /pub/fc11/images/install.img HTTP/1.0" 200 116039680 "-" "anaconda/11.5.0.59" 192.168.255.200 - - [23/Jun/2009:13:58:41 +0200] "GET /pub/fc11/.treeinfo HTTP/1.1" 200 1437 "-" "urlgrabber/3.0.0" 192.168.255.200 - - [23/Jun/2009:13:58:41 +0200] "GET /pub/fc11/repodata/repomd.xml HTTP/1.1" 200 3450 "-" "Fedora (anaconda)/11" 192.168.255.200 - - [23/Jun/2009:13:58:41 +0200] "GET /pub/fc11/repodata/d8d34dabbba6003a7d8742aa95d5463f8c32cf744830641a5bb016a654b28cdc-primary.sqlite.bz2 HTTP/1.1" 200 1737765 "-" "Fedora (anaconda)/11"