远程安装系统过程:PXE网卡启动——DHCP服务器——获得IP——从TFTP上下载pxelinux.0、
vmlinuz、initrd——启动系统——通过PXElinux去nfs下载ks.cfg文件—–根据ks.cfg去nfs下载安装文件。
载RPM包及安装系统——完成安装
1. 搭建tftp,dhcpf服务器
#yum install tftp* dhcp*
#vim /etc/xinetd.d/tftp
1. service tftp
2. {
3. disable = no
4. socket_type = dgram
5. protocol = udp
6. wait = yes
7. user = root
8. server = /usr/sbin/in.tftpd
9. server_args = -u nobody -s /tftpboot
10. per_source = 11
11. cps = 100 2
12. flags = IPv4
13. }
需要修改1个地方
disable = no 修改为yes
#cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf #vim /etc/dhcpd.conf (修改成如下) ddns-update-style interim; ignore client-updates; next-server 192.168.0.100; filename “pxelinux.0″; authoritative; allow booting; allow bootp; subnet 192.168.0.0 netmask 255.255.252.0 { option routers 192.168.0.1; option subnet-mask 255.255.252.0; option domain-name “mapbar.com”; option domain-name-servers 192.168.0.10; range dynamic-bootp 192.168.0.100 192.168.0.200; default-lease-time 21600; max-lease-time 43200; } ddns-update-style interim; /*dhcp支持的dns动态更新方式*/ ignore client-updates; /*忽略客户端DNS动态更新*/ authoritative; /*授权*/ allow booting; /*支持PXE启动*/ allow bootp; /*支持boottp*/ subnet 192.168.0.0 netmask 255.255.252.0 /*作用域*/ option routers 192.168.0.1; 网关的IP地址 range dynamic-bootp 192.168.0.100 192.168.0.200; 分配给客户端的IP地址范围 default-lease-time 21600; /*租期,秒数*/ max-lease-time 43200; /*最大租期,秒数*/ next-server 192.168.0.100; /*TFTPServer的IP*/ filename “pxelinux.0″; /*Bootstrap文件*/ 2.配置支持PXE mount /dev/cdrom /mnt && mkdir /centosinstall && cp –rf /mnt/* /centosinstall && vi /etc/exports /centosinstall *(rw,sync) 启动服务 service dhcpd start service portmap start service nfs start mkdir /tftpboot tftp的根目录 cp /usr/lib/syslinux/pxelinux.0 /tftpboot cp /mnt/images/pxeboot/{vmlinuz,initrd.img} /tftpboot mkdir /tftpboot/pxelinux.cfg cp /mnt/isolinux/isolinux.cfg pxelinux.cfg/default vim /tftpboot/pxelinux.cfg/default (修改配置如下:) default linux prompt 1 timeout 600 display boot.msg F1 boot.msg F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label linux kernel vmlinuz append ks=nfs:192.168.0.100:/centosinstall/ks.cfg initrd=initrd.img (需要修改的地方) 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 - 设置timeout 10 /*超时时间为10S */ 3.生成ks.cfg安装配置文件(拷贝到提供安装的目录 /centosinstall目录) 设置权限 chmod o+wx /centosinstall/ks.cfg 可以根据/root/目录下的anaconda-ks.cfg文件修改需要的系统需求。 (注意、clearpart –all –initlabel #如果ks.cfg脚本中不添加该语句,将不能实现自动化安装) nfs –server=NFS服务器ip –dir=光盘的位置 或 系统安装文件存放的位置 network –device eth0 –bootproto dhcp(使用DHCP来实现自动分配IP地址) 启动客户端,加电+插上网线,设置网卡启动,等待安装完毕即可。 重启系统就可以了。 以下为我的ks.cfg参考配置: # Kickstart file automatically generated by anaconda.cfg install text nfs –server=192.168.0.100 –dir=/centosinstall key –skip lang zh_CN.UTF-8 keyboard us network –device eth0 –bootproto dhcp rootpw fsdf@sdfsd123 firewall –disabled authconfig –enableshadow –enablemd5 selinux –disabled timezone Asia/Shanghai bootloader –location=mbr –driveorder=sda –append=”rhgb quiet” # 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=2000 part /software –fstype ext3 –size=20000 part / –fstype ext3 –size=30000 part /home –fstype ext3 –size=20000 part /webapps –fstype ext3 –size=1 –grow %packages @admin-tools @base @core @development-libs @development-tools @editors @system-tools @base-x keyutils kexec-tools trousers fipscheck device-mapper-multipath imake audit xorg-x11-server-Xnest xorg-x11-server-Xvf