dhcp+tftp+pxe+kickstart网络引导与无人值守安装
环境为:Red Hat Enterprise Linux Server 5 Update 4 (rhel5.4)
server(server1.example.com:192.168.10.254)
client(stationX.example.com:192.168.10.X)
1,配置yum本地库,搭nfs server,目的是共享安装源
把RHEL5的光盘的所有东西拷到/var/ftp/pub
[root@server1 ~]#mount –t iso9660 /dev/cdrom /media/cdrom
[root@server1 ~]# cp -r /media/cdrom/* /var/ftp/pub/
设置nfs 配置文件
[root@server1 ~]# vim /etc/exports
/var/ftp/pub 192.168.10.0/24(ro,sync)
[root@server1 ~]# service nfs restart
再做个http server
[root@server1 ~]# yum install -y httpd
[root@server1 ~]# cd /var/www/html/
[root@server1 html]# ln -s /var/ftp/pub/ pub
[root@server1 html]# ls -l
lrwxrwxrwx 1 root root 13 Sep 4 02:21 pub -> /var/ftp/pub/
配置yum本地库:
[root@server1 ~]# vim /etc/yum.repos.d/server1.repo
[base] ---->仓库名字一定为"base”
name=server1
baseurl=file:///media/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
清除yum缓存
[root@server1 ~]# yum clean all
2,制作kickstart脚本文件
[root@server1 ~]# yum list | grep kickstart
This system is not registered with RHN.
RHN support will be disabled.
pykickstart.noarch 0.43.5-1.el5 installed
system-config-kickstart.noarch 2.6.19.8-2.el5 installed
[root@server1 ~]# yum install -y system-config-kickstart
[root@server1 ~]# system-config-kickstart
会弹出图形界面,相信大家都会的.
完成后保存成文件
打开这个文件看看效果(也可以直接在这个文件里编辑)
[root@server1 ~]# vim /var/ftp/pub/ksfile/ks_32.cfg
auth --useshadow --enablemd5
bootloader --location=mbr
zerombr
clearpart --all --initlabel
graphical
firewall --disabled
firstboot --disable
key --skip
keyboard us
lang en_US
logging --level=info
nfs --server=192.168.10.254 --dir=/var/ftp/pub
network --bootproto=dhcp --device=eth0 --onboot=on
reboot
rootpw --iscrypted $1$rj5p8xZ3$OnS8CeYJHecHLvOkykJZ91
selinux --enforcing
timezone Asia/Shanghai
install
xconfig --defaultdesktop=GNOME --depth=16 --resolution=800x600 --startxonboot
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part / --bytes-per-inode=4096 --fstype="ext3" --size=5000
part swap --bytes-per-inode=4096 --fstype="swap" --size=512
part /home --bytes-per-inode=4096 --fstype="ext3" --size=512
%post
%packages
@base
@gnome-desktop
@system-tools
@sound-and-video
@graphical-internet
@graphics
@office
@text-internet
@printing
@games
@chinese-support
@editors
@base-x
2,配制DHCP server,
[root@server1 ~]# yum install -y dhcp
[root@server1 ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
[root@server1 ~]# vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
next-server 192.168.10.254; --->指定tftp server
filename "pxelinux.0"; --->指定filename
subnet 192.168.10.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.10.254;
option subnet-mask 255.255.255.0;
option nis-domain "notexample";
option domain-name "example.com";
option domain-name-servers 192.168.10.254;
option time-offset -18000; # Eastern Standard Time
option ntp-servers 192.168.10.254;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.10.10 192.168.10.20;
default-lease-time 21600;
max-lease-time 86400;
# we want the nameserver to appear at a fixed address
host ns {
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
3,设置tftp server
tftp-server默认系统已经安装
[root@server1 ~]# rpm -qa |grep tftp
tftp-server-0.49-2
[root@server1 ~]# cd /tftpboot/
[root@server1 tftpboot]# locate pxelinux.0
/usr/lib/syslinux/pxelinux.0
[root@server1 tftpboot]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
[root@server1 tftpboot]# cp /var/ftp/pub/isolinux/* /tftpboot/
[root@server1 tftpboot]# mkdir pxelinux.cfg
[root@server1 tftpboot]# cp isolinux.cfg pxelinux.cfg/default
[root@server1 tftpboot]# chmod 644 pxelinux.cfg/default
[root@server1 tftpboot]# vim pxelinux.cfg/default
default linux
prompt 1
timeout 600 --->这个是等待时间默认为60秒,可以自行修改
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.10.254/pub/ksfile/ks_32.cfg --->加上刚才的脚本
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
服务器基本配置完成!
client开始验证
开机时按F12就可以了进入网络引导了
又到了熟悉的界面了,直接回车
等!
等!
等!
等待全自动完成!无人值守的步骤就完成了!