当前位置:   article > 正文

Centos7.9搭建银河麒麟SP1系统PXE_如何搭建麒麟系统

如何搭建麒麟系统

一、环境准备
pxe-server 系统为CentOS 7.9
银河麒麟镜像名: Kylin-Server-10-SP1-Release-Build20-20210518-x86_64.iso
在这里插入图片描述

二、服务器部署
注意:配置环境之前请将防火墙关闭
在这里插入图片描述
1、安装DHCP、TFTP、XINETD、HTTPD 服务

yum install -y dhcp

yum install tftp xinetd tftp-server –y

yum install -y httpd
  • 1
  • 2
  • 3
  • 4
  • 5

三、配置文件查看
DHCP配置文件

cd /etc/dhcp/

cat dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Fri Sep 22 05:16:43 2023)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 192.168.40.0 netmask 255.255.255.0 {
     option routers             192.168.40.1;
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.254.0;
     range dynamic-bootp        192.168.40.10 192.168.40.250;   #dhcp地址池
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.40.1;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
     	  if option pxe-system-type = 00:06 {
                  filename "x86_uefi/BOOTX32.EFI";
          } else if option pxe-system-type = 00:07 {
                  filename "x86_uefi/BOOTX64.EFI";                 #引导方式
          } else if option pxe-system-type = 00:09 {
                  filename "x86_uefi/BOOTX64.EFI";
          }
	}

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

TFTP配置文件

cd /etc/xinetd.d/

cat tftp 
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        disable                 = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
        flags                   = IPv6
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

上传银河麒麟SP1镜像

ll -lh Kylin-Server-10-SP1-Release-Build20-20210518-x86_64.iso 
-rw-r--r-- 1 root root 4.3G Sep  6  2021 Kylin-Server-10-SP1-Release-Build20-20210518-x86_64.iso
  • 1
  • 2
 将镜像挂载到/mnt目录下
  • 1
mount Kylin-Server-10-SP1-Release-Build20-20210518-x86_64.iso /mnt
mount: /dev/loop1 is write-protected, mounting read-only

  • 1
  • 2
  • 3

进入/var/lib/tftpboot/

ls
BOOTIA32.EFI  BOOTX64.EFI         grub.cfg      grubx64.efi       mmia32.efi    TRANS.TBL
bootx64.efi     fonts             grubia32.efi    Kylin10-x86_64      mmx64.efi   
  • 1
  • 2
  • 3

