pxe自动化部署Linux系统

实验准备:虚拟机centos 7

需要部署:DHCP服务器,TFTP服务器,HTTP服务器

准备工作

[root@centos771 tftpboot]# yum -y install tree# 关闭防火墙
[root@centos771 ~]# systemctl stop firewalld
[root@centos771 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: inactive (dead) since Thu 2020-09-10 12:45:23 CST; 6s agoDocs: man:firewalld(1)Process: 633 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)Main PID: 633 (code=exited, status=0/SUCCESS)Sep 05 21:55:02 centos771 systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 05 21:55:03 centos771 systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 10 12:45:22 centos771 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 10 12:45:23 centos771 systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@centos771 ~]# # 禁用selinux
1、临时修改
[root@centos771 ~]# setenforce 0
[root@centos771 ~]# getenforce
Permissive2、永久修改,需要重启
[root@centos771 ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled   #---将enforcing修改为disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

1、HTTP服务器

[root@centos771 ~]# yum -y install httpd[root@centos771 ~]# systemctl start httpd
[root@centos771 ~]# systemctl status httpd
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)Active: active (running) since Thu 2020-09-10 12:44:52 CST; 11min agoDocs: man:httpd(8)man:apachectl(8)Main PID: 12492 (httpd)Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"CGroup: /system.slice/httpd.service├─12492 /usr/sbin/httpd -DFOREGROUND├─12502 /usr/sbin/httpd -DFOREGROUND├─12503 /usr/sbin/httpd -DFOREGROUND├─12504 /usr/sbin/httpd -DFOREGROUND├─12505 /usr/sbin/httpd -DFOREGROUND└─12506 /usr/sbin/httpd -DFOREGROUNDSep 10 12:44:40 centos771 systemd[1]: Starting The Apache HTTP Server...
Sep 10 12:44:46 centos771 httpd[12492]: AH00558: httpd: Could not reliably determine the server's fully qualified domain na...message
Sep 10 12:44:52 centos771 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos771 ~]# # 挂载光盘文件到HTTP的共享文件里
[root@centos771 ~]# mkdir -p /var/www/html/centos/7/[root@centos771 ~]# mount /dev/sr0 /var/www/html/centos/7/
mount: /dev/sr0 is write-protected, mounting read-only
[root@centos771 ~]# ls /var/www/html/centos/7/
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL
[root@centos771 ~]# [root@centos771 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:10:96:2e brd ff:ff:ff:ff:ff:ffinet 10.0.0.71/24 brd 10.0.0.255 scope global noprefixroute ens32valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe10:962e/64 scope link valid_lft forever preferred_lft forever
[root@centos771 ~]# # 通过浏览器访问该IP地址文件路径
http://10.0.0.71/centos/7/

2、kickstart应答文件

# 使用的连接方式是通过**Xshell 7 + Xmanager**进行连接,需要下载xmanager
[root@centos771 ~]# yum -y groupinstall  "X Window System" "Fonts"# 新开窗口-属性-隧道-选中'转发X11'-选择'Xmanager'-连接
WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Thu Sep 10 11:53:36 2020 from 10.0.0.1
[root@centos771 ~]# 

部署应答文件,安装图形工具

[root@centos771 ~]# yum -y install system-config-kickstart
[root@centos771 ~]# export DISPLAY=10.0.0.1:0.0 # 主机IP

# 启动
[root@centos771 ~]# system-config-kickstart















应答文件放到HTTP共享文件夹里

[root@centos771 ~]# ls
anaconda-ks.cfg  ks.cfg
[root@centos771 ~]# mkdir /var/www/html/ksdir
[root@centos771 ~]# cp ks.cfg /var/www/html/ksdir/ks7.cfg
[root@centos771 ~]# ls /var/www/html/ksdir/
ks7.cfg
[root@centos771 ~]# [root@centos771 ~]# vim /var/www/html/ksdir/ks7.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
#ignoredisk --only-use=sda
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext 123456
# System language
lang en_US.UTF-8
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --enable
# SELinux configuration
selinux --disabled# Do not configure the X Window System
skipx# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=ens33
network  --hostname=centos7
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://10.0.0.71/centos/7"
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="xfs" --ondisk=sda --size=1024
part / --fstype="xfs" --ondisk=sda --size=10240
part /data --fstype="xfs" --ondisk=sda --size=51200[root@centos771 ~]# 

