CentOS and RHEL both supports network installation using the NFS, FTP, or HTTP protocols. A network installation can be started from a boot media or a bootable flash memory drive. Alternatively, if the system to be installed contains a network interface card (NIC) with Pre-Execution Environment (PXE) support, Pre-Execution Environment (PXE) can also be used to install CentOS and RHEL.

How PXE works

The client's NIC with PXE support sends out a broadcast request for DHCP information and the DHCP server provides the client with an IP address, name server information, the hostname or IP address of the tftp server and the location of the installation files on the tftp server.

Following are the main steps required to configure PXE Server.

Change System settings

Change the following information of your system.
Name : server1.example.com
Static ip : 192.168.1.250
subnet : 255.255.255.0
Primary DNS : 192.168.1.250
This can be done easily using system-config-network-tui or system-config-network or system-config-network-gui

Configuring vsftpd for PXE

Setting up vsftpd for basic use require just two steps. Installation of vsftpd rpm and starting the vsftpd service. We also need to chkconfig vsftpd so that vsftpd starts automatically when system reboots.

Step 1:

Check if vsftpd is installed on your system or not. You can check if vsftpd is installed or not as:
rpm -q vsftpd
install vsftpd, if is not installed.
rpm -ivh vsftpd-2.0.5-16.el5_4.1.i386.rpm

Step 2:

Starting vsftpd service as:
service vsftpd start
chkconfig --level 345 vsftpd on

Copying DVD to /var/ftp/pub

/var/ftp/pub directory path is automatically created when we install vsftpd rpm. So, now we need to copy the DVD in /var/ftp/pub/

step 1:

If you are going to configure your PXE server to support more than one OS installation. You should create a separate directory for each OS. I am using CentOS 5.5, so I will make a directory /var/ftp/pub/centos55
mkdir /var/ftp/pub/centos55

step 2:

Now insert the DVD. The media gets mounted in /media/CentOS_5.5_Final/. Copy all the files in the media to /var/ftp/pub/centos55 as
cp -rvf /media/CentOS_5.5_Final/ /var/ftp/pub/centos55/
cp -vf /media/CentOS_5.5_Final/.diskinfo /var/ftp/pub/centos55/
cp -vf /media/CentOS_5.5_Final/.treeinfo /var/ftp/pub/centos55/


If have an iso image of DVD you can follow the following steps:

step 1:

Mount you iso in /var/ftp/pub/centos55/
mount -o loop CentOS-5.5-i386-bin-DVD.iso /var/ftp/pub/centos55/

step 2:

You need to make an entry in /etc/fstab so that on next reboot, this iso mount automatically.
/root/CentOS-5.5-i386-bin-DVD.iso /var/ftp/pub/centos55/ iso9660 defaults,loop 0 0


Configuring tftp for PXE

Step 1:

Check if tftp-server is installed on your system or not. You can check if tftp-server is installed or not as:
rpm -q tftp-server

If not, you need to install tftp, as:
yum install tftp-server

tftp-server is a xinetd dependent, if xinetd is not installed, before can successfully use tftp-server, you need to install xinetd rpm and start xinetd service.This can be done as
yum install xinetd
service xinetd start
chkconfig xineted on

Step 2:

tftp is an xinetd based service, and requires to be started manually as:
chkconfig tftp on


Configuring dhcp server for PXE

DHCP (Dynamic Host Configuration Protocol), is a network protocol for automatically assigning TCP/IP information to client machines, which includes, IP address, gateway, and DNS Server information.

Step 1:

Check if dhcp is installed on your system or not. You can check if dhcp is installed or not as:
rpm -q dhcp
If not, you need to install dhcp, as:
yum install dhcp

Step 2:

