RHEL-5   DHCP+TFTP+NFS+KICKSTART PXE無人職守安裝

By:Crushlinux

發揚開源精神,普及 linux 教育 - 1 -

作者:Crushlinux

時間:2010-08-02

E-mail:[email protected]

Blog:http://crushlinux.blog.51cto.com

------------------------------------------------------

RHEL5下

DHCP+TFTP+NFS+KICKSTART

PXE無人職守安裝

PXE原理圖:

實現原理:

1.1說明:

PXE Client:表示需要安裝操作系統的機器,統稱客戶端。

TFTP Server:表示安裝TFTPD服務的機器。

DHCP Server:表示安裝DHCPD服務的機器。

在實際的操作中往往將TFTP Server,DHCP Server部署在一臺機器上,統稱服務端

1.2流程:

(1)客戶端向服務端上的DHCP發送請求IP地址消息,DHCP檢查客戶端是否合法(主要檢測客戶端的網卡地址),如果合法則返回客戶端的IP地址,同時將啓動文件pxelinux.0的位置信息一併傳送給客戶端發送pxelinux.0。

By:Crushlinux

發揚開源精神,普及 linux 教育 - 2 -

(2)客戶端向服務器上的TFTP發送獲取pxelinux.0消息,TFTP接受到消息之後再向客戶端發送pxelinux.0大小信息,試探客戶端是否滿意。當TFTP收到客戶端返回的同意大小信息之後,正式向客戶端發送pxelinux.0。

(3)客戶端運行接收到的pxelinux.0文件

(4) 客戶端向TFTP發送針對本機的配置文件信息(記錄在TFTP上的pxelinux.cfg目錄下),

TFTP將配置文件發給客戶端,客戶端根據配置文件執行後續操作。

(5)客戶端向TFTP發送請求Linux內核信息,TFTP接受到消息之後將內核發送給客戶端

(6)客戶端向TFTP發送跟文件請求,TFTP接受到消息之後返回Linux根文件系統

(7)客戶端啓動Linux內核

(8)客戶端進入自動安裝模式

1.3 適用環境

(1)機器無光驅或者光驅損壞,需要網絡安裝Linux操作系統

(2)由於人品問題到時系統經常癱瘓,需要隔三差五裝系統

(3)需要大規模批量部署Linux操作系統(應用於企業)

環境部署:

服務端IP:192.168.200.104

[root@crushlinux4 ~]# service iptables stop

[root@crushlinux4 ~]# setenforce 0

[root@crushlinux4 ~]# mount /dev/cdrom /mnt/

[root@crushlinux4 ~]# vi /etc/yum.repos.d/yum.repo

[base]

name=base

baseurl=file:///mnt/Server

enable=1

gpgcheck=0

[root@crushlinux4 ~]# rpm -qa |grep tftp

tftp-server-0.49-2

[root@crushlinux4 ~]# rpm -qa |grep dhcp

dhcpv6-client-1.0.10-18.el5

dhcp-3.0.5-23.el5

[root@crushlinux4 ~]# rpm -qa |grep nfs

nfs-utils-lib-1.0.8-7.6.el5

nfs-utils-1.0.9-44.el5

[root@crushlinux4 ~]# rpm -qa |grep portmap

portmap-4.0-65.2.2.1

[root@crushlinux4 /]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf

[root@crushlinux4 ~]# vi /etc/dhcpd.conf ddns-update-style interim;

By:Crushlinux

發揚開源精神,普及 linux 教育 - 3 -

ignore client-updates;

subnet 192.168.200.0 netmask 255.255.255.0 {

option routers 192.168.200.1; option subnet-mask 255.255.255.0;

option time-offset -18000; # Eastern Standard Time

range dynamic-bootp 192.168.200.128 192.168.200.254; default-lease-time 21600; max-lease-time 43200; filename "pxelinux.0"; next-server 192.168.200.104; }

[root@crushlinux4 ~]# service dhcpd start

[root@crushlinux4 ~]# cd /tftpboot/

[root@crushlinux4 tftpboot]# cp /mnt/isolinux/* ./

[root@crushlinux4 tftpboot]# mkdir pxelinux.cfg

[root@crushlinux4 tftpboot]# mv isolinux.cfg pxelinux.cfg/default

[root@crushlinux4 tftpboot]# cp /usr/lib/syslinux/pxelinux.0 ./

[root@crushlinux4 tftpboot]# vi /etc/xinetd.d/tftp

修改文件第14行:將disable = yes 更改成no disable = no

[root@crushlinux4 tftpboot]# service xinetd restart

[root@crushlinux4 tftpboot]# vi /tftpboot/pxelinux.cfg/default

修改文件第3,12行: timeout 10 append ks=nfs:192.168.200.104:/pub/ks.cfg initrd=initrd.img

[root@crushlinux4 tftpboot]# yum -y install *kickstart*

