一.配置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= dgramprotocol= udpwait= yesuser= rootserver= /usr/sbin/in.tftpdserver_args= -s /var/lib/tftpbootdisable= noper_source= 11cps= 100 2flags= 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/p_w_picpaths/pxeboot/initrd.img /var/lib/tftpboot/[root@localhost ~]# cp /mnt/p_w_picpaths/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.0drwxr-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 defaultdefault vesamenu.c32#prompt 1timeout 600display boot.msgmenu background splash.jpgmenu title Welcome to Red Hat Enterprise Linux 6.5!menu color border 0 #ffffffff #00000000menu color sel 7 #ffffffff #ff000000menu color title 0 #ffffffff #00000000menu color tabmsg 0 #ffffffff #00000000menu color unsel 0 #ffffffff #00000000menu color hotsel 0 #ff000000 #ffffffffmenu color hotkey 7 #ffffffff #ff000000menu color scrollbar 0 #ffffffff #00000000label 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.imglabel vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img xdriver=vesa nomodesetlabel rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescuelabel local menu label Boot from ^local drive localboot 0xfffflabel 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 configurationfirewall --disabled# Install OS instead of upgradeinstall# Use NFS installation medianfs --server=192.168.110.1 --dir=/systemiso/rhel6# Root passwordrootpw --iscrypted $1$eQ/X66iG$5qRmqf/zXbufAREjjaWLv.# System authorization informationauth --useshadow --passalgo=sha512# Use text mode installtextfirstboot --disable# System keyboardkeyboard us# System languagelang en_US# SELinux configurationselinux --disabled# Installation logging levellogging --level=info# Reboot after installationreboot# System timezonetimezone Africa/Abidjan# Network informationnetwork --bootproto=dhcp --device=eth0 --onboot=on# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel# Disk partitioning information #我给的硬盘8Gpart /boot --fstype="ext4" --size=500 part / --fstype="ext4" --size=6656part swap --fstype="swap" --size=1000%packages@base@compat-libraries%end
最后创建虚拟机,使用网络px启动即可自动安装