boot from pxe
1 Server with DHCP, TFTPBOOT and HTTPD First we need a server with dhcpd, ftpd and httpd installed and configured correctly. It has not to be the same box, but you need at least access to the configuration files. Please note: I'll explain how to setup the dhcp and tftp server, but I assume you have a http daemon running. Following installation examples are for a CentOS 5 server which will be used as installation server, but it works with nearly any other distributions too. 2 Installing up dhcpd
yum install dhcpIf you are using Debian there should be a package like dhcp or dhcp-server (try: apt-cache search dhcp|grep server). 3 Setting up dhcpd Example of dhcpd.conf (/etc/dhcpd.conf):
ddns-update-style ad-hoc; option subnet-mask 255.255.255.0; option domain-name-servers 192.168.0.1; subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.200 192.168.0.210; option broadcast-address 192.168.0.255; option routers 192.168.0.1; next-server 192.168.0.1; filename "pxelinux.0"; max-lease-time 100; default-lease-time 100; }This assumes to have following configuration:
IP Network (subnet-mask / subnet .... netmask )192.168.0.0/24DNS Server (domain-name-servers )192.168.0.1DHCP IP Range (range )192.168.0.200-210Broadcast (option broadcast-address )192.168.0.255Gateway (option routers )192.168.0.1tftboot Server (next-server )192.168.0.1 (will be setup later)4 Installing the TFTP Daemon
yum install tftp-serverThe equivalent Debian package should be tftpd , but I think the configuration will be different. 5 Configuring the TFTP Daemon The TFTP Daemon will be launched via xinetd and can be enabled/disabled in /etc/xinetd.d/tftp. Example of /etc/xinetd.d/tftp
service tftp { disable = no socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot -vv per_source = 11 cps = 100 2 only_from = 192.168.0.0 192.168.1.0 flags = IPv4 }This starts the tftp server with extra verbose options and only allows connections from the networks 192.168.0.0/24 and 192.168.0.1/24. The output will be stored in /var/log/messages. 6 Get the files The boot loader: pxelinux.0 This file is part of the package syslinux and will be in /usr/lib/syslinux.
yum install syslinux cp /usr/lib/syslinux/pxelinux.0 /tftpbootIt should be the same for debian (apt-get install syslinux). If not, here you are: pxelinux.0.gz (don't forget to gunzip it). 7 /tftpboot/pxeboot.msg The content of pxeboot.msg is shown when your server boots via PXE. This file can contain any text you like. Example /tftpboot/pxeboot.msg:
** Welcome to my wonderful automatic installation ** Following commands are available: Boot from local hard disk ------------------------- Command: local CentOS5 (auto and manual installation) ------- Command: installauto-centos5 Command: install-centos5 Debian 4 Etch (auto and manual installation) ------------- Command: installauto-debian4 Command: install-debian4 Rescue Boot ----------- Command: rescue Memtest86 ------- Command: memtest8 Create default config You need to create a default config file which will be loaded by the clients. There you define the above listed commands you'd like to have. It has to be stored in /tftpboot/pxelinux.cfg and named default. Example: /tftpboot/pxelinux.cfg/default
# This command will be executed automatically after the below set timeout default local # Always prompt prompt 1 # Display the bootup message display pxeboot.msg # If you like playing around, check out this :-) # Display some extra stuff when pressing the F-keys (.msg files has to exist) #F1 help.msg #F2 bla.msg #F3 xxx.msg #... and so on # Boot automatically after x seconds in tenths of a second timeout 30 # COMMANDS # Boot local machine without doing something label local localboot 0 # CentOS 5 Auto-Installation label installauto-centos5 kernel centos5/vmlinuz append ksdevice=eth0 load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=16384 / initrd=centos5/initrd.img network ks=http://192.168.0.1/centos5_ks.cfg # CentOS 5 Manual Installation label install-centos5 kernel centos5/vmlinuz append ksdevice=eth0 load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=16384 / initrd=centos5/initrd.img network # Debian 4 Auto-Installation label installauto-debian4 kernel debian4/linux append initrd=debian4/initrd.gz preseed/url=http://192.168.0.1/deb4_preseed.cfg / debconf/priority=critical root=/dev/rd/0 ramdisk_size=10392 devfs=mount,dall rw / locale=de_DE interface=eth0 # Debian 4 Manual Installation label install-debian4 kernel debian4/linux append initrd=debian4/initrd.gz root=/dev/rd/0 devfs=mount,dall rw ramdisk_size=10392 # Rescue Image label rescue kernel rescue/vmlinuz append initrd=rescue/rescue.cpi root=/dev/ram0 init=/linuxrc ramdisk_size=54000 / CONF="`/dev/fd0:/rescue`;;;;;;;;;;;" # Memtest86 label memtest kernel memtest/memtestPlease adjust the IP of your webserver (in this case 192.168.0.1) and make sure that it is accessable directly with the IP. I've noted that Debian doesn't work properly when entering a Domain Name instead of the IP. You can also create an individual config file for each server, therefore you need the mac address of your server. The file then has to be called 01-XX-XX-XX-XX-XX-XX > in the same directory. 9 Start services Now we have to start up everything:
service dhcpd restart service xinted restartThis must work without any errors.
Now we are ready to start the installation. So boot up your server, enable booting over network (PXE) and enter installauto-centos5 or installauto-debian4 when requested to start the installation.
It really wasted a lot of time finding a rescue image which does following:
boot via PXElate linux kernelboot up with networkboot with SSHinclude mandatory toolsAnd here it is: PLD Rescue CD It's created by Arkadiusz Patyk and works great. Here is what you have to do:
cd /tmp # Download latest version, today (2007-10-12) it's 2.90 wget http://rescuecd.pld-linux.org/download/2007-06-17/x86/RCDx86_290.iso # Mount it mkdir /mnt/rescue mount RCDx86_290.iso /mnt/rescue -o loop # Copy all files to tftp directory mkdir /tftpboot/rescue cp /mnt/rescue/rescue.cpi /tftpboot/rescue cp /mnt/rescue/boot/isolinux/vmlinuz /tftpboot/rescue # Unmount umount /mnt/rescue rmdir /mnt/rescueWhen you boot your server with this image you have to know following:
Server gets IP via DHCPDefault root password is 'pld'When the PLD Rescue Image detects your hard disk you can mount and (if you like) chroot into it. The great thing is you don't need direct access to your box. Just edit the default boot command in /tftpboot/pxelinux.cfg/default to 'rescue' and your server will boot up the rescue image. But don't forget to change it back to 'local' :)
This is a simple thing. You just need to download the memtest binary and extract it to /tftpboot/memtest/memtest. Today the latest version is 1.70
mkdir /tftpboot/memtest cd /tftpboot/memtest wget "http://memtest.org/download/1.70/memtest86+-1.70.bin.gz" mv "memtest86+-1.70.bin" memtestAfter these steps you should be able to start memtest directly via PXE.
See http://syslinux.zytor.com/
At certain times of the year I might be attempting to install dozens of machines for our cluster. Inserting a CD is fine for one, not for twenty. Of more interest, though, is that I want a variety of things to boot. I want a Debian Stable ISO to boot. Most importantly, I want to boot Dell diagnostics.
This process usings something called PXE. It requires your machine's BIOS to make a request of a TFTP server for a bootable image (the equivalent of inserting a CD and booting). Most modern higher-end machines can do this - and particularly all Dell PowerEdge machines, which is what I support. I use a Debian distribution, so what follows is debianish. Whatever you have will almost certainly have something similar. You should also check out the SARA package of utilities at https://subtrac.sara.nl/oss/pxeconfig .
Install a tftp server. I chose atftpd and did the following: apt-get install atftpd # Set up atftpd (do not use inetd, since it hardly ever gets used) touch /var/log/atftp.log # Enable logging vi /etc/default/atftpd USE_INETD=false # verbose=7 --trace will trace every packet OPTIONS="--daemon --verbose --tftpd-timeout 10 --retry-timeout 5 / --mcast-port 1758 --mcast-addr 192.168.0.0-65535 --mcast-ttl 10 / --maxthread 10 --verbose=5 --logfile=/var/log/atftp.log /tftpboot" update-inetd --disable tftp /etc/init.d/atftpd restart Install syslinux and set up a TFTP boot server. DHCP can do this for you. Here's what I did: apt-get install syslinux mkdir -p /tftpboot/boot tftpboot/pxelinux.cfg chmod 777 /tftpboot # Copy files from syslinux distribution to /tftpboot cp -p /usr/lib/syslinux/pxelinux.0 /tftpboot cp -p /usr/lib/syslinux/menu.c32 /tftpboot cp -p /usr/lib/syslinux/memdisk /tftpboot/boot Configure dhcp so it allows a TFTP boot to happen. I won't provide the all DHCP details, but for this step all you need do is add some lines like this to your dhcp.conf file. Yes, the pxelinux.0 file you see below is the same one from the previous step. allow booting; allow bootp; filename "/tftpboot/pxelinux.0"; next-server 192.168.1.5; Make default menus for pxelinux. Note that executables to be run (kernel keyword) cannot have special chars. Keep these names v-e-r-y simple. The menu.c32 is a small program to generate a menu so you can select what to do. Here's what I have right now: cat /tftpboot/pxelinux.cfg/default DEFAULT menu.c32 PROMPT 0 MENU TITLE CSG PXE Boot Menu TIMEOUT 100 # First one is default unless 'DEFAULT name' specified LABEL delldiags MENU LABEL Dell Diagnostics (EW5091A1 DOS mode) kernel boot/memdisk append initrd=boot/delldiag.img LABEL installi386 MENU LABEL Install Debian Etch I386 over Network kernel boot/debian/i386/linux append vga=normal initrd=boot/debian/i386/initrd.gz -- Get memtest from http://www.memtest.org . Download the file labelled Download - Pre-Compiled package for Floppy (DOS - Win) and then do: cd /tmp # or some directory for temporary files unzip memtest86+-1.70.floppy.zip cp -p floppy/memtestp.bin /tftpboot/boot/memtestp rm -rf /tmp/floppy Get the Debian network installer (or your favorite). The process for this is described in: http://www.debian.org/releases/stable/i386/ch04s06.html.en , http://www.debian.org/releases/stable/i386/ch04s02.html.en#where-files , and http://ftp.debian.org/debian/dists/etch/main/installer-i386/current//images/netboot/ . Fetch netboot.tar.gz and extract it in a safe place: mkdir -p /tftpboot/boot/debian/i386 cd where-netboot-extracted cp -p debian-installer/i386/linux /tftpboot/boot/debian/i386 cp -p debian-installer/i386/initrd.gz /tftpboot/boot/debian/i386 # Edit /tftpboot/pxelinux.cfg/default and add an entry from pxelinux.cfg/default as necessary. Get Dell diagnostics from http://support.dell.com/ . Select Drivers and Downloads Select product by model , service tag or whatever. PowerEdge works fine, others apparently do notAt page Drivers and Downloads Search Criteria , select Operating System as MS-DOS Select DiagnosticsDownload the 2MB imageExtract on a Windows system. What! Of course, remember it's called a MONOPOLY. Fine, visit one of your poor friends who are stuck on a Windows machine. Copy the 2MB file to the Windows machine, then execute it. This program copies files to a directory and invokes an application which will create Floppy boot images, USB boot image or a 'Bootable Image'Select Bootable Image and save the *.img fileCopy the *.img file back to your Linux and do cp -p diags.img /tftpboot/boot/delldiag.img Edit /tftpboot/pxelinux.cfg/default and add an entry for Dell diagnostics as necessaryYou should now be able to boot a machine on your DHCP network and choose to boot from the network. On Dell machines this is F12 labelled 'PXE Boot'. If all went well, you should get a menu showing you several things defined in /tftpboot/pxelinux.cfg/default and allow you to boot from these.
I must tell you, it's a real joy to PXE boot and run diagnostics so easily. Good job, Dell .
下面是dhcp服务器的配制文件ddns-update-style interim; ignore client-updates; allow booting; allow bootp; option ip-forwarding false; subnet 192.168.0.0 netmask 255.255.255.0 { # --- default gateway option routers 192.168.0.1; option subnet-mask 255.255.255.0; option nis-domain "domain.org"; option domain-name "domain.org"; option domain-name-servers 202.115.144.33; option time-offset -18000; # Eastern Standard Time # option ntp-servers 192.168.1.1; # option netbios-name-servers 192.168.1.1; # --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well # option netbios-node-type 2; range dynamic-bootp 192.168.0.128 192.168.0.254; default-lease-time 21600; max-lease-time 43200; filename "pxelinux.0"; next-server 192.168.0.1; }