By default the dhcpd.conf file is empty. The sample file is present at /usr/share/doc/dhcp<version>/dhcp.conf.sample which can be copied to /etc/ for use. This can be done as:
[root@server1 ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
cp: overwrite `/etc/dhcpd.conf'? y

Step 3:

Configuring /etc/dhcpd.conf :
ddns-update-style interim;
ignore client-updates;

allow booting;
allow bootp;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 192.168.1.250;
filename "linux-install/pxelinux.0";
}

subnet 192.168.1.0 netmask 255.255.255.0 {
get-lease-hostnames on;

# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;

option domain-name "example.com";
option domain-name-servers 192.168.1.250;

option time-offset -18000; # Eastern Standard Time

range dynamic-bootp 192.168.1.10 192.168.1.20;
default-lease-time 21600;
max-lease-time 43200;
}
After dhcpd.conf file is being configured, start dhcpd service and chkconfig it so that it start automatically on next boot.
service dhcpd start
chkconfig dhcpd --level 345 on



Configuring name server - BIND

Step 1:

Now, install bind and bind related utilities as
yum install bind bind-utils bind-chroot caching-nameserver

Step 2:

Now move to /var/named/chroot/etc and copy named.rfc1912.zones as named.conf as
cd /var/named/croot/etc
cp -p named.rfc1912.zones named.conf

Step 3:

now open named.caching-nameserver.conf and copy following lines from named.caching-nameserver.conf to named.conf
options {
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { localhost; };
};

Now modify the above as shown below in /var/named/chroot/etc/named.conf
acl mylan { 192.168.1.0/24; };
options {
listen-on port 53 { 127.0.0.1; 192.168.1.250; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { localhost; mylan; };
};

Step 4:

Also add the below zone entries at the end in /var/named/chroot/etc/named.conf
zone "example.com" IN {
type master;
file "example.com.zone";
allow-update { mylan; };
};

zone "1.168.192.in-addr.arpa" IN {
type master;
file "example.com.reverse";
allow-update { mylan; };
};

Check your named.conf configuration as:
[root@server1 ~]# named-checkconf /var/named/chroot/etc/named.conf

Step 5:

Create a file /var/named/chroot/var/named/example.com.zone with the following contents:
$TTL 86400
@ IN SOA server1.example.com. root.server1.example.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN NS server1.example.com.

server1 IN A 192.168.1.250

station10 IN A 192.168.1.10
station11 IN A 192.168.1.11
station12 IN A 192.168.1.12
station13 IN A 192.168.1.13
station14 IN A 192.168.1.14
station15 IN A 192.168.1.15
station16 IN A 192.168.1.16
station17 IN A 192.168.1.17
station18 IN A 192.168.1.18
station19 IN A 192.168.1.19
station20 IN A 192.168.1.20

Now change the group of example.com.zone to "named"
chgrp named /var/named/chroot/var/named/example.com.zone

Create a file /var/named/chroot/var/named/example.com.reverse with the following contents:
$TTL 86400
@ IN SOA server1.example.com. root.server1.example.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS server1.example.com.

250 IN PTR server1.example.com.
10 IN PTR station10.example.com.
11 IN PTR station11.example.com.
12 IN PTR station12.example.com.
13 IN PTR station13.example.com.
14 IN PTR station14.example.com.
15 IN PTR station15.example.com.
16 IN PTR station16.example.com.
17 IN PTR station17.example.com.
18 IN PTR station18.example.com.
19 IN PTR station19.example.com.
20 IN PTR station20.example.com.

Change the group of example.com.reverse to "named"
chgrp named /var/named/chroot/var/named/example.com.reverse

Now, check your zone file namely example.com.zone and example.com.reverse as:
[root@server1 ~]# named-checkzone example.com /var/named/chroot/var/named/example.com.zone
zone example.com/IN: loaded serial 200808187
OK
[root@server1 ~]# named-checkzone example.com /var/named/chroot/var/named/example.com.reverse
zone example.com/IN: loaded serial 200808188
OK


service named configtest can also be used to check integrity of configuration files.

Step 6:

After configuring named, start named service and chkconfig it so that it start automatically on next boot.
service named start
chkconfig named --level 345 on



Configuring netboot - Attended PXE Installation

The next step is to configure PXE boot configuration, so that tftp-server can serve client requests. This configuration can be done either through GUI tool system-config-netboot or through CLI using pxeos command.

Step 1:

Check if system-config-netboot-cmd is installed on your system or not. You can check if system-config-netboot-cmd is installed or not as:
rpm -q system-config-netboot-cmd
If not, you need to install dhcp, as:
yum install system-config-netboot-cmd
  • system-config-netboot is available if system-config-netboot-<version-number>.noarch.rpm is installed.
  • pxeos and pxeboot commands are available if system-config-netboot-cmd-<version-number>.noarch.rpm is installed.
  • In this post I have mentioned how to use cmd tool to configure PXE boot, so, installation of system-config-netboot-<version-number>.noarch.rpm is not required. Installation of system-config-netboot-cmd-<version-number>.noarch.rpm will serve our purpose.

Step 2:

We need to execute the following command to configure PXE configuration as:
pxeos -a -i "CentOS 5.5" -p FTP -D 0 -s 192.168.1.250 -L /pub/centos55/ CentOS-5.5

Where:
-a
add a new Operating System description

-i <description>
set short description associated with the Operating System.

-p <NFS | HTTP | FTP>
specify protocol used to access the Operating System

-D <1|0>
specify whether the configuration is diskless or not, zero specifies that it is not a diskless configuration

-s <server name or ip adress>
specify the machine containing the Operating System

-L <netlocation>
specify the directory on the sever machine containing the Operating System.

<os-identifier>
Specify the unique Operating System identifier, which is used as the directory name in the /tftpboot/linux-install/directory.

After execution pxeos command, the initrd.img and vmlinuz files required are transferred from /var/ftp/pub/CENTOS55/images/pxeboot/ to /tftpboot/linux-install/<os-identifier>Whereas <os-identifier> in our case <os-identifier> is CentOS-5.5.


Configuring netboot - Unattended PXE installation

If you want your PXE server to provide unattended installation, you need a kickstart file. I have created a kickstart file for CentOS 5.5, so we will create a directory /var/ftp/pub/kickstart and will get centos5.5.cfg from opensourcenuts.com in /var/ftp/pub/kickstart/. if you are using older version of CentOS, you may have to create a new kickstart file.
mkdir /var/ftp/pub/kickstart
cd /var/ftp/pub/kickstart
wget http://opensourcenuts.com/sites/default/files/centos5.5.cfg
Now we need to configure PXE netboot. We can do this by executing the below command:
pxeos -a -i "CentOS 5.5-unattended" -p FTP -D 0 -s 192.168.1.250 \
-K ftp://192.168.1.250/pub/kickstart/centos5.5.cfg \
-L /pub/centos55/ CentOS-5.5-unattended
You can use pxeos -l command to see the list of pxe boot list
# pxeos -l
CentOS-5.5
Description: CentOS 5.5
Protocol: FTP
isDiskless: False
Server: 192.168.1.250
Location: /pub/centos55
isAnonymous: True
User:
Password:
CentOS-5.5-unattended
Description: CentOS 5.5-unattended
Protocol: FTP
isDiskless: False
Server: 192.168.1.250
Location: /pub/centos55
isAnonymous: True
User:
Password:
At this stage our pxe server is ready to server any pxe clients. Now we can install Linux on any machine which supports pxe booting. You need to connect your PXE Server and client though a network cable and on client you need to set first boot device as PXE.
PXE screenshot
The available OS will be displayed as shown above. You will have to press1, 2 or 3 depending upon what you want to select.
pxeos -l command can be used on the PXE Server to see the list of OS configured for PXE installation.
pxeos -d <os-identifier> can be used to delete the OS entry from the list.



此文章由 flyinweb 于 2011-06-01 09:31:14 编辑

本日志由 flyinweb 于 2011-06-01 09:21:15 发表,目前已经被浏览 1086 次,评论 0 次;

作者添加了以下标签: PXEPXE Server

引用通告:http://www.517sou.net/Article/614/Trackback.ashx

评论订阅:http://www.517sou.net/Article/614/Feeds.ashx

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)