(1)安装所需软件,搭建环境: #yum -y install httpd tftp-server dhcp system-config-kickstart 挂载光盘文件,将其他机器装机所需软件的复制到/var/www/html:(一定要放在Apache的运行目录下) #mkdir /media/cdrom #mount -o -loop CentOS-6.3.iso /media/cdrom #cp -fr /media/cdrom /var/www/html/ (2)相关配置: TFTP配置——修改/etc/xinetd.d/tftp文件: 接着修改/etc/xinetd.d/tftp文件,将disable的值由yes变为no,内容如下所示: 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 } .接着重启xinetd进程,命令如下所示: service xinetd restart DHCP配置——修改/etc/dhcp/dhcpd.conf: cp -p /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf vim /etc/dhcp/dhcpd.conf # dhcpd.conf # # Sample configuration file for ISC dhcpd # subnet 192.168.1.0 netmask 255.255.255.0 { default-lease-time 21600; max-lease-time 43200; range 192.168.1.210 192.168.1.230; option subnet-mask 255.255.255.0; next-server 192.168.1.228; filename "/pxelinux.0"; } (3)配置支持PXE的启动程序—— #cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot #cp /var/www/html/p_w_picpaths/pxeboot/initrd.img /var/lib/tftpboot #cp /var/www/html/p_w_picpaths/pxeboot/vmlinuz /var/lib/tftpboot #cp /var/www/html/isolinux/*.msg /var/lib/tftpboot #mkdir /var/lib/tftpboot/pxelinux.cfg #cp /var/www/html/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default 终端运行kickstart #system-config-kickstart ks.cfg: #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --enabled --ssh # Install OS instead of upgrade install # Use network installation url --url="http://192.168.1.228/" # Root password rootpw --iscrypted $1$5RsAThGe$7Uo10EjVpxizCaiAB3knD1 # System authorization information auth --useshadow --passalgo=md5 # Use text mode install text firstboot --disable # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux --disabled # Installation logging level logging --level=info # Reboot after installation reboot # System timezone timezone --isUtc Asia/Shanghai # Network information network --bootproto=static --device=eth0 --gateway=192.168.1.1 --ip=192.168.1.6 -- nameserver=192.168.1.1 --netmask=255.255.255.0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="ext4" --size=200 part swap --fstype="swap" --size=4096 part / --asprimary --fstype="ext4" --size=30000 %packages @base @basic-desktop @chinese-support @compat-libraries @console-internet @debugging @desktop-debugging @desktop-platform @fonts @general-desktop @graphical-admin-tools @input-methods @internet-browser @legacy-x @remote-desktop-clients @x11 -nspluginwrapper -totem-mozplugin %end 修改此default文件: vim /var/lib/tftpboot/pxelinux.cfg/default 第1行改为:default linux(对应就是下面的label linux) timeout 600改为timeout 1,这样可以立马进入装机,不用等待。 label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append initrd=initrd.img 后添加一个:ks=http://192.168.x.x/ks.cfg 重启服务器 关闭防火墙 service httpd restart service xinetd restart service dhcpd restart service iptables stop
转载于:https://blog.51cto.com/xunzhang/1297809