用PXE批量部署系统

在部署操作系统的时候可以选择安装centos6还是centos7

clipb9oard

在部署操作系统的时候可以选择安装centos6还是centos7
关闭防火墙和selinux
挂centos6和centos7的光盘
echo ‘- – -‘ > /sys/class/scsi_host/host0/scan
yum install httpd dhcp tftp-server syslinux -y
systemctl enable httpd dhcpd tftpd.socket 开机启动
systemctl start httpd tftp.socket
配置DHCP服务
option domain-name “example.org”;
option domain-name-servers 114.114.114.114;
default-lease-time 86400;
max-lease-time 200000;
subnet 192.168.63.0 netmask 255.255.255.0 {
range 192.168.63.100 192.168.63.200;
option routers 192.168.63.1;
next-server 192.168.63.134;
filename “pxelinux.0”;
}
systemctl restart dhcpd 启动服务
配置yum源
mkdir /var/www/html/centos/{6,7} -pv
/dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0
/dev/sr1 /var/www/html/centos/6 iso9660 defaults 0 0
~
配置应答文件
mkdir /var/www/html/ksdir
[root@localhost ksdir]# cp /root/ks7_desktop.cfg /var/www/html/ksdir/
[root@localhost ksdir]# cp /root/ks_mini.cfg /var/www/html/ksdir/
vim /var/www/html/ksdir/ks_mini.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard ‘us’
# Root password
rootpw –iscrypted $1$R3VaLZ60$6ivf/Qc89KVNf3SGYXP351
# Use network installation
url –url=http://192.168.63.134/centos/7
# System language
lang en_US
# Firewall configuration
firewall –disabled
# System authorization information
auth –useshadow –passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux –disabled
# Do not configure the X Window System
skipx
# Network information
network –bootproto=dhcp –device=ens33 –onboot=on –ipv6=auto –activate
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader –append=”selinux=0″ –location=mbr –password=”123456″
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart –all –initlabel
# Disk partitioning information
part swap –fstype=”swap” –size=2048
part / –fstype=”xfs” –size=20000
part /boot –fstype=”xfs” –size=5048
part /home –fstype=”xfs” –size=10000
%post
rm -rf /etc/yum.repos.d/*
mkdir /etc/yum.repos.d/bak
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///mnt/cdroot
gpgcheck=0
EOF
mkdir /mnt/cdroot
mount /dev/sr0 /mnt/cdroot
%end
%packages
@base
@core
vim
%end
配置TFTP
cd /var/lib/tftpboot/
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost tftpboot]# mkdir centos{6,7} 由于有两个内核,所以创建两个文件夹,一个放7的一个放6的
[root@localhost tftpboot]# cp /var/www/html/centos/6/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6/
[root@localhost tftpboot]# cp /var/www/html/centos/7/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7/
[root@localhost tftpboot]# cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/ 拷贝简单版菜单
[root@localhost tftpboot]# cp /var/www/html/centos/7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default 拷贝菜单文件并改名
vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title CentOS 7
label centos7
menu label ^Install Mini CentOS 7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://192.168.63.134/ksdir/ks7_mini.cfg
label centos6
menu label ^install Mini CentOS 6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://192.168.63.134/ksdir/ks_mini.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
menu end

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99623

发表评论

登录后才能评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1823388528@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班