[root@crushlinux4 ~]# system-config-kickstart

By:Crushlinux

發揚開源精神,普及 linux 教育 - 4 -

By:Crushlinux

發揚開源精神,普及 linux 教育 - 5 -

By:Crushlinux

發揚開源精神,普及 linux 教育 - 6 -

By:Crushlinux

發揚開源精神,普及 linux 教育 - 7 -

By:Crushlinux

發揚開源精神,普及 linux 教育 - 8 -

[root@crushlinux4 ~]# mkdir /pub

[root@crushlinux4 ~]# mv /root/ks.cfg /pub/

[root@crushlinux4 ~]# chmod 757 /pub/ks.cfg

[root@crushlinux4 ~]# vi /pub/ks.cfg

By:Crushlinux

發揚開源精神,普及 linux 教育 - 9 -

查看第6,10行內容沒有請手動添加

key --skip 跳過安裝序列號,需要手動修改添加

clearpart --all --initlabel 初始化所有分區(裸機安裝最好添加此行)

ks.cfg腳本內容: #platform=x86, AMD64, 或 Intel EM64T # System authorization information auth --useshadow --enablemd5 # System bootloader configuration bootloader --location=mbr key --skip # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Use graphical install graphical # Firewall configuration firewall --disabled # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard us # System language lang zh_CN # Installation logging level logging --level=info # Use NFS installation media nfs --server=192.168.200.104 --dir=/mnt # Network information network --bootproto=dhcp --device=eth0 --onboot=on # Reboot after installation reboot #Root password rootpw --iscrypted $1$1XcrmvYC$NMhnjtW6I4QUDWpECSK6L0

# SELinux configuration selinux --disabled # System timezone timezone Asia/Shanghai # Install OS instead of upgrade install # X Window System configuration information xconfig --defaultdesktop=GNOME --depth=8 --resolution=1024x768

By:Crushlinux

發揚開源精神,普及 linux 教育 - 10 -

# Disk partitioning information part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100 part swap --asprimary --bytes-per-inode=4096 --fstype="swap" --size=2048 part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1

%packages @base @gnome-desktop @development-libs @admin-tools @base-x @legacy-software-development @development-tools @chinese-support @gnome-software-development @x-software-development @openfabrics-enterprise-distribution @java-development @legacy-software-support @graphical-internet @system-tools @text-internet @ruby @java

[root@crushlinux4 ~]# vi /etc/exports /mnt *(ro) /pub *(ro)

[root@crushlinux4 ~]# service dhcpd restart

[root@crushlinux4 ~]# service xinetd restart

[root@crushlinux4 ~]# service nfs restart

環境測試:

新建一虛擬機網絡模式啓動與PXE Server用同一網卡

實驗拓展:

問題:使用system-config-kickstart來配置ks.cfg文件時,在軟件包選擇欄中提示"由於下載軟件包信息失敗,軟件包選擇被禁止"

解決方法:

創建一個yum倉庫名字一定要是“base”

By:Crushlinux

發揚開源精神,普及 linux 教育 - 11 -

[base]

name=base

baseurl=file:///mnt/cdrom/Server

enabled=1

gpgcheck=0

配置kickstart控制檯多lable

[root@crushlinux4 ~]# cd /tftpboot/pxelinux.cfg/

[root@crushlinux4 pxelinux.cfg]# vi default default linux prompt 1 timeout 600 display boot.msg F1 boot.msg F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label 1 kernel vmlinuz append ks=nfs:192.168.200.104:/pub/1.cfg initrd=initrd.img label 2 kernel vmlinuz append ks=nfs:192.168.200.104:/pub/2.cfg initrd=initrd.img label 3 kernel vmlinuz append ks=nfs:192.168.200.104:/pub/3.cfg initrd=initrd.img label 4 kernel vmlinuz append ks=nfs:192.168.200.104:/pub/4.cfg initrd=initrd.img

[root@crushlinux4 pxelinux.cfg]# cd ../

[root@crushlinux4 tftpboot]# vi boot.msg ^L ^Xsplash.lss

- To install or upgrade in graphical mode, press the ^O01<ENTER>^O07 key.

- To install or upgrade in text mode, type: ^O01linux text <ENTER>^O07.

- Use the function keys listed below for more information.

^O0f[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]^O07

By:Crushlinux

發揚開源精神,普及 linux 教育 - 12 -

lable 1 --> 1 lable 2 --> 2 lable 3 --> 3 lable 4 --> 4

[root@crushlinux4 tftpboot]# cd /pub/

[root@crushlinux4 pub]# mv ks.cfg 1.cfg

[root@crushlinux4 pub]# cp 1.cfg 2.cfg

[root@crushlinux4 pub]# cp 1.cfg 3.cfg

[root@crushlinux4 pub]# cp 1.cfg 4.cfg

環境測試:

新建一虛擬機網絡模式啓動與PXE Server用同一網卡


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章