Changes RSS

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== Debian-based PXE boot setup ====== In this document, and the related documents in the guides:pxe namespace, I will document my PXE boot-server setup. It is my intention to have quite a few "features" in my setup, including: * Menu-based selection of boot options * Booting of installers for several open-source operating systems * Booting of Live-environments for several open-source OS. * A selection of system-tools, like disk-shredder, partitioning tools, disk-backup and antivirus * Support for chainloading other net-boot mechanisms. The setup is based on pxelinux, a part of the syslinux tools. In general, PXE-booting will be useful for booting x86/ia32-related hardware. ===== Prerequisites ===== Naturally, a boot-server requires some components apart from configuration files and such. Noteable components: * An operating system for the boot server. I am using Debian 5 "Lenny" as my server-platform * A TFTP daemon. From recommendations of other Debian users, I am switching to atftpd. * A DHCP server. As this setup is done for my home-network, this role is filled by my OpenBSD box. * An NFS server. I am using the same box for tftpd and nfs, and I am running nfs-kernel-server. ===== Installing the tftp dæmon ===== My choice of tftpd-dæmon fell on atftpd. This is a modern TFTP server using multi-threading, supports multicast tftp, option extension, large file-sizes and more. Particularly important for PXE is the support for the [[http://tools.ietf.org/html/rfc2349|RFC2349]] Transfer Size option. Installing atftpd is basically as simple as: <code> apt-get install atftpd </code> It may be noted that as a dependency, atftpd pulls in "inetutils-inetd". As this is done on a Debian system, the package maintainers of atftpd has placed the tftpboot (aka tftp root) directory according to Debian standard at /var/lib/tftpboot. If you are using a different platform, it is highly probable that atftpd will be referring to /tftpboot instead. On the other hand, if you are using Debian, and want /tftpboot in stead of /var/lib/tftpboot, either symlink, or edit /etc/default/atftpd to relocate. ===== Adding TFTP/bootpd settings to DHCP server ===== Note that this is from my OpenBSD DHCP server. These settings however should be directly compatible with the DHCPd in most common Linux distributions, and at least ISC DHCPd. <code> subnet 10.0.3.0 netmask 255.255.255.0 { option domain-name-servers 10.0.2.2; option routers 10.0.3.1; option tftp-server-name "10.0.2.13"; next-server 10.0.2.13; filename "pxelinux.0"; range 10.0.3.130 10.0.3.250; } </code> ===== Installing syslinux to get the pxelinux files... ===== PXELinux, the PXE Boot environment used in my, and most other linux-oriented, net-boot-setups, is not a stand-alone package, but part of the larger [[http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project|syslinux]] project. To install, pull in the following packages: <code> apt-get install syslinux syslinux-common </code> The files we need to continue will be living in /usr/lib/syslinux. For starters, we will want to have a basic set of syslinux modules/files available. We will be adding on modules as features are added to the setup. * pxelinux.0 is the actual PXE environment/loader * menu.c32 allows us the creation of text-based menus * chain.c32 allows us to have "Boot from hard drive" as a boot option. These files are to be copied from /usr/lib/syslinux to /var/lib/tftpboot. We also need the directory where pxelinux configurations will be stored. <code> cp /usr/lib/syslinux/{pxelinux.0,menu.c32,chain.c32} /var/lib/tftpboot mkdir /var/lib/tftpboot/pxelinux.cfg chmod a+rx /var/lib/tftpboot/pxelinux.cfg </code> ===== Setting up a test ===== Our first test will be to see if our PXE environment works at all. To do this, we'll set up a "welcome message", a chainload of the first local harddrive and a faux linux boot. <code> cat > /var/lib/tftpboot/boot.txt <<END This is a PXELinux bootserver. To boot linux, type 'linux<enter>' To boot from local drive, press <enter> END cat > /var/lib/tftpboot/pxelinux.cfg/default <<END DISPLAY boot.txt DEFAULT boot_hd0 LABEL boot_hd0 COM32 chain.c32 APPEND hd0 LABEL linux kernel debian/lenny/i386/linux append vga=normal initrd=debian/lenny/i386/initrd.gz -- PROMPT 1 TIMEOUT 120 END </code> So, no menu yet, just a real simple test. Using any PXE-capable client computer, test this setup. You should be presented with quite a bit of pxelinux output, followed but the contents of boot.txt and a prompt. Trying to boot the 'linux' LABEL should naturally fail, but still confirms that things are working. Booting the default option 'boot_hd0' should boot your system normally (assuming the first BIOS drive is your boot device). ===== First 'real-world' boot setup ===== Now, we will introduce the simples PXE-bootable installer, the Debian netinstall, and a menu to select it. We start by fetching the netboot-kit for Lenny: <code> mkdir /tmp/pxetmp; cd /tmp/pxetmp wget ftp://ftp.uio.no/debian/dists/lenny/main/installer-i386/20090123lenny6/images/netboot/netboot.tar.gz tar zxvf netboot.tar.gz mkdir -p /var/lib/tftpboot/debian/i386/lenny cp /tmp/pxetmp/debian-installer/i386/initrd.gz var/lib/tftpboot/debian/lenny/i386 cp /tmp/pxetmp/debian-installer/i386/linux /var/lib/tftpboot/debian/lenny/i386 </code> Now, we change /var/lib/tftpboot/pxelinux.cfg/default a little bit to start using menus. Replace the contents: <code> DEFAULT menu.c32 MENU TITLE PXE Boot menu 0.1 LABEL linux MENU LABEL Debian Lenny i386 netinstall KERNEL debian/lenny/i386/linux APPEND vga=normal initrd=debian/lenny/i386/initrd.gz -- LABEL boot_hd0 MENU LABEL Boot from first hard drive MENU DEFAULT COM32 chain.c32 APPEND hd0 PROMPT 0 MENU WIDTH 80 MENU MARGIN 10 MENU ROWS 12 MENU TABMSGROW 18 MENU CMDLINEROW 12 MENU ENDROW 24 MENU TIMEOUTROW 20 ONTIMEOUT boot_hd0 TIMEOUT 200 </code> ===== Getting fancy ===== The setup will now introduce quite a few components: * "Graphical" menu using vesamenu.c32 * A fancy background image * Common menu-config with color and layout settings for vesamenu.c32 * Nested/chained menus. We will set the basic framework using the two working options we already have in our menu to introduce the concept. After this, all elements of the sub-menus are simply variations on the basic setup we make here, and all specifics for each menu/os/installer/tool will be presented on separate pages. ==== Preparing vesamenu.c32 ==== <code> cp /usr/lib/syslinux/vesamenu.c32 /var/lib/tftpboot </code> ==== Background image ==== {{:guides:pxemenu-background.png|background.png}} ==== Common configuration ==== <code> # /var/lib/tftpboot/menus/common.cfg DEFAULT vesamenu.c32 MENU BACKGROUND menus/background.png ALLOWOPTIONS 1 PROMPT 0 MENU WIDTH 77 MENU ROWS 14 MENU TABMSGROW 25 MENU CMDLINEROW 25 MENU HELPMSGROW 23 MENU MARGIN 15 MENU VSHIFT 4 MENU COLOR BORDER 30;44 #00000000 #00000000 none MENU COLOR SEL 7;37;40 #ffffffff #9090a0f0 std MENU COLOR HOTSEL 7;37;40 #ffffffff #204040f0 std MENU COLOR TIMEOUT_MSG 37;40 #aaaaaaaa #00000000 std MENU COLOR TIMEOUT 1;37;40 #ffaaaaff #00000000 std MENU SEPARATOR </code> ==== Nested menus ====