用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 19:50
下一篇 2018-05-27 21:19

相关推荐

  • Linux 系统启动故障恢复

    如果你的Linux系统一直重启或者因为某些服务无法开启的问题导致机器故障不能正常使用,那我们就从系统启动模式来考虑,是不是/etc/inittab文件下默认被设置成为6模式,或者/etc/crontab文件中是否加入的能导致系统一直重启的命令,或者说在系统启动中因为一个服务一直打不开导致系统卡在服务启动界面而无法进入系统,那我们就来看看这些让人哭笑不得的问题怎么解决!

    2018-05-10
  • 一些常用的文本工具

    cat命令:查看文本内容 cat [选项]… [文件]… -E    显示行结束符 -n    显示文本内容时显示行号 -A    显示所以控制符 -b    非空行编号 -s     压缩连续的空行成一行 head命令 : -n  显示文件前n行,默认显示前10行 -c # 显示文件前#个字节内容 tail命令: tail [选项]…

    2018-04-09
  • 加密与安全

    加密与安全 SSH端口转发 SSH 会自动加密和解密所有 SSH 客户端与服务端之间的网络数据。但是,SSH 还能够将其他 TCP 端口的网络数据通过 SSH 链接来转发,并且自动提供了相应的加密及解密服务。这一过程也被叫做“隧道”(tunneling),这是因为 SSH 为其他 TCP 链接提供了一个安全的通道来进行传输而得名。例如,Telnet,SMTP…

    Linux笔记 2018-06-11
  • FTP服务介绍及相关实验

    FTP是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”。用于Internet上的控制文件的双向传输。FTP协议是早期的三个应用级协议之一。

    2018-06-26
  • Linux下history的用法

    Linux下history的用法 如果你经常使用Linux命令,那么使用history命令无疑会提升你的工作效率。history命令主要用于显示历史指令记录内容, 通过快捷键快速下达历史纪录中的指令, -c: 清空命令历史 清空内存中的历史记录 -d offset: 删除历史中指定的第offset个命令 例如 history -d 153 删除第153条记录…

    2018-04-01
  • 运维自动化之ansible

    ansible的基本架构 ​ host inventory主机清单 ​ playbook相当于脚本, ​ modules模块 ansible工作原理 ​ 通过执行命令,或ansible playbook,cmdb ansible配置文件 ​ /etc/ansible/ansible.cfg主配置文件,配置ansible工作特性 ​ /etc/ansible/…

    Linux笔记 2018-06-03