简单原理介绍:无光软驱服务器通过PXE网卡启动,从dhcp服务器获取IP 通过tftp 取到pxelinux配置文件,按配置文件进行启动centos 文件进行引导系统安装。
二、环境说明
本文测试环境及用到的软件
Server: centos 5.2 dhcp nfs tftp ip:192.168.1.251 (此IP只需要与服务器网卡相连,不管是什么都可以)
三、安装配置过程及基本讲解:
安装相应的软件:yum -y install dhcp* nfs* tftp*
<!--[if !supportLists]-->1、 <!--[endif]-->配置tftp
[code] more /etc/xinetd.d/tftp
# default: off
# de.ion: 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.
# trad: liuyu
# blog: liuyu.blog.51cto.com
# bbs: www.linuxtone.org
service tftp
{
disable = no #默认是yes 改为no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /tftpboot #添加nobody可以访问//-s 表示用/tftpboot作为tftp目录的根目录
per_source = 11
cps = 100 2
flags = IPv4
} [/code]
重启xinetd服务: /etc/init.d/xinetd restart
查看tftp 是否启动:# chkconfig --list |grep tftp
tftp: on
<!--[if !supportLists]-->2、 <!--[endif]-->配置nfs
mount /iso/CentOS-5.2-i386-bin-1of6.iso /mnt -o loop #我是挂载的镜像文件,你们可以挂载光驱
echo "/tftpboot *(ro,sync)" > /etc/exports
echo "/mnt *(ro,sync)" > /etc/exports #此二步设置共享的目录
exportfs -a #使配置生效
/etc/init.d/portmap start &&/etc/init.d/nfs start #重启服务
Showmount -e localhost #看查共享的目录
Export list for localhost:
/mnt *
/tftpboot *
3、配置dhcp
直接copy我的配置
[code]# more /etc/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
# trad: liuyu
# blog: liuyu.blog.51cto.com
# bbs: www.linuxtone.org
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.251;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.251; #本地IP
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.1.12 192.168.1.254; #要分区的IP
default-lease-time 21600;
max-lease-time 43200;
# Group the PXE bootable hosts together
# PXE-specific configuration directives...
next-server 192.168.1.251;
filename "/pxelinux.0"; #方便查找配置文件
} [/code]
/etc/init.d/dhcpd start 启动服务
<!--[if !supportLists]-->4、 <!--[endif]-->配置pxe所需要的文件
[code]
Mkdir /tftpboot/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
cp /mnt/isolinux/vmlinuz /tftpboot/
cp /mnt/isolinux/initrd.img /tftpboot/
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default [/code]