银河麒麟服务器V10 SP2 PXE搭建及配置

  • Post author:
  • Post category:其他

1、前提

服务端:Kylin-Server-10-SP2-Release-Build09-20210524-x86_64

客户端:Kylin-Server-10-SP2-Release-Build09-20210524-x86_64

服务器IP:192.168.1.100

  1. 服务端搭建

2.1 nfs搭建

  • 安装nfs并修改配置文件

yum install -y nfs-utils

 

mkdir /V10SP2 /kickstart

 

echo -e “/V10SP2  *(insecure,rw,async,no_root_squash)\n/kickstart  *(insecure,rw,async,no_root_squash)” > /etc/exports

  • 将光盘挂载到 /mnt,并将 iso 中的文件拷贝到 /V10SP2中

mount xxx.iso /mnt

cp -avprf /mnt/* /V10SP2

chmod -R 777 /V10SP2

  • 编写ks脚本

vim /kickstart/ks.cfg

添加如下内容

#version=DEVEL

# X Window System configuration information

xconfig  –startxonboot

# License agreement

eula –agreed

# System authorization information

auth –enableshadow –passalgo=sha512

# Use CDROM installation media

nfs –server=192.168.1.100 –dir=/V10SP2

# Use graphical install

graphical

# Run the Setup Agent on first boot

firstboot –enable

# System services

services –enabled=”chronyd”

# Keyboard layouts

keyboard –vckeymap=us –xlayouts=’us’

# System language

lang zh_CN.UTF-8

ignoredisk –only-use=sda

# Network information

# Root password

rootpw –iscrypted $6$h8fkf.JIshjmaupc$uARnGcVUbdVaUjndEznoyNeIG5nbaOqnFHR5g.4jtBasbwLPflJ2EllcNrhXM6NRZS/xFriClROmwsLatwg2D1

# System timezone

timezone Asia/Shanghai –isUtc

# System bootloader configuration

#bootloader –append=” crashkernel=auto” –location=mbr –boot-drive=sda

# Partition clearing information

#clearpart –all –initlabel –drives=sda

# Disk partitioning information

#part / –fstype=”xfs” –ondisk=sda –size=51200

#part /boot –fstype=”xfs” –ondisk=sda –size=1024

#part /boot/efi –fstype=”efi” –ondisk=sda –size=200 –fsoptions=”umask=0077,shortname=winnt”

#part swap –fstype=”swap” –ondisk=sda –size=4096

#part /home –fstype=”xfs” –ondisk=sda –size=2689078

%packages

@^kylin-desktop-environment

%end

%addon com_redhat_kdump –enable –reserve-mb=1024M

%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

reboot

  • 启动 nfs

systemctl restart nfs.service

2.2 tftp和 xinetd 服务搭建

  • 安装 tftp 和 xinted 服务

yum install -y tftp-server xinetd

  • 修改 tftp 配置文件

vim /etc/xinetd.d/tftp

 

disable = yes 改为 no

  • 将光盘中的 grub.cfg,grubx64.efi,initrd.img,vmlinuz 拷贝到 /var/lib/tftpboot 目录下面

cp -avp /V10SP2/EFI/BOOT/grubx64.efi /var/lib/tftpboot

 

cp -avp /V10SP2/EFI/BOOT/grub.cfg /var/lib/tftpboot

 

cp -avp /V10SP2/images/pxeboot/{initrd.img,vmlinuz}  /var/lib/tftpboot/

  • 创建 UEFI 目录并赋权

mkdir /var/lib/tftpboot/UEFI

 

chmod -R 777 /var/lib/tftpboot/UEFI

  • 将光盘中的文件 grub.cfg,grubx64.efi,initrd.img,vmlinuz 拷贝到 /var/lib/tftpboot/UEFI

cp -avp /V10SP2/EFI/BOOT/grubx64.efi /var/lib/tftpboot/UEFI

 

cp -avp /V10SP2/EFI/BOOT/grub.cfg /var/lib/tftpboot/UEFI

 

cp -avp /V10SP2/images/pxeboot/{initrd.img,vmlinuz}  /var/lib/tftpboot/UEFI

  • 恢复 linux 上下文

cd /var/lib/tftpboot/UEFI && restorecon -v *

  • 修改grub.cfg 为如下

vim /var/lib/tftpboot/UEFI/grub.cfg

修改如下:

set default=”0″

function load_video {

  insmod efi_gop

  insmod efi_uga

  insmod video_bochs

  insmod video_cirrus

  insmod all_video

}

load_video

set gfxpayload=keep

insmod gzio

insmod part_gpt

insmod ext2

set timeout=60

### END /etc/grub.d/00_header ###

search –no-floppy –set=root -l ‘Kylin-Server-10’

### BEGIN /etc/grub.d/10_linux ###

menuentry ‘Install Kylin Linux Advanced Server V10’ –class fedora –class gnu-linux –class gnu –class os {

#   linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=Kylin-Server-10 quiet

#   initrdefi /images/pxeboot/initrd.img

        linuxefi vmlinuz inst.ks=nfs:192.168.1.100:/kickstart/ks.cfg  nvme_core.multipath=N

        initrdefi initrd.img

}

  • 重启 tftp 和 xinetd 服务

systemctl restart tftp.service

 

systemctl restart xinetd

2.3 dhcp 服务搭建

  • 安装 dhcp 服务

yum install -y dhcp

  • 配置dhcp 服务

vim /etc/dhcp/dhcpd.conf

内容如下

subnet 192.30.101.0 netmask 255.255.255.0{

    range 192.30.101.100 192.30.101.110;

    default-lease-time 6000;

    max-lease-time 7200;

    option time-offset -3600;

}

 

class “pxeclients”{

    match if substring(option vendor-class-identifier,0,9)=”PXEClient”;

    next-server 192.168.1.100;

    filename “UEFI/grubx64.efi”;

}

 

  • 开启 dhcp服务、关闭 selinux和防火墙

      systemctl restart dhcpd

 

setenforce 0

 

systemctl stop firwalld&& systemctl disable firewalld

3、客户端配置

  • 将待安装服务器与PXE服务器网线连接到同一个交换机,保证可以dhcp获取到IP。

  • 重启待安装服务器,修改启动顺序。选择从接有网线的接口从网络启动。

  • 重启客户端服务器会自动安装

备注:由于配置了kickstart。部分参数已经预配置系统无需人工干预,分区部分需要自定义,所有配置设置完成开始安装。安装完成后系统会自动重启,root用户默认密码qwer1234


版权声明:本文为yuchen008原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。