PXE详解

TFTP文件配置
安装tftp-server tftp客户端并启动服务
[root@node4 ~]#yum -y install tftp-server tftp
[root@node4 ~]# systemctl start tftp.socket
[root@node4 ~]# ss -tunlp
Netid  State      Recv-Q Send-Q         Local Address:Port                        Peer Address:Port 
udp    UNCONN     0      0                         :::69                                    :::*                   users:(("systemd",pid=1,fd=136))
下载测试文件验证tftp服务是否正常
[root@node4 ~]# cd /tmp/
[root@node4 tmp]# tftp 192.168.10.9
tftp> get grub2.cfg
tftp> quit
[root@node4 tmp]# ls
grub2.cfg

dhcp文件配置
安装dhcp服务器,修改配置文件
[root@node4 ~]# yum -y install dhcpd
[root@node4 ~]# vi /etc/dhcp/dhcpd.conf
option domain-name "tom.com";
option routers 192.168.10.9;
option domain-name-servers 192.168.170.10;

default-lease-time 600;
max-lease-time 7200;
log-facility local7;
 
subnet 192.168.10.0 netmask 255.255.255.0 {
    range 192.168.10.10 192.168.10.20;
    filename "pxelinux.0";
    next-server 192.168.10.9;
}
启动dhcp服务
[root@node4 dhcp]# systemctl restart dhcpd
查看服务端口是否监听
[root@node4 dhcp]# ss -tunlp | grep :67
udp    UNCONN     0      0         *:67                    *:*                   users:(("dhcpd",pid=11322,fd=7))

挂载本地iso光盘镜像到/var/www/html/centos/7/x86_64下
[root@node4 ~]# mount -r /dev/cdrom /var/www/html/centos/7/x86_64
[root@node4 ~]# ls /var/www/html/centos/7/x86_64
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL


http服务配置
安装httpd服务,启动服务及监听的端口
[root@node4 ~]# yum -y install httpd
[root@node4 ~]# systemctl start httpd
[root@node4 ~]# ss -tunlp | grep 80
tcp    LISTEN     0      128      :::80                   :::*                   users:(("httpd",pid=11382,fd=4),("httpd",pid=11381,fd=4),("httpd",pid=11380,fd=4),("httpd",pid=11379,fd=4),("httpd",pid=11378,fd=4),("httpd",pid=11377,fd=4),("httpd",pid=8420,fd=4),("httpd",pid=8419,fd=4),("httpd",pid=8418,fd=4),("httpd",pid=8417,fd=4),("httpd",pid=8415,fd=4))

浏览器输入http://192.168.170.9/centos/7/x86_64


kickstart 文件制作

[root@node4 ~]#  mkdir /var/www/html/kickstarts/
[root@node4 ~]# vi /var/www/html/kickstarts/centos7.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig  --startxonboot
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'
# Root password
rootpw --iscrypted $1$J1l5IzTB$QzUs87Bx7I47bHGla96Qs1
# Use network installation
url --url="http://192.168.170.9/centos/7/x86_64/"
# System language
lang en_US
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --enforcing

# System services
services --disabled="chronyd"
ignoredisk --only-use=sda
# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=ens192
# Halt after installation
halt
# System timezone
timezone Asia/Shanghai --nontp
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=500
part swap --fstype="swap" --ondisk=sda --size=1536
part / --fstype="xfs" --ondisk=sda --size=28672

%packages
@base
@core
@desktop-debugging
@development
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11

%end

PXE文件制作

[root@node4 ~]# yum -y install syslinux
[root@node4 ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@node4 ~]# cp /var/www/html/centos/7/x86_64/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
[root@node4 ~]# cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot/
[root@node4 ~]# mkdir /var/lib/tftpboot/pxelinux.cfg/
[root@node4 ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
 prompt 5
 timeout 30
 MENU TITLE CentOS 7 PXE Menu

 LABEL linux
 MENU LABEL Install CentOS 7 x86_64
 KERNEL vmlinuz
 APPEND initrd=initrd.img inst.repo=http://192.168.10.9/centos/7/x86_64   ks=http://192.168.170.9/kickstarts/centos7.cfg

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值