1、配置yum源
安装操作系统时我们选择的包不一定会含DHCP、TFTP、NFS服务,所以我们需要搭建yum源安装这些软件
====================
挂载光驱
====================
[[email protected] ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mkdir bak
[[email protected] yum.repos.d]# mv *.repo ./bak/
[[email protected] yum.repos.d]# vim base.repo
=========================
编辑base.repo文件,如下:
=========================
[base]
name=base
baseurl=file:///mnt/ #iso文件挂载在那个目录下这里写哪个目录,如挂载在/mnt/目录下,这里就是baseurl=file:///mnt/
enabled=1
gpgcheck=0
[[email protected] yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
...
Metadata Cache Created
2、安装软件
[[email protected] yum.repos.d]# yum install dhcp tftp xinetd tftp-server nfs-utils rpcbind -y
3、创建相关文件夹并copy相应的文件
[[email protected] dhcp]# mkdir -p /centos/centos76
[[email protected] dhcp]# cp /mnt/* /centos/centos76/
[[email protected] ~]# mkdir /var/lib/tftpboot/uefi
=============
提取shim.ufi
=============
[[email protected] ~]# cp /centos/centos76/Packages/shim-aa64-12-1.el7.aarch64.rpm /tm
[[email protected] ~]# cd /tmp
[[email protected] ~]# rpm2cpio shim-aa64-12-1.el7.aarch64.rpm |cpio -idmv
[[email protected] ~]# cp /tmp/boot/efi/EFI/redhat/shim.efi /var/lib/tftpboot/uefi/
[[email protected] ~]# cp /centos/centos76/EFI/BOOT/grubaa64.efi /var/lib/tftpboot/uefi/
[[email protected] ~]# cp /centos/centos76/images/pxeboot/vmlinuz /var/lib/tftpboot/uefi/
[[email protected] ~]# cp /centos/centos76/images/pxeboot/initrd.img /var/lib/tftpboot/uefi/
[[email protected] ~]# vim /var/lib/tftpboot/uefi/grub.cfg
set timeout=60
menuentry ‘CentOS 7‘ {
linux uefi/vmlinuz ip=dhcp inst.repo=nfs:9.43.3.1:/centos/centos76 inst.resolution=1024x768
initrd uefi/initrd.img
}
#inst.repo 为安装源路径,inst.resolution设置分辨率,ip=dhcp设置dhcp动态IP
=======================================
检查/var/lib/tftpboot/uefi/下的文件
=======================================
[[email protected] ~]# ls /var/lib/tftpboot/uefi/
grub.cfg grubaa64.efi initrd.img shim.efi vmlinuz
[[email protected] ~]# chmod 777 *
创建ks.cfg文件,将ks.cfg文件cp到/centos目录下并修改权限为777
4、配置文件
==================
配置DHCPD服务文件
==================
[[email protected] yum.repos.d]# vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
ignore client-updates;
default-lease-time 359200;
max-lease-time 800000;
next-server 9.43.3.1; #pxe源服务器的IP地址
subnet 9.43.0.0 netmask 255.255.0.0 { #subnet pxe dhcp分配的地址段 netmaskpxe dhcp分配的地址段掩码
range dynamic-bootp 9.43.3.100 9.43.200.250; #pxe dhcp可分配的地址
filename "uefi/shim.efi";
}
[[email protected] ~]# systenctl restart dhcpd
[[email protected] ~]# systenctl enable dhcpd
=============
配置tftp服务
=============
[[email protected] ~]# vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot/ -u nobody
disable = no #将yes改为no
per_source =11
cps =100 2
flags = IPv4
}
[[email protected] ~]# systenctl restart tftp
[[email protected] ~]# systenctl enable tftp
===========
配置NFS服务
===========
[[email protected] ~]# vim /etc/exports
/centos/ *(root_squash,crossmnt)
[[email protected] ~]# systenctl restart nfs
[[email protected] ~]# systenctl enable nfs
[[email protected] ~]# showmount -e localhost #验证nfs配置
Export list for localhost:
/centos *
5、关闭防火墙和SELINUX
[[email protected] ~]# systenctl stop firewalld
[[email protected] ~]# systenctl disable firewalld
[[email protected] ~]# vim /etc/sysconfig/selinux
SELINUX=disabled #将enforcing修改成disabled
原文:https://www.cnblogs.com/mrpangpang/p/12181528.html