shirwablog.com

  • home
  • about
  • Categories

Categories

  • Apache (0)
  • Backup (0)
  • Cisco (1)
  • DNS (0)
  • GNU/Linux (2)
    • CentOs (1)
    • Debian GNU/Linux (0)
    • Ubuntu (1)
  • Nginx (0)
  • PXE Server (1)
  • Virtualisation (1)
  • Windows (0)

Syndicate

Syndicate content
Powered by Drupal, an open source content management system
Home

Howto Install CentOS PXE server

  • View
  • What links here
Printer-friendly versionPrinter-friendly versionSend to friendSend to friendPDF versionPDF version

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/
directory and populate it with the files necessary to start the installation program via PXE.

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/
directory tree and copy vmlinuz and inetrd files which are in the first cd/dvd or install-souce (/images/pxeboot/vmlinuz and /images/pxeboot/initrd).

[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=32768

tftp 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

<!--[if !IE]>--> <!--<![endif]-->

The Camtasia Studio video content presented here requires a more recent version of the Adobe Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

<!--[if !IE]>-->

<!--<![endif]-->

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.

Your rating: None Average: 4 (4 votes)
  • Add new comment
Tags:
  • CentOs
  • GNU/Linux
  • PXE Server

14 reponses to "Howto Install CentOS PXE server "

1. hi , thanks for the detailed

Submitted by Anonymous (not verified) on Fri, 01/29/2010 - 21:22.

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.

  • reply

2. Hi Shirwa, Ubuntu is also

Submitted by Murugesh (not verified) on Fri, 12/11/2009 - 12:23.

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.

  • reply

3. Hi ! I would like to thank

Submitted by Murugesh (not verified) on Fri, 12/11/2009 - 12:22.

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.

  • reply

4. i found it the image is

Submitted by Samba KOITA (not verified) on Fri, 12/11/2009 - 12:21.

i found it the image is intrid and the kernel VMLINUZ it was an syntaxe error

  • reply

5. thank you for SHIRWA but i

Submitted by Samba KOITA (not verified) on Fri, 12/11/2009 - 12:20.

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

  • reply

6. HI Shirwa first of all i’ll

Submitted by Samba KOITA (not verified) on Fri, 12/11/2009 - 12:17.

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

  • reply

7. Hi samba , I’m not sure if

Submitted by shirwa on Fri, 12/11/2009 - 12:18.

Hi samba ,

I’m not sure if that is possble, i will let you know if i see any howto’s.

  • reply

8. Hello, Thank you for your

Submitted by Joel (not verified) on Fri, 12/11/2009 - 12:16.

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.

  • reply

9. Hi Joel, are you trying to

Submitted by shirwa on Fri, 12/11/2009 - 12:16.

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.

  • reply

10. I read your blog in a regular

Submitted by Sierra Skye (not verified) on Fri, 12/11/2009 - 12:15.

I read your blog in a regular manner, and I really like your way of writing
Please keep going, smile
your sierra

  • reply

11. thanks for the awesome

Submitted by winnie poohh (not verified) on Fri, 12/11/2009 - 12:11.

thanks for the awesome tutorial. Any way to modify this to install winxp over the network???
\

  • reply

12. Hi winnie, this is possible

Submitted by shirwa on Fri, 12/11/2009 - 12:12.

Hi winnie, this is possible following this quide although i haven’t tested it myself.

  • reply

13. You've made a typo at: 2.

Submitted by Nander Paardekooper (not verified) on Fri, 12/11/2009 - 12:04.

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 ;)

  • reply

14. Nander Paardekooper, Thanks

Submitted by shirwa on Fri, 12/11/2009 - 12:07.

Nander Paardekooper, Thanks for the correction.

  • reply