用PXE批量部署系统

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

用PXE批量部署系统

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

(0)
周亚飞周亚飞
上一篇 2018-05-27
下一篇 2018-05-27

相关推荐

  • shell脚本编程基础

    简要概括一点脚本小知识

    Linux笔记 2018-04-14
  • lvs

    Linux笔记 2018-07-08
  • liniux课程第一周总结

    第一天课程内容 MBR分区类型:主分区:1-4,一块硬盘最多4个主分区,不可以分小区,可以用来启动操作系统(系统分区),直接建文件系统,存放数据扩展分区:一块硬盘最多一个扩展分区,可以没有,加主分区最多4个,不能创建文件系统,可以再划分更小的分区(即逻辑分区)逻辑驱动器(分区):可以创建文件系统,存放数据 系统分区:启动操作系统的分区启动分区:安装操作系统的…

    Linux笔记 2018-04-01
  • 学习笔记(2)

    学习笔记

    Linux笔记 2018-04-01
  • shell脚本编程示例

    #!/usr/bin/expectspawn scp /etc/fstab 192.168.8.100:/appexpect {“yes/no” { send “yes\n”;exp_continue }“password” { send “magedu\n” }}expec…

    2018-05-12
  • 路由设置

    路由

    Linux笔记 2018-05-05