一.配置dhcp服务
[root@localhost ~]# yum install dhcp -y
[root@localhost ~]# cat /etc/dhcp/dhcpd.conf
ddns-update-style interim;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20 192.168.1.254;
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 86400;
max-lease-time 172800;
next-server 192.168.1.1; ##tftpf服务器地址
filename "pxelinux.0"; ###网络启动
}
[root@localhost ~]# service dhcp start二.配置TFTP
[root@localhost ~]# yum install tftp-server
[root@localhost ~]# vim /etc/xintd.d/tftp ##编辑使其打开tftp功能
[root@localhost ~]# 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= -s /var/lib/tftpboot
disable= no
per_source= 11
cps= 100 2
flags= IPv4
}
[root@localhost ~]# service xinitd restart开启防火墙69/udp
三.配置SYSLINUX
[root@localhost ~]# yum install syslinux [root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ [root@localhost ~]# cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/ [root@localhost ~]# cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/ [root@localhost ~]# cp /mnt/isolinux/vesamenu.c32 /var/lib/tftpboot/ [root@localhost ~]# cp /mnt/isolinux/*.msg /var/lib/tftpboot/ [root@localhost ~]# cp /mnt/isolinux/splash.jpg /var/lib/tftpboot/ [root@localhost tftpboot] ll 总用量 38044 -r--r--r--. 1 root root 84 9月 1 04:27 boot.msg -r--r--r--. 1 root root 33383449 9月 1 04:24 initrd.img -rw-r--r--. 1 root root 26828 9月 1 04:23 pxelinux.0 drwxr-xr-x. 2 root root 4096 9月 1 06:18 pxelinux.cfg -r--r--r--. 1 root root 1236005 9月 1 06:25 splash.jpg -r--r--r--. 1 root root 162860 9月 1 04:26 vesamenu.c32 -r-xr-xr-x. 1 root root 4128944 9月 1 04:24 vmlinuz [root@localhost tftpboot]# [root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg [root@localhost ~]# cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost pxelinux.cfg]# cat default default vesamenu.c32 #prompt 1 timeout 600 display boot.msg menu background splash.jpg menu title Welcome to Red Hat Enterprise Linux 6.5! menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000 label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append ks=nfs:192.168.1.1:/tmp/ks.cfg inst.stage2=nfs:192.168.1.1/systemiso/rhel6 initrd=initrd.img label vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img xdriver=vesa nomodeset label rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff label memtest86 menu label ^Memory test kernel memtest append -
四.配置NFS
[root@localhost tftpboot]# cat /etc/exports /systemiso/rhel6 *(rw) /tmp/ *(rw) [root@localhost tftpboot]# [root@localhost ~]# mkdir -p /systemiso/rhel6 [root@localhost ~]# cp -r /mnt/* /systemiso/rhel6 [root@localhost ~]# chmod +r /systemiso/rhel6/* [root@localhost ~]# service nfs start [root@localhost tftpboot]# cat /etc/exports /systemiso/rhel6 *(rw) /tmp/ *(rw)
五.创建kickstart文件
可以使用图形化配置ks.cfg文件 [root@localhost tftpboot]# yum install system-config-kickstart
或者直接使用已经创建好的ks.cfg [root@localhost ~]# cat /tmp/ks.cfg #platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use NFS installation media nfs --server=192.168.110.1 --dir=/systemiso/rhel6 # Root password rootpw --iscrypted $1$eQ/X66iG$5qRmqf/zXbufAREjjaWLv. # System authorization information auth --useshadow --passalgo=sha512 # 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 Africa/Abidjan # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information #我给的硬盘8G part /boot --fstype="ext4" --size=500 part / --fstype="ext4" --size=6656 part swap --fstype="swap" --size=1000 %packages @base @compat-libraries %end
最后创建虚拟机,使用网络px启动即可自动安装
本文出自 “TOP-ONE” 博客,请务必保留此出处http://onenice.blog.51cto.com/13201315/1965074
DHCP+TFTP+SYSLINUX+NFS+KICKSTART
原文:http://onenice.blog.51cto.com/13201315/1965074