用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

相关推荐

  • DNS服务

    DNS

    Linux笔记 2018-07-19
  • 实验:正向主DNS实现 实验:反向解析DNS 实验:从DNS服务器实现

    实验:正向主DNS实现实验:反向解析DNS 实验:从DNS服务器实现 在主服务器vim /etc/named.confallow-transfer { slaveip;}; 加此行从服务器vim /etc/named.confallow-transfer { none;}; 加此行 vim /etc/named.rfc1912.zoneszone &#822…

    Linux笔记 2018-06-01
  • HTTP服务和APACHE

    http协议 Httpd介绍 Htdtpd2.2配置 Httpd2.4配置 编译安装http

    Linux笔记 2018-06-19
  • linux练气篇二

    1.sort和cut的运用
    2.输出和追加输出
    3.用户及组的增,删,改权限

    Linux笔记 2018-05-29
  • 文件查找命令locate与find的对比分析

    文件查找命令locate与find的对比分析一、locate 1、locate命令是用来文件查找的命令,依赖于事先构建的索引。而索引的更新并不是实时的,而是每次开机启动或者管理员手动更新。因为是使用事先建立的索引库进行检索,所以会有以下特点: 1)查找速度快 2)模糊查找 3)非实时查找 4)搜索的是文件的全路径,不仅仅是文件名 5)可能之搜索用户具备读取和…

    Linux笔记 2018-04-14
  • N31-第二周作业—文件的管理

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。
    2、bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及其示例演示。
    3、请使用命令行展开功能来完成以下练习:
    (1)、创建/tmp目录下的:a_c, a_d, b_c, b_d
    (2)、创建/tmp/mylinux目录下的:
    mylinux/
    ├── bin
    ├── boot
    │   └── grub
    ├── dev
    ├── etc
    │   ├── rc.d
    │   │   └── init.d
    │   └── sysconfig
    │   └── network-scripts
    ├── lib
    │   └── modules
    ├── lib64
    ├── proc
    ├── sbin
    ├── sys
    ├── tmp
    ├── usr
    │   └── local
    │   ├── bin
    │   └── sbin
    └── var
    ├── lock
    ├── log
    └── run
    4、文件的元数据信息有哪些,分别表示什么含义,如何查看?如何修改文件的时间戳信息。
    5、如何定义一个命令的别名,如何在命令中引用另一个命令的执行结果?
    6、显示/var目录下所有以l开头,以一个小写字母结尾,且中间至少出现一位数字(可以有其它字符)的文件或目录。
    7、显示/etc目录下,以任意一个数字开头,且以非数字结尾的文件或目录。
    8、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录。
    9、在/tmp目录下创建以tfile开头,后跟当前日期和时间的文件,文件名形如:tfile-2016-05-27-09-32-22。
    10、复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
    11、复制/etc目录下所有以.d结尾的文件或目录至/tmp/mytest2目录中。
    12、复制/etc/目录下所有以l或m或n开头,以.conf结尾的文件至/tmp/mytest3目录中。

    Linux笔记 2018-07-05