3、TFTP服务器

[root@centos771 ~]# yum -y install tftp-server
[root@centos771 ~]# systemctl start tftp
[root@centos771 ~]# systemctl status tftp
● tftp.service - Tftp ServerLoaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)Active: active (running) since Thu 2020-09-10 12:34:10 CST; 8s agoDocs: man:in.tftpdMain PID: 12304 (in.tftpd)CGroup: /system.slice/tftp.service└─12304 /usr/sbin/in.tftpd -s /var/lib/tftpbootSep 10 12:34:10 centos771 systemd[1]: Started Tftp Server.
[root@centos771 ~]# # /var/lib/tftpboot/ # 此路径是TFTP服务器的共享文件路径
[root@centos771 ~]# cd /var/lib/tftpboot/
[root@centos771 tftpboot]#

4、pxe引导文件

# 安装提供引导文件的软件包
[root@centos771 ~]# yum -y install syslinux# pxelinux.0文件路径
[root@centos771 ~]# rpm -ql syslinux | grep pxelinux
/usr/share/doc/syslinux-4.05/pxelinux.txt
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/gpxelinuxk.0
/usr/share/syslinux/pxelinux.0
[root@centos771 ~]# # 拷贝pxe引导文件到TFTP共享文件目录下
[root@centos771 ~]# cd /var/lib/tftpboot/
[root@centos771 tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
[root@centos771 tftpboot]# ls
pxelinux.0

5、DHCP服务器

# 安装并启动服务
[root@centos771 ~]# yum -y install dhcp# 启动服务,查看报错信息
[root@centos771 ~]# systemctl start dhcpd
Job for dhcpd.service failed because the control process exited with error code. See "systemctl status dhcpd.service" and "journalctl -xe" for details.
[root@centos771 ~]# [root@centos771 ~]# systemctl status dhcpd.service
● dhcpd.service - DHCPv4 Server DaemonLoaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)Active: failed (Result: exit-code) since Thu 2020-09-10 11:26:56 CST; 1min 22s agoDocs: man:dhcpd(8)man:dhcpd.conf(5)Process: 2528 ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid (code=exited, status=1/FAILURE)#  /etc/dhcp/dhcpd.conf  > dhcp 配置文件Main PID: 2528 (code=exited, status=1/FAILURE)Sep 10 11:26:56 centos771 dhcpd[2528]: All rights reserved.
Sep 10 11:26:56 centos771 dhcpd[2528]: For info, please visit https://www.isc.org/software/dhcp/
Sep 10 11:26:56 centos771 dhcpd[2528]: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified ...ig file
Sep 10 11:26:56 centos771 dhcpd[2528]: Wrote 0 leases to leases file.
Sep 10 11:26:56 centos771 dhcpd[2528]:
Sep 10 11:26:56 centos771 dhcpd[2528]: No subnet declaration for ens32 (10.0.0.71).
Sep 10 11:26:56 centos771 systemd[1]: dhcpd.service: main process exited, code=exited, status=1/FAILURE
Sep 10 11:26:56 centos771 systemd[1]: Failed to start DHCPv4 Server Daemon.
Sep 10 11:26:56 centos771 systemd[1]: Unit dhcpd.service entered failed state.
Sep 10 11:26:56 centos771 systemd[1]: dhcpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos771 ~]# 

修改配置文件

