测试环境:
centos6.5_x64
dhcp的安装及配置
yum install -y dhcp*
配置dhcpd.conf
vim /etc/dhcp/dhcpd.conf #option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org; ddns-update-style none; ignore client-updates; allow booting; allow bootp; default-lease-time 600; max-lease-time 7200; subnet 10.0.0.0 netmask 255.255.255.0 { range 10.0.0.10 10.0.0.20; option routers 10.0.0.1; } host ns{ #给主机为ns的服务器绑定MAC地址(固定IP) hardware ethernet 00:1a:a0:2b:38:81; fixed-address 10.0.0.11;} }
启动dhcp服务
service dhcpd start
遇到的问题:
dhcpd: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
localhost dhcpd: Can't chown new lease file: Operation not permitted
解决办法:关闭selinux,并重启机器
nfs的安装配置
安装
yum install -y nfs-utils
配置nfs挂载目录
vim /etc/exports /centos *(rw,sync)
启动nfs
service nfs start
tftp安装配置
yum install -y xinetd tftp*
配置tftp守护进程
vim /etc/xinetd.d/tftp 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 }
启动tftp守护进程
service xinetd start
配置kicstart
挂载镜像
mount /dev/cdrom /mnt mount CentOS-6.5-x86_64-minimal.iso /mnt/ -t iso9660 -o loop
安装syslinux(pxelinux.0文件)
[root@localhost ~]# yum install -y syslinux [root@localhost ~]# find / -name pxelinux.0 /usr/share/syslinux/pxelinux.0 #tftpboot用于指定pxe内核模块相关内容及参数 [root@localhost ~]# ln -s /var/lib/tftpboot/ / [root@localhost ~]# cd /tftpboot [root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 . [root@localhost ~]# cp /mnt/p_w_picpaths/pxeboot/* . [root@localhost ~]# mkdir pxelinux.cfg [root@localhost ~]# cp /mnt/isolinux/isolinux.cfg pxelinux.cfg/default [root@localhost ~]# vim pxelinux.cfg/default
添加内容示例:
#default vesamenu.c32 default centos6.5 #prompt 1 timeout 600 display boot.msg menu background splash.jpg menu title Welcome to CentOS 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 centos6.5 kernel vmlinuz append ks=nfs:10.0.0.4:/centos/ks.cfg initrd=initrd.img label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append 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配置的挂载目录/centos
配置ks.cfg文件(自动安装的重要文件)
示例:
vim /centos/ks.cfg # Kickstart file automatically generated by anaconda. #version=DEVEL install nfs --server=10.0.0.4 --dir=/centos text lang en_US.UTF-8 keyboard us network --onboot yes --device eth0 --bootproto dhcp #rootpw --iscrypted $1$yHkD65xl$1JQEiUKnhL.sirX1iMRIK. rootpw 123456 # Reboot after installation firewall --service=ssh authconfig --useshadow --enablemd5 selinux --disabled timezone --utc Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="crashkernel=auto 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=ext4 --size=100 part / --fstype=ext4 --grow --size=3000 part /data --fstype=ext4 --grow --size=13000 part swap --grow --maxsize=1984 --size=1000 #repo --name="CentOS" --baseurl=cdrom:sr1 --cost=100 reboot %packages @Base @Core @Desktop @Fonts @General Purpose Desktop @Internet Browser @Printing client @X Window System binutils gcc kernel-devel make patch python %end
拷贝镜像内所有文件到该目录
cp -rf /mnt/* /centos/
测试:
新建虚拟机选择pxe启动会自动安装
转载于:https://blog.51cto.com/j99d99/1716706