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

来源:互联网 发布:程序员鼓励师慰安妇 编辑:程序博客网 时间:2024/05/09 23:08

公司购买了一批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

剩下的事情就是端杯茶,慢慢品尝了。

本文出自 “小苗” 博客,请务必保留此出处http://7056824.blog.51cto.com/69854/278602

原创粉丝点击