[root@centos771 ~]# vim /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example# 根据提示信息查看文件#   see dhcpd.conf(5) man page
#[root@centos771 ~]# cat /usr/share/doc/dhcp*/dhcpd.conf.example
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
## option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;default-lease-time 600;
max-lease-time 7200;# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.subnet 10.152.187.0 netmask 255.255.255.0 {
}# This is a very basic subnet declaration.subnet 10.254.239.0 netmask 255.255.255.224 {range 10.254.239.10 10.254.239.20;option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.subnet 10.254.239.32 netmask 255.255.255.224 {range dynamic-bootp 10.254.239.40 10.254.239.60;option broadcast-address 10.254.239.31;option routers rtr-239-32-1.example.org;
}# A slightly different configuration for an internal subnet.
subnet 10.5.5.0 netmask 255.255.255.224 {range 10.5.5.26 10.5.5.30;option domain-name-servers ns1.internal.example.org;option domain-name "internal.example.org";option routers 10.5.5.1;option broadcast-address 10.5.5.31;default-lease-time 600;max-lease-time 7200;
}# Hosts which require special configuration options can be listed in
# host statements.   If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.host passacaglia {hardware ethernet 0:0:c0:5d:bd:95;filename "vmunix.passacaglia";server-name "toccata.fugue.com";
}# Fixed IP addresses can also be specified for hosts.   These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host fantasia {hardware ethernet 08:00:07:26:c0:a5;fixed-address fantasia.fugue.com;
}# You can declare a class of clients and then do address allocation
# based on that.   The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.class "foo" {match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}shared-network 224-29 {subnet 10.17.224.0 netmask 255.255.255.0 {option routers rtr-224.example.org;}subnet 10.0.29.0 netmask 255.255.255.0 {option routers rtr-29.example.org;}pool {allow members of "foo";range 10.17.224.10 10.17.224.250;}pool {deny members of "foo";range 10.0.29.10 10.0.29.230;}
}
[root@centos771 ~]# 
# 复制
[root@centos771 ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@centos771 ~]# vim /etc/dhcp/dhcpd.conf
[root@centos771 ~]# vim /etc/dhcp/dhcpd.conf# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
## option definitions common to all supported networks...
option domain-name "baidu.org";  # 设置dhcp域名
option domain-name-servers 114.114.114.114, 8.8.8.8; # 设置DNSdefault-lease-time 3600;  # 设置分配的IP有效时间
max-lease-time 72000;     # 设置最大的有效时间# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.# ---- 设置dhcp的ip,子网掩码
subnet 10.0.0.0 netmask 255.255.255.0 {range 10.0.0.50 10.0.0.100;  # 分配的IP范围option broadcast-address 10.0.0.2;  # 网关next-server 10.0.0.71;  # 指定TFTP的IPfilename "pxelinux.0";  # 指定pxelinux引导文件路径
}
..........
:.,$s/^\([^#]\)/#\1/  # 注释掉不需要的代码

重启并监控日志

[root@centos771 ~]# systemctl restart dhcpd
[root@centos771 ~]# systemctl status dhcpd
● dhcpd.service - DHCPv4 Server DaemonLoaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)Active: active (running) since Thu 2020-09-10 11:51:52 CST; 10s agoDocs: man:dhcpd(8)man:dhcpd.conf(5)Main PID: 2558 (dhcpd)Status: "Dispatching packets..."CGroup: /system.slice/dhcpd.service└─2558 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pidSep 10 11:51:52 centos771 dhcpd[2558]: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified ...ig file
Sep 10 11:51:52 centos771 dhcpd[2558]: Internet Systems Consortium DHCP Server 4.2.5
Sep 10 11:51:52 centos771 dhcpd[2558]: Copyright 2004-2013 Internet Systems Consortium.
Sep 10 11:51:52 centos771 dhcpd[2558]: All rights reserved.
Sep 10 11:51:52 centos771 dhcpd[2558]: For info, please visit https://www.isc.org/software/dhcp/
Sep 10 11:51:52 centos771 dhcpd[2558]: Wrote 0 leases to leases file.
Sep 10 11:51:52 centos771 dhcpd[2558]: Listening on LPF/ens32/00:0c:29:10:96:2e/10.0.0.0/24
Sep 10 11:51:52 centos771 dhcpd[2558]: Sending on   LPF/ens32/00:0c:29:10:96:2e/10.0.0.0/24
Sep 10 11:51:52 centos771 systemd[1]: Started DHCPv4 Server Daemon.
Sep 10 11:51:52 centos771 dhcpd[2558]: Sending on   Socket/fallback/fallback-net
Hint: Some lines were ellipsized, use -l to show in full.# 监控日志
[root@centos771 ~]# tail -f /var/lib/dhcpd/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.2.5server-duid "\000\001\000\001&\354_N\000\014)\020\226.";

6、TFTP服务器部署相关文件

# 部署开机菜单页面
[root@centos771 ~]# cd /var/lib/tftpboot/
[root@centos771 tftpboot]# mkdir pxelinux.cfg
[root@centos771 tftpboot]# ls
pxelinux.0  pxelinux.cfg
[root@centos771 tftpboot]# [root@centos771 tftpboot]# ls /var/www/html/centos/7/isolinux/
boot.cat  grub.conf   isolinux.bin  memtest     TRANS.TBL     vmlinuz
boot.msg  initrd.img  isolinux.cfg  splash.png  vesamenu.c32
# 拷贝菜单文件并重命名
[root@centos771 tftpboot]# cp /var/www/html/centos/7/isolinux/isolinux.cfg pxelinux.cfg/default# 部署背景图片
[root@centos771 tftpboot]# cp /var/www/html/centos/7/isolinux/splash.png .# 拷贝内核文件
[root@centos771 tftpboot]# cp /var/www/html/centos/7/isolinux/vmlinuz .# 拷贝驱动文件
[root@centos771 tftpboot]# cp /var/www/html/centos/7/isolinux/initrd.img .# 拷贝图形模块
[root@centos771 tftpboot]# cp /var/www/html/centos/7/isolinux/vesamenu.c32 .[root@centos771 tftpboot]# ll
total 60548
-rw-r--r--. 1 root root 55073584 Sep 10 14:22 initrd.img
-rw-r--r--. 1 root root    26759 Sep 10 12:38 pxelinux.0
drwxr-xr-x. 2 root root       21 Sep 10 14:16 pxelinux.cfg
-rw-r--r--. 1 root root      186 Sep 10 14:20 splash.png
-rw-r--r--. 1 root root   153104 Sep 10 14:22 vesamenu.c32
-rwxr-xr-x. 1 root root  6734016 Sep 10 14:21 vmlinuz
[root@centos771 tftpboot]# tree
.
├── initrd.img    # 驱动文件
├── pxelinux.0    # pxe引导文件
├── pxelinux.cfg
│   └── default   # 菜单文件
├── splash.png    # 菜单背景图片
├── vesamenu.c32  # 菜单图形模块
└── vmlinuz       # 内核文件1 directory, 6 files
[root@centos771 tftpboot]# # 修改菜单文件
[root@centos771 tftpboot]# vim pxelinux.cfg/default
default vesamenu.c32
timeout 600menu background splash.png
menu title CentOS 7label auto linuxmenu label ^Install CentOS 7kernel vmlinuzappend initrd=initrd.img ks=http://10.0.0.71/ksdir/ks7.cfglabel manualmenu label Test this ^media & install CentOS 7menu defaultkernel vmlinuzappend initrd=initrd.img inst.repo=http://10.0.0.71/centos/7/# 救援模式
label rescuemenu label ^Rescue a CentOS Linux systemkernel vmlinuzappend initrd=initrd.img inst.repo=http://10.0.0.71/centos/8/ rescue# 默认启动已安装好的系统
label localmenu default      #默认启动硬盘,防止系统被重装menu label Boot from ^local drivelocalboot 0xffff

重启服务器

[root@centos771 tftpboot]# systemctl restart httpd
[root@centos771 tftpboot]# systemctl restart dhcpd
[root@centos771 tftpboot]# systemctl restart tftp

测试




注意:报错信息

报错1:

Warning: deu/root does not exist
Generating "run/initramfs/rdsosreport .txt"
Entering emergency mode. Exit the shell to cotinue.
Tupe "journa lctl" to uieu sustem logs .
You might uant to saue "rruninitranfs/rdsosreport.txt" to a USB stick or /boot
after mounting them and attach it to a bug report.

解决方法:编辑虚拟机----内存---- > 2G

说明:centos7和8需要虚拟内存最少2G

在启动界面按esc进入,选择网络安装

7、部署三个操作系统

步骤:

1、centos7安装HTTP服务器,添加6,7,8的镜像文件并挂载到HTTP共享文件下面# 插入centos6,7,8光盘
[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan ;echo "- - -" > /sys/class/scsi_host/host1/scan;echo "- - -" > /sys/class/scsi_host/host2/scan    #读取插入的光盘
[root@centos7 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0    2G  0 part [SWAP]
├─sda4   8:4    0    1K  0 part
└─sda5   8:5    0   50G  0 part /data
sr0     11:0    1  3.7G  0 rom
sr1     11:1    1    7G  0 rom
sr2     11:2    1  4.4G  0 rom  [root@centos7 ~]# yum -y install httpd;systemctl enable --now httpd   #安装httpd服务,并开启[root@centos771 ~]# ls /var/www/html/centos/
6  7  8
[root@centos771 ~]# ls /var/www/html/centos/6
CentOS_BuildTag  GPL       Packages                  RPM-GPG-KEY-CentOS-6           RPM-GPG-KEY-CentOS-Testing-6
EFI              images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBL
EULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6
[root@centos771 ~]# ls /var/www/html/centos/7
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL
[root@centos771 ~]# ls /var/www/html/centos/8
AppStream  BaseOS  EFI  images  isolinux  media.repo  TRANS.TBL
[root@centos771 ~]# 2、分别将各个已安装好的虚拟机root目录下的.cfg文件上传到centos7共享文件下
[root@centos771 tftpboot]# tree /var/www/html/ksdir/
/var/www/html/ksdir/
├── ks6.cfg
├── ks7.cfg
└── ks8.cfg[root@centos771 ~]# cat /var/www/html/ksdir/ks6.cfg
# Kickstart file automatically generated by anaconda.#version=DEVEL
install
lang en_US.UTF-8
url --url=http://10.0.0.71/centos/6/
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$cbCNviUY4I7g6x0Q$QOKb7MkJFg8X/U6DcfrR4ESroVOdn6jg7eVzAjTRUrQ.yU4BRc65/4n8kt8qgbqT/wqrUdF1GW8uH48U/y06y/
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --none
zerombr
clearpart --all --initlabel
part /boot --fstype=ext4 --size=1024
part / --fstype=ext4 --size=50000
part /data --fstype=ext4 --size=30000
part swap --size=2048
#part /boot --fstype=ext4 --size=1000
#part / --fstype=ext4 --size=10000
#part /data --fstype=ext4 --size=10000#part swap --size=2000#repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100%packages
@base
@core
@fonts
@server-policy
@workstation-policy
@x11
%end%post
useradd wang
echo magedu | passwd --stdin wang &> /dev/null
%end# ks7.cfg
[root@centos771 ~]# cat /var/www/html/ksdir/ks7.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
#ignoredisk --only-use=sda
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext 123456
# System language
lang en_US.UTF-8
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --enable
# SELinux configuration
selinux --disabled# Do not configure the X Window System
skipx# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=ens33
network  --hostname=centos7
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://10.0.0.71/centos/7"
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="xfs" --ondisk=sda --size=1024
part / --fstype="xfs" --ondisk=sda --size=10240
part /data --fstype="xfs" --ondisk=sda --size=51200# ks8.cfg
[root@centos771 ~]# cat /var/www/html/ksdir/ks8.cfg
#version=RHEL8
ignoredisk --only-use=sda
text
reboot
zerombr# Partition clearing information
clearpart --all --initlabel
# Use graphical install
#graphical
#repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
# Use CDROM installation media
#cdrom
url --url=http://10.0.0.71/centos/8/BaseOS/
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8# Network information
network  --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate
network  --hostname=centos82
# Root password
rootpw --iscrypted $6$LZaB7kO7I1RVA56J$6njSqc3wvnnggpCfwI.ddXXeCuNkcO6At1ZYq6VX4cmLA5RAS2ntakjbwR87Aejao.e7NPw0oocfXqLrw6D1a1
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --name=centos80 --password=$6$h8UwxiZ9B2DrU40P$2FJZEGwh2lJOaDV6LzGI7e69FIPEwoB.qQDAiDEzkh4kF.1CUKgG5ySaTnukdV8uGlVbQMOGrjR9yyRgL//nO1 --iscrypted --gecos="centos80"
# Disk partitioning information
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024%packages
@^minimal-environment
kexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end%post
useradd mage
echo magedu | passwd --stdin mage &> /dev/null
%end3、安装DHCP服务器,并修改配置文件[root@centos771 ~]# cat /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
## option definitions common to all supported networks...
option domain-name "baidu.org";
option domain-name-servers 114.114.114.114, 8.8.8.8;default-lease-time 3600;
max-lease-time 72000;# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.subnet 10.0.0.0 netmask 255.255.255.0 {range 10.0.0.50 10.0.0.100;option broadcast-address 10.0.0.2;next-server 10.0.0.71;filename "pxelinux.0";
}4、安装pxelinux
yum -y install syslinux
# pxelinux.0文件路径
[root@centos771 ~]# rpm -ql syslinux | grep pxelinux
/usr/share/doc/syslinux-4.05/pxelinux.txt
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/gpxelinuxk.0
/usr/share/syslinux/pxelinux.0   <----5、安装TFTP服务器
创建相关目录及拷贝相关文件
[root@centos771 ~]# cd /var/lib/tftpboot/
[root@centos771 tftpboot]# tree
.
├── centos6
│   ├── initrd.img
│   └── vmlinuz
├── centos7
│   ├── initrd.img
│   └── vmlinuz
├── centos8
│   ├── initrd.img  # 驱动文件
│   └── vmlinuz     # 内核文件
├── ldlinux.c32    --
├── libcom32.c32     | # 此三个文件是CentOS8安装所必须文件
├── libutil.c32    --
├── pxelinux.0      # pxe引导文件
├── pxelinux.cfg
│   └── default     # 菜单设置文件
├── splash.png      # 背景图片
├── splash.png.1
└── vesamenu.c32    # 图形模块4 directories, 11 files
-----------------------------------------------------------
#以下三个文件是CentOS8安装所必须文件,CentOS6,7则不需要
[root@centos8 ~]#cp /var/www/html/centos/8/os/x86_64/isolinux/{ldlinux.c32,libcom32.c32,libutil.c32} /var/lib/tftpboot/
-----------------------------------------------------------[root@centos771 tftpboot]# cat pxelinux.cfg/default
default vesamenu.c32
timeout 600menu background splash.png
menu title CentOS label auto linuxmenu label ^Install CentOS 6kernel centos6/vmlinuzappend initrd=centos6/initrd.img ks=http://10.0.0.71/ksdir/ks6.cfg label auto linuxmenu label ^Install CentOS 7kernel centos7/vmlinuzappend initrd=centos7/initrd.img ks=http://10.0.0.71/ksdir/ks7.cfglabel auto linuxmenu label ^Install CentOS 8kernel centos8/vmlinuzappend initrd=centos8/initrd.img ks=http://10.0.0.71/ksdir/ks8.cfg# 救援模式光盘启动
label rescuemenu label ^Rescue a CentOS Linux systemkernel centos8/vmlinuzappend initrd=centos8/initrd.img inst.repo=http://10.0.0.8/centos/8/ rescue quiet# yum源仓库路径# 超时默认启动已安装好的系统
label localmenu defaultmenu label Boot from ^local drivelocalboot 0xffff

pxe自动化部署Linux系统相关推荐

  1. PXE实现批量部署linux系统

    pxe批量部署linux服务器 1.pxe介绍 PXE是有intel设计的协议,它可以使计算机通过网络启动,协议分为client和server两端,PXEclient在网卡的ROM中,当计算机引导时, ...

  2. windows pxe 安装linux,菜鸟学Linux 第103篇笔记 pxe自动化安装linux

    菜鸟学Linux 第103篇笔记 pxe自动化安装linux 内容总览 linux的系统安装 kickstart文件的组成部分 DHCP (Dynamic Host Configuration Pro ...

  3. 用Kickstart批量安装Linux系统、Kickstart安装,linux批量安装;Linux的Kickstart的 无人值守安装;linux pxe自动安装linux系统...

    用Kickstart批量安装Linux|Kickstart,批量安装:Linux的Kickstart的 无人值守安装:linux pxe自动安装linux系统: KickStart + DHCP + ...

  4. Kickstart+HTTP+DHCP+TFTP全自动批量安装部署Linux系统

    说明: Kickstart服务器系统:CentOS 6.5 64位 IP地址:192.168.0.250 需要安装部署的Linux系统:CentOS 6.5 64位 eth0(第一块网卡,用于外网)I ...

  5. DHCP、PXE自动化部署操作系统、DNS正向解析、NFC共享目录服务--(程序员心碎的一天,碎了的自行粘上)

    DHCP.PXE自动化部署操作系统.DNS正向解析.NFC共享目录服务--(程序员心碎的一天,碎了的自行粘上 一.实验准备 二.实验要求 三.实验过程 1.配置DHCP (1).修改虚拟网络编辑器 ( ...

  6. 【云原生之Docker实战】使用Docker部署Linux系统监控平台Netdata

    [云原生之Docker实战]使用Docker部署Linux系统监控平台Netdata 一.Netdata介绍 1.netdata简介 2.netdatar特点 二.检查本地Docker环境 1.宿主机 ...

  7. 海康sdk项目部署Linux系统时出现java.lang.UnstisfiedLinkError:jnidispatch(xxx)not found in resource path错误

    海康sdk项目部署Linux系统时出现java.lang.UnstisfiedLinkError:jnidispatch(xxx)not found in resource path错误 问题描述 解 ...

  8. ruoyi项目前后端分离版本部署-linux系统

    ruoyi项目前后端分离版本部署-linux系统 参考网址 ruoyi官网 https://doc.ruoyi.vip/ruoyi-vue/ https://ruoyi.vip/ 参考文章网址 htt ...

  9. PXE+KickStart自动化安装Linux系统

     PXE+kickstart模式自动安装系统  PXE介绍 预启动执行环境(Preboot eXecution Environment,PXE)也被称为预执行环境,提供了一种使用网络接口(Netw ...

最新文章

  1. Javascript 的addEventListener()及attachEvent()区别分析
  2. 关于Webpack详述系列文章 (第四篇)
  3. Eclipse导入import sun.misc.BASE64Decoder报错的解决办法
  4. C语言经典例11-斐波那契数列
  5. 【数据结构作业—01】用单循环链表解决约瑟夫问题
  6. Java多线程(五)之BlockingQueue深入分析
  7. 20155212 2017-2018-1 《信息安全系统设计》第8周课下作业
  8. oracle销售服务器吗,oracle 服务器 版本
  9. 交换机MAC地址学习和转发数据帧的原理
  10. python没有那个文件或目录_fatal error: Python.h: 没有那个文件或目录 解决方法
  11. Delphi XE10编写的《开放式公路收费系统》
  12. java String类 常用函数
  13. LAMP架构(apache安装,apache工作原理介绍)
  14. fedora mysql gui,fedora 14 启用无线网卡 | 勤奋的小青蛙
  15. HTML“计算机输出”标签 codekbdsampttvarpre
  16. 我用python分析了李子柒的辣酱真的好吃吗?
  17. mac 卸载 安装mysql_Mac 卸载与安装mysql
  18. 0101到高低电平原理
  19. TCP连接握手为什么3次?断开为什么是4次?TCP的优化-SCTP协议
  20. 数学2600年,欧拉凭什么能当上“大王”?

热门文章

  1. 绝了!美图技术专家获取肉鸡服务器密码如探囊取物
  2. 计算机专业怎么防止脱发,电脑工作者如何防止脱发出现
  3. 在c++中,operator怎么使用
  4. camel标记法是什么方法
  5. 5G技术关键里程碑-3GPP Release 17标准完成
  6. 2017年由Unity员工打造的最爱
  7. 用汇编写的计算阶乘N!的程序
  8. WPF和Silverlight到底有什麼不同?
  9. 东财《社会学X》综合作业
  10. Windows 10 Build 21332:纯净安装移除 Paint 3D 应用