用DHCP,NFS,tftpd搭建PXE无人值守安装linux操作系统

由于新需要装大量linux机器,便尝试了PXE无人安装,效果不错,与大家分享一下配置文件:
1.DCHP:  vi /etc/dhcpd.conf

option domain-name "mydomain";
ddns-update-style none;

max-lease-time 7200;
server-name "bootserver";
default-lease-time 600;

allow booting;
allow bootp;

subnet 192.168.141.0 netmask 255.255.255.0 {
                option routers 192.168.141.254;
                option subnet-mask 255.255.255.0;
                option domain-name-servers    8.8.8.8;
                range 192.168.141.96 192.168.141.98;
                deny unknown-clients;
                next-server 192.168.141.95;
}

group pxe {
                filename "pxelinux.0";
                host testserver {
                hardware ethernet 00:0c:29:4b:28:2d;
                fixed-address 192.168.141.96;
                                }
                }
2. tftpd 配置:
service tftp
{
                socket_type                         = dgram
                protocol                                = udp
                wait                                        = yes
                user                                        = root
                server                                    = /usr/sbin/in.tftpd
                server_args                         = -s /tftpboot
                disable                                 = no
                per_source                            = 11
                cps                                         = 100 2
                flags                                     = IPv4
}
3. nfs 配置:
/media/cdrom *(ro,sync)
/tftpboot     *(ro,sync)
 
完成部署机所需服务配置;下面配置 tftpd目录下文件;
有如下文件:
用DHCP,NFS,tftpd搭建PXE无人值守安装linux操作系统_第1张图片
 
其中ks.cfg 请在 图形界面下用kickstart工具生成;位置:application-systemtools-kickstart
其他 initrd 和 vmlinuz从 系统目录下拷贝;
#mkdir /mnt/iso
#mount -o loop,ro vmlinuz-2.6.18-194.el5-disc1.iso    /mnt/iso
#cp /mnt/iso/isolinux/initrd.img /tftpboot
#cp /mnt/iso/isolinux/vmlinuz /tftpboot
#mv /tftpboot/initrd.img /tftpboot/initrd-2.6.18-194.el5.im
#mv /tftpboot/vmlinuz /tftpboot/vmlinuz-vmlinuz-2.6.18-194.el5
 
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
 
pxelinux.cfg 目录下:保存有 default文件;内容如下:
default autoinstall
label autoinstall
kernel vmlinuz-2.6.18-194.el5
append ks=nfs:192.168.141.95:/tftpboot/ks.cfg initrd=initrd-2.6.18-194.el5.img
这里很重要,如果和tftpboot 文件夹里面的对不上,或者有换行符,客户端获取就会出错。
 
 
 

你可能感兴趣的:(nfs,DHCP,pxe,无人值守安装,tftpd)