华为TaiShan服务器PXE操作系统

1、配置yum源
安装操作系统时我们选择的包不一定会含DHCP、TFTP、NFS服务,所以我们需要搭建yum源安装这些软件

====================
挂载光驱
====================
[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo ./bak/
[root@localhost yum.repos.d]# vim base.repo

=========================
编辑base.repo文件,如下:
=========================
[base]
name=base
baseurl=file:///mnt/  #iso文件挂载在那个目录下这里写哪个目录,如挂载在/mnt/目录下,这里就是baseurl=file:///mnt/
enabled=1
gpgcheck=0

[root@localhost yum.repos.d]# yum makecache 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
...
Metadata Cache Created

2、安装软件
[root@localhost yum.repos.d]# yum install dhcp tftp xinetd tftp-server nfs-utils rpcbind -y

3、创建相关文件夹并copy相应的文件
[root@localhost dhcp]# mkdir -p /centos/centos76
[root@localhost dhcp]# cp /mnt/* /centos/centos76/
[root@localhost ~]# mkdir /var/lib/tftpboot/uefi
=============
提取shim.ufi
=============
[root@localhost ~]# cp /centos/centos76/Packages/shim-aa64-12-1.el7.aarch64.rpm /tm
[root@localhost ~]# cd /tmp
[root@localhost ~]# rpm2cpio shim-aa64-12-1.el7.aarch64.rpm |cpio -idmv
[root@localhost ~]# cp /tmp/boot/efi/EFI/redhat/shim.efi /var/lib/tftpboot/uefi/
[root@localhost ~]# cp /centos/centos76/EFI/BOOT/grubaa64.efi /var/lib/tftpboot/uefi/
[root@localhost ~]# cp /centos/centos76/images/pxeboot/vmlinuz /var/lib/tftpboot/uefi/
[root@localhost ~]# cp /centos/centos76/images/pxeboot/initrd.img /var/lib/tftpboot/uefi/
[root@localhost ~]# 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/下的文件
=======================================
[root@localhost ~]# ls /var/lib/tftpboot/uefi/
grub.cfg grubaa64.efi initrd.img shim.efi vmlinuz
[root@localhost ~]# chmod 777 *

创建ks.cfg文件,将ks.cfg文件cp到/centos目录下并修改权限为777

4、配置文件
==================
配置DHCPD服务文件
==================
[root@localhost 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";
}
[root@localhost ~]# systenctl restart dhcpd
[root@localhost ~]# systenctl enable dhcpd

=============
配置tftp服务
=============
[root@localhost ~]# 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
}
[root@localhost ~]# systenctl restart tftp
[root@localhost ~]# systenctl enable tftp

===========
配置NFS服务
===========
[root@localhost ~]# vim /etc/exports
/centos/  *(root_squash,crossmnt)          
[root@localhost ~]# systenctl restart nfs
[root@localhost ~]# systenctl enable nfs
[root@localhost ~]# showmount -e localhost    #验证nfs配置
Export list for localhost:
/centos *

5、关闭防火墙和SELINUX
[root@localhost ~]# systenctl stop firewalld
[root@localhost ~]# systenctl disable firewalld
[root@localhost ~]# vim /etc/sysconfig/selinux
SELINUX=disabled #将enforcing修改成disabled

猜你喜欢

转载自www.cnblogs.com/mrpangpang/p/12181528.html