Installing Linux over Network: PXE, DHCP, TFTP, NFS and Kickstart Revision History: 07/05/02 V1.0 Initial version. 1. Summary This memo documents the procedure to automatically install Linux from a centralized server to a fresh node (the client) over the network, without using a floppy drive or CD-ROM on the client node. 2. Hardware environment: The client node uses a Biostar M7VKQ mainborad with a built-in Ethernet adapter using RTL8139 chipset, an AMD Athlon XP 1800+ CPU and a Maxtor 81.9G hard drive. The Ethernet adapter supports Intel UNDI PXE 2.0. The server uses the same hardware configuration as the client with an additional CD-ROM for the initial installation of software on the server. However, the procedure documented here does not depend on the server's particular hardware configuration. 3. Software environment: Software: RedHat 7.2 distribution of Linux 2.4.7-10. 4. Configure the client: * Record the client's MAC address from the BIOS reading. In our case, it is 00:E0:4C:7B:67:8D. * Set the boot sequence in the BIOS to be in this order: LAN, HDD-0, Floppy, and CD-ROM. 5. Server configuration: 5.1 Network The server has an IP of "10.0.1.1". The client is to be assigned an IP of "10.0.1.2" via DHCP. 5.2 Export the RH7.2 distribution via NFS * Copy the Red Hat Linux 7.2 distribution on hard disk: Make a directory "/export/cdrom", and copy the distribution tree from the 2 RH7.2 CD-ROMs to there. [yudong@test1 cdrom]$ pwd /export/cdrom [yudong@test1 cdrom]$ ls autorun ks.cfg README.it RELEASE-NOTES.de RELEASE-NOTES.ko boot.cat README README.ja RELEASE-NOTES.es RPM-GPG-KEY COPYING README.de README.ko RELEASE-NOTES.fr TRANS.TBL dosutils README.es RedHat RELEASE-NOTES.it images README.fr RELEASE-NOTES RELEASE-NOTES.ja * Configure Kickstart for the client Make the "ks.cfg" file (using "ksconfig", for example), and put it in "/export/cdrom": [yudong@test1 RedHat]$ cat /export/cdrom/ks.cfg #Generated by Kickstart Configurator lang en_US langsupport en_US keyboard us mouse generic3ps/2 timezone --utc America/New_York rootpw --iscrypted $1$ÙoÉãêskí$qC2bX.xkwCJVM.CR6rdDn/ bootloader --useLilo --linear --location=mbr install nfs --server 10.0.1.1 --dir /export/cdrom clearpart --all --initlabel part / --fstype ext3 --size 1024 part /tmp --fstype ext3 --size 4096 part /usr --fstype ext3 --size 1024 part /var --fstype ext3 --size 1024 part /home --fstype ext3 --size 1024 part /data --fstype ext3 --size 4096 --grow network --bootproto dhcp auth --useshadow --enablemd5 firewall --disabled xconfig --depth 16 --resolution 640x480 --defaultdesktop=GNOME --card "Trident Blade3D (generic)" --videoram 8192 --monitor "Compaq V710 Color Monitor" %packages @Classic X Window System @X Window System @GNOME @Network Support [yudong@test1 RedHat]$ Note: for the "/data" partition, do not allocate too big a space for it. Instead, give it a few gigabytes and let it grow. A big allocation will cause an error in the client installation process: "Can not allocation partition". * Set up NFS to export the distribution: -- set up /etc/exports file: [yudong@test1 log]$ cat /etc/exports # /export/cdrom 10.0.0.0/255.0.0.0(ro) -- start NFS server: [root@test1 init.d]# service nfs status rpc.mountd is stopped nfsd is stopped rpc.rquotad is stopped [root@test1 init.d]# /etc/rc.d/init.d/nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS mountd: [ OK ] Starting NFS daemon: [ OK ] [root@test1 init.d]# service nfs status rpc.mountd (pid 2526) is running... nfsd (pid 2540 2539 2538 2537 2536 2535 2534 2531) is running... rpc.rquotad (pid 2521) is running... [root@test1 init.d]# showmount -e Export list for test1: /export/cdrom 10.0.0.0/255.0.0.0 [root@test1 init.d]# 5.3 Set up tftp server and download PXELINUX: * making directories: /tftpboot/ and /tftpboot/pxelinux.cfg/ * Put kernel images there: [root@test1 pxeboot]$ cp /export/cdrom/images/pxeboot/initrd.img /tftpboot/ [root@test1 pxeboot]$ cp /export/cdrom/images/pxeboot/vmlinuz /tftpboot/ * Download and configure SYSLINUX [yudong@test1 test]$ wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-1.75.tar.gz After unpacking the SYSLINUX package, copy "pxelinux.0", which is the PXE bootloader, to "/tftpboot/". Get the following files in /tftpboot/pxelinux.cfg: [yudong@test1 pxelinux.cfg]$ ls -la /tftpboot/pxelinux.cfg total 20 -rw-r--r-- 1 root root 41 Jun 21 15:10 default -rw-r--r-- 1 root root 194 Jun 24 10:40 default.netks-7.2 lrwxrwxrwx 1 root root 17 Jul 5 12:17 0A000102 -> default.netks-7.2 where "0A000102" corresponds to the client's IP address "10.0.1.2". [yudong@test1 pxelinux.cfg]$ cat /tftpboot/pxelinux.cfg/default default linux label linux localboot 0 [yudong@test1 pxelinux.cfg]$ cat /tftpboot/pxelinux.cfg/default.netks-7.2 default linux serial 0,9600n8 label linux kernel vmlinuz append ksdevice=eth0 console=ttyS0,38400 console=tty0 load_ramdisk=1 initrd=initrd.img network ks=nfs:10.0.1.1:/export/cdrom/ks.cfg where the first file instructs PXElinux to perform local boot, while the second file tells the client to boot from the network following the kickstart config file. PXELINUX will first look for the configuration file "0A000102", in which case it will start kickstart installation as instructed by the "ks.cfg" file. If a "0A*" file does not exist, it will read the "default" file, in which case it will boot from local media. Thus once the kickstart installation on the client finishes, the "0A000102" needs to be removed from the server so the client can boot from its local harddisk. Otherwise the client will start the kickstart installation again after it reboots from the network. * Set up and start tfptp server: [yudong@test1 xinetd.d]$ rpm -qa |grep tftp tftp-server-0.17-14 [yudong@test1 xinetd.d]$ ls /etc/xinetd.d chargen daytime-udp finger rlogin talk time chargen-udp echo ntalk rsh telnet time-udp daytime echo-udp rexec sgi_fam tftp [yudong@test1 xinetd.d]$ cat /etc/xinetd.d/tftp # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot -l disable = no } [yudong@test1 xinetd.d]$ [root@test1 xinetd.d]$ /etc/rc.d/init.d/xinetd restart 5.4 Set up DHCP server * Set up DHCPD configuration file, which, in this case, gives the only client "A2" an IP 10.0.1.2, and directs the client to the tftp server to get boot loader "pxelinux.0": [yudong@test1 yudong]$ cat /etc/dhcpd.conf deny unknown-clients; not authoritative; option domain-name "gsfc.nasa.gov"; #option domain-name-servers 10.0.1.1, 10.0.0.1; option subnet-mask 255.0.0.0; option broadcast-address 10.255.255.255; allow bootp; allow booting; subnet 10.0.0.0 netmask 255.0.0.0 { option routers 10.0.0.1; } group { next-server 10.0.1.1; filename "pxelinux.0"; host A2 { hardware ethernet 00:E0:4C:7B:67:8D; fixed-address 10.0.1.2; } } * Start DHCP server: Make sure "/var/lib/dhcp/dhcpd.leases" exists. [root@test1 yudong]$ /etc/rc.d/init.d/dhcpd start If the server has more than 1 network interface, it is desirable that the server listens only on one interface. To do this, edit /etc/sysconfig/dhcpd, assign the interface name to the variable "DHCPDARGS". 6. Client installation Make sure the client is connected to the server via the network. Power on the client, and the installation will automatically start. After the installation finishes, before reboot the client, remove the "/tftpboot/pxelinux.cfg/0A000102" file on the server so the client will boot from the local hard disk thereafter. Following is part of the syslog during the process: Jul 5 13:11:44 test1 dhcpd: DHCPDISCOVER from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:44 test1 dhcpd: DHCPOFFER on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:46 test1 dhcpd: DHCPREQUEST for 10.0.1.2 from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:46 test1 dhcpd: DHCPACK on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 17:11:46 test1 in.tftpd[2038]: tftp: client does not accept options Jul 5 13:11:55 test1 dhcpd: DHCPDISCOVER from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:55 test1 dhcpd: DHCPOFFER on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:55 test1 dhcpd: DHCPDISCOVER from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:55 test1 dhcpd: DHCPOFFER on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:55 test1 dhcpd: DHCPREQUEST for 10.0.1.2 from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:55 test1 dhcpd: DHCPACK on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 rpc.mountd: authenticated mount request from 10.0.1.2:612 f or /export/cdrom (/export/cdrom) Jul 5 13:11:56 test1 dhcpd: DHCPDISCOVER from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 dhcpd: DHCPOFFER on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 dhcpd: DHCPDISCOVER from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 dhcpd: DHCPOFFER on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 dhcpd: DHCPREQUEST for 10.0.1.2 from 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 dhcpd: DHCPACK on 10.0.1.2 to 00:e0:4c:7b:67:8d via eth0 Jul 5 13:11:56 test1 rpc.mountd: authenticated mount request from 10.0.1.2:616 f or /export/cdrom (/export/cdrom) 6. References http://www.stanford.edu/~alfw/PXE-Kickstart/PXE-Kickstart.html http://syslinux.zytor.com/