Howto Install CentOS PXE server
This tutorial shows how to set up a PXE (short for preboot execution environment). A PXE install server allows your client computers to boot and install a Linux distribution over the network, without the need of burning Linux iso images onto a CD/DVD, boot floppy images, etc. This is handy if your client computers don't have CD or floppy drives, or if you want to set up multiple computers at the same time (e.g. in a large enterprise), or simply because you want to save the money for the CDs/DVDs.
To install network PXE server, you need following components:
1. DHCP Server
2. TFTP Server
3. NFS/FTP/HTTPD server (to store installing files)
Step1 – Install dhcp server
[root@server1 ~]# yum install dhcp
Dhcpd configuration file is located at /etc/dhcpd.conf. You can use /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample as a sample config or you can use my config below as a base, make sure you change the subnet you want to provide dhcp service in your network.
ddns-update-style interim;
not authoritative;
option domain-name "shirwa.net";
option domain-name-servers 208.67.222.222, 208.67.220.220;
option subnet-mask 255.255.255.0;
subnet 172.20.30.0 netmask 255.255.255.0 {
authoritative;
range 172.20.30.10 172.20.30.90;
option routers 172.20.30.254;
allow unknown-clients;
allow booting
allow bootp
next-server 172.20.30.100;
filename "pxelinux.0";
}Step2 - Install tftp-server
[root@server1 ~] # yum install tftp-server
Edit /etc/xinetd.d/tftp and set disable to no.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}Step 3 – Create Network Install source
We can use three method to store installation files on the network and retrieve it when booting the client using pxe. You can use nfs, ftp or http. I have chosing to ftp, to install ftp server:
[root@server1 ~] # yum install vsftpd
Public accessible ftp site is located in /var/ftp. create installation tree in this folder.
[root@server1 ~] # mkdir –p /var/ftp/install/centos/i386/5.2 [root@server1 ~] # mkdir –p /var/ftp/install/debian/i386/4 [root@server1 ~] # mkdir –p /var/ftp/install/ubuntu-desktop/i386/8.10 [root@server1 ~] # mkdir –p /var/ftp/install/ubuntu-server/i386/8.10
If you have download dvd or cd iso files, you can mount it and copy the installation files, to mount an iso file:
[root@server1 ~] # mount –t iso9660 -o loop CentOS-5.2-i386-bin-DVD.iso /mnt/iso
once mounted the iso file copy the installation files to /var/ftp/install/centos/i386/5.2. do this for each linux distribution you want to include in yout pxe server.
[root@server1 ~] # cp –avr /mnt/iso/* /var/ftp/install/centos/i386/5.2
Step 4 Restart dhcpd and tftpd and vsftpd Services
[root@server1 ~] # /etc/init.d/dhcpd restart [root@server1 ~] # /etc/init.d/xinetd restart [root@server1 ~] # /etc/init.d/vsftpd restart
To make sure these services remain running after reboot, run following command:
[root@server1 ~] # chkconfig --level 345 dhcpd on [root@server1 ~] # chkconfig --level 345 vsftpd on
tftpd server is managed by xinetd which is on after reboot by default.
Step 5 – Setup tftp network boot files
Create /tftpboot/images/
1. Copy the /usr/lib/syslinux/pxelinux.0 file installed by the syslinux package into /tftpboot/
[root@server1 tftpboot] # cp /usr/lib/syslinux/pxelinux.0 /tftpboot
2. Create /tftpboot/images/
[root@server1 tftpboot] # mkdir –p images/centos/i386/5.2 [root@server1 tftpboot] # cp /var/ftp/install/centos/i386/5.2/images/pxeboot/vmlinuz images/centos/i386/5.2 [root@server1 tftpboot] # cp /var/ftp/install/centos/i386/5.2/images/pxeboot/initrd images/centos/i386/5.2
Step 6 – Create PXE Menu
Use the following steps to configure PXE menu.
1. Copy menu.c32 file from /usr/lib/syslinux/menu.c32 into /tftpboot
[root@server1 ~] # cp /usr/lib/syslinux/menu.c32 /tftpboot
2. Create /tftpboot/pxelinux.cnf directory
[root@server1 ~] # mkdir /tftpboot/pxelinux.cfg
3. Create /tftpboot/pxelinux.cnf/default configuration file. Following is my default file configuration.
default menu.c32
prompt 0
timeout 300
MENU TITLE PXE Menu
LABEL CentoS 5.2 i386
MENU LABEL CentOS 5.2 i386
KERNEL images/centos/i386/5.2/vmlinuz
append vga=normal initrd=images/centos/i386/5.2/initrd.img ramdisk_size=32768 method=ftp://172.20.30.100/install/centos/i386/5.2
LABEL Debian etch i386
MENU LABEL Debian etch i386
KERNEL images/debian/i386/4/vmlinuz
append vga=normal initrd=images/debian/i386/4/initrd.gz ramdisk_size=32768 method=ftp://172.20.30.100/install/debian/i386/4
LABEL Ubuntu-Server 8.10
MENU LABEL Ubuntu-Server 8.10
KERNEL images/ubuntu-server/i386/8.10/linux
append vga=normal initrd=images/ubuntu-server/i386/8.10/initrd.gz ramdisk_size=32768
LABEL Ubuntu-Desktop 8.10
MENU LABEL Ubuntu-Desktop 8.10
KERNEL images/ubuntu-desktop/i386/8.10/linux
append vga=normal initrd=images/ubuntu-desktop/i386/8.10/initrd.gz ramdisk_size=32768tftp server files structure should look like this:
[root@server1 ~]# tree /tftpboot/ /tftpboot/ |-- images | |-- centos | | `-- i386 | | `-- 5.2 | | |-- initrd.img | | `-- vmlinuz | |-- debian | | `-- i386 | | `-- 4 | | |-- initrd.gz | | `-- vmlinuz | |-- ubuntu-desktop | | `-- i386 | | `-- 8.10 | | |-- initrd.gz | | `-- linux | `-- ubuntu-server | `-- i386 | `-- 8.10 | |-- initrd.gz | `-- linux |-- menu.c32 |-- pxelinux.0 `-- pxelinux.cfg |-- default
FTP files structure should look like this:
[root@server1 ~]# tree -L 3 /var/ftp/install/ /var/ftp/install/ |-- centos | `-- i386 | `-- 5.2 |-- debian | `-- i386 | `-- 4 |-- ks | `-- ks.cfg |-- ubuntu-desktop | `-- i386 | `-- 8.10 `-- ubuntu-server `-- i386 `-- 8.10
Following video demonstrate base centos install using ftp server
Automating CenOS installation using kickstart
1. Install kickstart.
[root@server1 ~] # yum install system-config-kickstart
2. Create kickstart file
Create kickstart file and place it on your installation source ftp site. Following is my kickstart configuration file and i have placed it in ftp://172.20.30.100/install/ks/ks.cfg
#platform=x86, AMD64, or Intel EM64T # System authorization information auth --useshadow --enablemd5 # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Use graphical install graphical # Firewall configuration firewall --enabled --ssh # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard uk # System language lang en_GB # Installation logging level logging --level=info # Use network installation url --url=ftp://172.20.30.100/install/centos/i386/5.2 # Network information network --bootproto=dhcp --device=eth0 --onboot=on #network --bootproto=dhcp --device=eth1 --onboot=on # Reboot after installation reboot #Root password rootpw --iscrypted $1$dfadfaaffafarae1 # SELinux configuration selinux --enforcing # System timezone timezone Europe/London # Install OS instead of upgrade install # X Window System configuration information xconfig --defaultdesktop=GNOME --depth=8 --resolution=800x600 # Disk partitioning information part swap --bytes-per-inode=4096 --fstype="swap" --size=1000 part / --bytes-per-inode=4096 --fstype="ext3" --size=4000 %packages @base
3. Modify /ftpboot/pxelinux.cfg/default
Edit /ftpboot/pxelinux.cfg/default file and add ks parameter.
LABEL CentoS 5.2 i386 MENU LABEL CentOS 5.2 i386 KERNEL images/centos/i386/5.2/vmlinuz append vga=normal initrd=images/centos/i386/5.2/initrd.img ramdisk_size=32768 ks=ftp://172.20.30.100/install/ks/ks.cfg
Following video demonstrate automating CentOS install using kickstart with PXE Server.
14 reponses to "Howto Install CentOS PXE server "
1. hi , thanks for the detailed
hi ,
thanks for the detailed explanation,
i did a mistake i copied ks.cfg file shown above and i used that
can you please tell me the password,,,,,,,
i can redo it but i installed on 4 computers i will take time....
shiva.
2. Hi Shirwa, Ubuntu is also
Hi Shirwa,
Ubuntu is also working now. how to create kickstart file for debian OS . I have tried aptitute and apt-get commands but i couldn't . Is there any alternate way to insatll debian without creating kickstart file.
3. Hi ! I would like to thank
Hi ! I would like to thank first. This guide is good and help me to implement PXE boot for my work place. I have installed RHEL 5 using this guide. But Ubuntu is not worked for me and facing error like
[!] Configuring initrd-kickseed Failed to download kickstart file.
wget: cannot connect to remote host .Network unreachable.
Please give me a assistance to solve this problem.
4. i found it the image is
i found it the image is intrid and the kernel VMLINUZ it was an syntaxe error
5. thank you for SHIRWA but i
thank you for SHIRWA but i still have one more question what is the name of ubuntu's kernel image ?? because o tried to load ubuntu via pxe but it's stop .in this configuration kernel image =vmlinuz but it doesn't work
6. HI Shirwa first of all i’ll
HI Shirwa
first of all i’ll like to say a big thank !!!!!!!!!!!!!!!!! is great !!!! but what i’ll like to know is
is it possible in addition to these lunix version to add a windows OS on the server and boot via the network
7. Hi samba , I’m not sure if
Hi samba ,
I’m not sure if that is possble, i will let you know if i see any howto’s.
8. Hello, Thank you for your
Hello, Thank you for your great tut, however going off your tut I have also implamented ubuntu but I cannot get debian to work, everytime i try it cannot find drivers for anything. If you could please do a walk through or contact me personally that be great.
9. Hi Joel, are you trying to
Hi Joel, are you trying to imprement pxe server on ubuntu or debian? if so i’m trying to write tutorial on how to setup pxe server on ubuntu/debian if time permits.
10. I read your blog in a regular
I read your blog in a regular manner, and I really like your way of writing
Please keep going, smile
your sierra
11. thanks for the awesome
thanks for the awesome tutorial. Any way to modify this to install winxp over the network???
\
12. Hi winnie, this is possible
Hi winnie, this is possible following this quide although i haven’t tested it myself.
13. You've made a typo at: 2.
You've made a typo at:
2. Create /tftpboot/pxelinux.cnf directory
[root@server1 ~] # mkdir /tftpboot/pxelinux.cnf
This must be "pxelinux.cfg", had some hours around this matter ;)
14. Nander Paardekooper, Thanks
Nander Paardekooper, Thanks for the correction.