环境:
dhcp服务器:172.168.0.1
tftp+pxe服务器:172.168.0.2
配置DHCP服务器
一、配置本地yum源
mount /dev/cdrom /mnt rm -rf /etc/yum.repos.d/* vi /etc/yum.repos.d/base.repo [base] name=base baseurl=file:///mnt enabled=1 gpgcheck=0 yum repolist
二、安装配置dhcp
yum -y install dhcp cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf cat /etc/dhcp/dhcpd.conf | grep -v "^$" | grep -v "^#" option domain-name "parpar.com"; option domain-name-servers 8.8.8.8; default-lease-time 3600; max-lease-time 7200; log-facility local7; subnet 172.168.0.0 netmask 255.255.0.0 { range 172.168.0.20 172.168.0.30; option routers 172.168.0.1; next-server 172.168.0.2; filename "pxelinux.0"; } chkconfig dhcpd on service dhcpd start
配置tftp+http+pxe服务器
一、安装配置tftp
yum -y install tftp tftp-server chkconfig tftp on service xinetd start
二、配置PXE工作环境
yum -y install syslinux cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
三、提供引导内核文件
cp /mnt/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/ cp /mnt/isolinux/{vesamenu.c32,boot.msg,splash.jpg} /var/lib/tftpboot mkdir /var/lib/tftpboot/pxelinux.cfg cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
四、安装配置httpd服务
yum -y install httpd mkdir /var/www/html/centos6 mount --bind /mnt /var/www/html/centos6 service httpd start
五、生成ks文件
yum -y install system-config-kickstart system-config-kickstart mv ks.cfg /var/www/html/ cat /var/www/html/ks.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="http://172.168.0.2/centos6" repo --name="CentOS" --baseurl=http://172.168.0.2/centos6 --cost=100 # Root password rootpw --iscrypted $1$10KAJR0t$WqUKt8fRa24FDPnHZxRTZ1 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical 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 Asia/Shanghai # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda" # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="ext4" --size=200 part swap --size=4000 part / --fstype="ext4" --grow --size=200 %packages @core %end
六、修改
vim /var/lib/tftpboot/pxelinux.cfg/default label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append ks=http://172.168.0.2/ks.cfg initrd=initrd.img
九、配置完成,新启动虚拟机即可自动安装系统
时间: 2024-10-13 20:54:26