天天看點

華為伺服器清空pxe配置檔案,華為TaiShan伺服器PXE作業系統(示例代碼)

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