mkdir -p x86_uefi/Kylin10-x86_64
cp -r /mnt/EFI/BOOT/* /var/lib/tftpboot/x86_uefi

ls
initrd.img  TRANS.TBL  vmlinuz

  • 1
  • 2
  • 3

创建grub.cfg文件

cat grub.cfg 
set default="1"
 
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=600
 
### END /etc/grub.d/00_header ###
 
#search --no-floppy --set=root -l 'CentOS 7 x86_64'
 
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Kylin-SP1-10' --class fedora --class gnu-linux --class gnu --class os {
linuxefi x86_uefi/Kylin10-x86_64/vmlinuz inst.ks=http://192.168.40.1/ks/kylin-ks.cfg  quiet
initrdefi x86_uefi/Kylin10-x86_64/initrd.img
}
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

HTTP配置文件

进入/var/www/html/目录下创建镜像目录
  • 1
mkdir Kylin10-x86_64

cp -r /mnt/* /var/www/html/Kylin10-x86_64

  • 1
  • 2
  • 3
  • 4

进入/var/www/html/目录下创建自动化部署脚本

mkdir ks

上传kickstart文件
cat kylin-ks.cfg 
# Use graphical install
#text
graphical
# Network information
network  --bootproto=dhcp --device=eth0 --ipv6=auto --no-activate
network  --bootproto=dhcp --device=eth1 --ipv6=auto
network  --bootproto=dhcp --hostname=localhost.localdomain
ignoredisk --only-use=sda
# Use CDROM installation media
#cdrom
url --url=http://192.168.40.1/os/Kylin10-x86_64
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
#skipx
# System services
services --enabled="chronyd"
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Root password
rootpw --iscrypted $6$3LZsXejR1giQk6ml$TkYHhy.HoyCGhiHdSq/Y6IdjumotR5GJh4iGxnGAMeOgJo6XgP0XOY4ijhV78UZqRHSgBVfCtRODAR8ZPRb2M1
user --name=engine --password=$6$q8RtE3y3UKCB48W1$bYzLUdMERoPW8r3R5N5eTeHJuRrFkoCRqKsUPGAjVTRl6W9HRWmI.alYosW8qrxln3uPxaHSKTOeS4Aj9w4ZU. --iscrypted --gecos="engine"
# System timezone
timezone Asia/Shanghai 
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
#autopart --type=lvm
part /boot --asprimary --fstype="ext4" --size=500 --ondisk=sda  
part /boot/efi --fstype="efi" --size=200 --fsoptions="umask=0077,shortname=winnt" --ondisk=sda
part swap --fstype="swap" --size=1024 --ondisk=sda
#part biosboot --fstype="BIOSboot" --size=1 --ondisk=sda
part / --fstype="ext4" --size=1 --ondisk=sda

# Partition clearing information
clearpart --all --initlabel

%post --nochroot
#####copy kyinfo and LICENSE
if [ -e /tmp/.kyinfo ];then
  echo y | cp -a /tmp/.kyinfo $ANA_INSTALL_PATH/etc/
fi
if [ -e /tmp/LICENSE ];then
  echo y | cp -a /tmp/LICENSE $ANA_INSTALL_PATH/etc/
fi
if [ -e /run/install/repo/.kyinfo ];then
  echo y | cp -a /run/install/repo/.kyinfo $ANA_INSTALL_PATH/etc/
fi
if [ -e /run/install/repo/LICENSE ];then
  echo y | cp -a /run/install/repo/LICENSE $ANA_INSTALL_PATH/etc/
fi

##### kylin postaction
## cdrom install, copy .kylin-post-actions
if [ -e /run/install/repo/.kylin-post-actions ];then
  echo y | cp -a /run/install/repo/.kylin-post-actions /tmp/.kylin-post-actions
  echo "repo=/run/install/repo" > /tmp/.kylin-repo
fi
## copy kylin post scripts in new os
if [ -e /tmp/.kylin-post-actions ];then
  echo y | cp -a /tmp/.kylin-post-actions $ANA_INSTALL_PATH/bin
fi
if [ -e /tmp/.kylin-repo ];then
  echo y | cp -a /tmp/.kylin-repo $ANA_INSTALL_PATH/tmp/
fi

## copy and run .kylin-post-actions-nochroot
if [ -e /run/install/repo/.kylin-post-actions-nochroot ];then
  echo y | cp -a /run/install/repo/.kylin-post-actions-nochroot /tmp/.kylin-post-actions-nochroot
fi
if [ -e /tmp/.kylin-post-actions-nochroot ];then
  /bin/bash -x /tmp/.kylin-post-actions-nochroot &> $ANA_INSTALL_PATH/var/log/.kylin-post-actions-nochroot.log
fi
%end

%post

systemctl disable systemd-networkd-wait-online.service
systemctl disable multipathd.service

### do kylin post action
if [ -e /bin/.kylin-post-actions ];then
  /bin/bash -x /bin/.kylin-post-actions &> /var/log/.kylin-post-actions.log
fi

%end

%packages
@^minimal-environment
@development
kexec-tools

%end

%addon ADDON_placeholder --enable --reserve-mb=1024M
%end

%anaconda
pwpolicy root --minlen=8 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=8 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=8 --minquality=1 --notstrict --nochanges --notempty
%end

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109

服务启动

systemctl restart dhcpd
systemctl restart tftp
systemctl restart xinetd
systemctl restart httpd
  • 1
  • 2
  • 3
  • 4

四、验证部署测试
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/857653
推荐阅读
相关标签
  

闽ICP备14008679号