白天和黑夜只交替没交换无法想像对方的世界
分类: linux
2011-05-31 19:01:27
centos5.4下配置pxe kickstart无人值守安装
pxe工作过程
在上图中,pxe client是需要安装linux的计算机,tftp server和dhcp server运行在另外一台linux server上。bootstrap文件、配置文件、linux内核以及linux根文件系统都放置在linux server上tftp服务器的根目录下。
操作步骤: 要实现一个pxe kickstart无人值守安装,从上面的理论解说中,我们知道,至少需要dhcp与tftp服务来完成引导。要进行网络安装的 话,我们则需要nfs或者http或者ftp服务。这里,我们选择nfs。tftp要工作的话,我们又要安装xinetd。加上要生成bootstrap 文件要安装的syslinux。我们要安装的软件包一共如下: dhcp tftp-server xinetd syslinux nfs-utils
dchp 安装dhcp: yum install -y dhcp 安装完成之后,把dhcp.conf.sample文件拷贝到/etc下面 cp /usr/share/doc/dhcp-3.0.5/dhcp.conf-sample /etc/dhcpd.conf 编辑/etc/dhcp.conf。 找到: ignore client-updates; 在后面添加上: next-server 192.168.1.152; 找到: option nis-domain "domain.org"; 将其注释 配置你的网卡,将其ip改为192.168.1.152 找到: bootproto=dhcp 改为: bootproto=static 并在其下加上两行: ipaddr=192.168.1.152 重启网络并启动dhcp /etc/init.d/network restart tftp-server yum install -y xinetd tftp-server 配置tftp-server tftp默认是绑定在xinetd服务下的,因此,要修改tftp文件就要到/etc/xinetd.d下完成,修改后的tftp文件如下所示,其中“disable“选项由“yes“修改为”no“,在server_args选项增加了” -u nobody“参数,以让任何用户均可访问。 找到: disable = yes 将其改为 disable = no 启动tftp-server /etc/init.d/xinetd start pxelinux.0 yum install -y syslinux 启动文件 mount -o loop /root/centos-5.4-i386-bin-dvd.iso /mnt 拷贝内核文件vmlinuz以及根文件系统initrd.img到/tftpboot cp /mnt/images/pxeboot/vmlinuz /mnt/images/pxeboot/initrd.img /tftpboot 创建/tftpboot/pxelinux.cfg目录 mkdir /tftpboot/pxelinux.cfg 创建/tftpboot/pxelinux.cfg/default文件 touch /tftpboot/pxelinux.cfg/default 文件内容如下: default linux 配置nfs网络安装 mkdir /netinstall 安装nfs服务,并将/netinstall发布出去 yum install -y nfs-utils 关于ks.cfg文件 # rpm –ivh /mnt/centos/ system-config-kickstart-2.6.19.8-2.el5.rpm #system-config-kickstart 运行图形化配置工具,进行相关配置,最后,保存成ks.cfg文件即可。 #cp ks.cfg /netinstall/ks.cfg |
注意:ks.cfg文件可以用system-config-kickstart生成,内容可以根据自己的需求而定。
1. 配置文件ks.cfg内容如下:
[root@lvgoo-test-02 netinstall]# cat ks.cfg
#platform=x86, amd64, or intel em64t
# system authorization information
auth --useshadow --enablemd5
# system bootloader configuration
bootloader --location=mbr
# partition clearing information
#clearpart --none
autopart
clearpart --all --drives=sda --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 en_us
# installation logging level
logging --level=info
# use nfs installation media
nfs --server=192.168.1.152 --dir=/netinstall
# network information
network --bootproto=dhcp --device=eth0 --onboot=on
# reboot after installation
reboot
#root password
rootpw --iscrypted $1$uiau9bh9$l2yhrsqrso0jwgazcqoh1.
# selinux configuration
selinux --disabled
# system timezone
timezone america/new_york
# install os instead of upgrade
install
# x window system configuration information
xconfig --defaultdesktop=gnome --depth=32 --resolution=1024x768
# disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=16384
part / --bytes-per-inode=4096 --fstype="ext3" --size=112640
part /data --bytes-per-inode=4096 --fstype="ext3" --size=778240
%packages
@base
@chinese-support
@core
@development-libs
@development-tools
@editors
@gnome-desktop
@games
@graphical-internet
@graphics
@legacy-software-development
@legacy-software-support
@office
@sound-and-video
@system-tools
@text-internet
@base-x
keyutils
trousers
fipscheck
device-mapper-multipath
imake
java-1.6.0-openjdk
libsane-hpaio
festival
audit
net-snmp-utils
sysstat
xorg-x11-server-xnest
xorg-x11-server-xvfb
2.配置文件default内容如下:
# cat /tftpboot/pxelinux.cfg/default
default linux
prompt 0
label linux
kernel vmlinuz
append ks=nfs:192.168.1.152:/netinstall/ks.cfg initrd=initrd.img
3.配置文件dhcpd.conf内容如下:
[root@lvgoo-test-02 netinstall]# cat /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.152;
option subnet-mask 255.255.255.0;
option nis-domain "lvgoo.com";
option domain-name "lvgoo.com";
option domain-name-servers 192.168.1.152;
option time-offset -18000;
range 192.168.1.240 192.168.1.250;
default-lease-time 21600;
max-lease-time 43200;
server-name "192.168.1.152";
next-server 192.168.1.152;
filename "/pxelinux.0";
host server1 {
server-name "192.168.1.152";
next-server 192.168.1.152;
hardware ethernet a4:ba:db:36:10:41;
fixed-address 192.168.1.241;
filename "/pxelinux.0";
}
}
4.配置文件tftp内容如下:
[root@lvgoo-test-02 netinstall]# cat /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 = -u nobody -s /tftpboot
disable = no
per_source = 11
cps = 1002
flags = ipv4
}