PXE 安裝 RedHat Enterprise Linux AS 4 update 7 (linux版)

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

公司購買了一批HP DL360G5伺服器,數量大約有200台.要統一安裝 RedHat Enterprise Linux AS 4 update 7 操作系統.如果一台一台手動安裝不但費時費事,更是會讓我羸弱的身體雪上加霜.於是公欲善其事,必先利其器.我決定使用PXE來批量安裝這批伺服器.
以下是安裝配置的過程:

硬體和軟體環境:
硬體:找一台安裝了RedHat Enterprise Linux AS 4 update 7 系統的伺服器,一台48口千兆交換機(沒有千兆交互機可以用百兆交換機替代)
軟體:tftp-server、dhcpd、vsftpd

軟體安裝配置過程:
1、安裝tftp-server
從 RedHat Enterprise Linux AS 4 update 7 安裝光碟找到 tftp-server-0.39-3.el4.i386.rpm 軟體包並安裝.
修改 /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
disable = no #將原來的yes改成no
per_source = 11
cps = 100 2
flags = IPv4
}

重啟 xinetd 服務

#service xinetd restart.
配置tftpboot目錄內的文件
複製 RedHat Enterprise Linux AS 4 update 7 安裝光碟中 /images/pxeboot/ 目錄下的initrd.img和vmlinuz到/tftpboot目錄下.
從 http://www.kernel.org/pub/linux/utils/boot/syslinux/ 下載最新版的 syslinux.我下載的是syslinux-3.84.zip.
解壓syslinux-3.84.zip
複製其中的com32/menu/vesamenu.c32 到 /tftpboot 目錄下.
複製其中的core/pxelinux.0 到 /tftpboot 目錄下.
複製其中com32/hdt/art/backgnd.png 到 /tftpboot 目錄下.
在 /tftpboot 目錄下新建一個目錄pxelinux.cfg
在 /tftpboot/pxelinux.cfg 目錄下建立default文件,內容如下:

default vesamenu.c32
prompt 0

menu TITLE PXE Boot Install Menu By WOSZM
MENU BACKGROUND backgnd.png
timeout 100

label linux4u7
MENU LABEL ^0----Install RedHat AS4 update 7
kernel vmlinuz
append ks=ftp://192.168.0.1/ks.cfg ksdevice=eth0 initrd=initrd.img ramdisk_size=8192

/tftpboot 目錄下的內容如下:
-rw-r--r-- 1 root root 10155 Feb 5 10:53 backgnd.png
-rw-r--r-- 1 root root 4266944 Feb 1 10:05 initrd.img
-rwxr-xr-x 1 root root 16466 Feb 1 10:04 pxelinux.0
-drwxr-xr-x 2 root root 4096 Feb 5 11:31 pxelinux.cfg
.----------rwxr-xr-x 1 root root 103 Feb 5 11:31 default
-rwxr-xr-x 1 root root 158364 Feb 5 10:48 vesamenu.c32
-rw-r--r-- 1 root root 1545551 Feb 1 10:05 vmlinuz

2、安裝vsftpd
從 RedHat Enterprise Linux AS 4 update 7 安裝光碟找到 vsftpd-2.0.1-6.el4.i386.rpm 軟體包並安裝.
vsftpd默認支持匿名下載,無需修改配置,只要啟動 vsftpd 服務#service vsftpd start.
建立 RedHat Enterprise Linux AS 4 update 7 安裝樹.
#mount -o loop RHEL4.7-i386-AS-DVD.iso /mnt
#cp -avr /mnt /var/ftp/rhel

3、安裝dhcpd
從 RedHat Enterprise Linux AS 4 update 7 安裝光碟找到 dhcp-3.0.1-62.EL4.i386.rpm 軟體包並安裝.
修改 ll /etc/dhcpd.conf 文件:

#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#

ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;

subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
#option domain-name-servers 192.168.0.1;
option time-offset -18000;
range dynamic-bootp 192.168.0.100 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.0.1;
filename "/pxelinux.0";
}

用以上的內容替換原來的文件內容.
修改伺服器網卡eth0的配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE=eth0
BOOTPROTO=static
TYPE=Ethernet
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0

修改dhcp啟動網卡的配置文件 /etc/sysconfig/dhcpd

# Command line options here
DHCPDARGS=eth0

啟動網卡#ifup eth0
啟動dhcp服務#service dhcpd start

4、配置ks.cfg

按照下面的內容或者安裝你需要的內容配置ks.cfg文件,並將文件複製大/var/ftp目錄下.

# Kickstart file automatically generated by anaconda.

install
url --url=ftp://192.168.0.1/rhel/
lang zh_CN.UTF-8
langsupport --default=en_US.UTF-8 zh_CN.UTF-8 en_US.UTF-8
keyboard us
xconfig --card "ATI ES1000" --videoram 32768 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16 --startxonboot --defaultdesktop kde
text
network --device eth0 --bootproto dhcp
network --device eth1 --bootproto dhcp
rootpw --iscrypted $1$VhK0ct0.$yLPLHRWsKYEUFnNbGA4s2.
firewall --enabled --port=22:tcp --port=80:tcp --port=21:tcp --port=25:tcp
selinux --enforcing
poweroff
authconfig --enableshadow --passalgo=md5
timezone Asia/Shanghai
bootloader --location=mbr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=200
part swap --size=2048
part / --fstype ext3 --size=100 --grow

%packages
@ editors
@ emacs
@ system-tools
@ text-internet
@ dialup
@ ftp-server
@ compat-arch-support
@ legacy-software-development
@ chinese-support
@ development-tools
sysstat
-ckermit
-OpenIPMI-tools
-openldap-clients
rdesktop
-samba-client
kernel-devel
-bluez-pin
iptraf
-wireshark
kernel
-xdelta
e2fsprogs
-zsh
-open
grub
net-snmp-utils

%post

關於ks.cfg的其他具體參數請參考:https://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Installation_Guide-en-US/s1-kickstart2-options.html

剩下的事情就是端杯茶,慢慢品嘗了.





[火星人 ] PXE 安裝 RedHat Enterprise Linux AS 4 update 7 (linux版)已經有352次圍觀

http://coctec.com/docs/linux/show-post-51985.html