• Kylin-Server-V10 ARM64与LoongArch64 PXE无人值守安装


    1. 需求和环境

    需求:同时批量自动化安装Kylin-Server-V10 ARM64 和 LoongArch64版本操作系统,避免光盘缓慢的逐个安装


    2. 构建PXE安装服务器

    2.1 安装软件包

    先基于Kylin-Server-V10 ARM64安装一台系统,然后作为PXE服务器提供安装所需要的软件和服务,iso挂载到/mnt下:

    mount -o loop Kylin-Server-V10-GFB-Release-2204-Build03-ARM64.iso /mnt/
    
    • 1

    然后配置本地源:
    vim /etc/yum.repos.d/kylin_aarch64.repo

    ###Kylin Linux Advanced Server 10 - os repo###
    [ks10-adv-cdrom]
    name = Kylin Linux Advanced Server 10 - cdrom
    baseurl = file:///mnt
    gpgcheck = 0
    
    • 1
    • 2
    • 3
    • 4
    • 5

    安装软件包tftp xinetd tftp-server vsftpd

    yum -y install xinetd dhcp tftp-server vsftpd
    
    • 1

    此处采用vsftpd作为存储镜像,后期云平台WEB需要用httpd,确保二者可共存

    2.2 配置dhcp

    修改dhcp配置文件,ipv4的编辑/etc/dhcp/dhcpd.conf,如下:

    #
    # DHCP Server Configuration file.
    #   see /usr/share/doc/dhcp-server/dhcpd.conf.example
    #   see dhcpd.conf(5) man page
    #
    
    ddns-update-style interim;
    ignore client-updates;
    authoritative;
    allow booting;
    allow bootp;
    allow unknown-clients;
    default-lease-time 21600;
    max-lease-time 43200;
    option pxe-system-type code 93 = unsigned integer 16;
    
    # internal subnet for my DHCP Server
    subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.101 192.168.0.200;
        option domain-name-servers 223.5.5.5;
        option routers 255.255.255.0;
        option broadcast-address 192.168.0.255; 
    
        # IP of PXE Server
        next-server 192.168.0.10;
        if substring(option vendor-class-identifier, 0, 9) = "PXEClient" {
            if option pxe-system-type = 00:07 or pxe-system-type = 00:09 {
                filename "/X64/BOOTX64.EFI";
            } else if option pxe-system-type = 00:0b {
                filename "/ARM64/grubaa64.efi";
            } else if option pxe-system-type = 00:27 {
                filename "/LoongArch64/grubloongarch64.efi";
            }
        }
    #    filename "/ARM64/grubaa64.efi";
    #    filename "/LoongArch64/grubloongarch64.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

    配置完成后,重启服务systemctl restart dhcpd

    通过pxe-system-type选项可以指定x64、ARM64和LoongArch64使用不同的引导文件,07和09为x64 UEFI;0b为ARM UEFI;27为LoongArch64的UEFI。
    在客户端下租约文件在/var/lib/dhclient/dhclient.leases;在服务器端的租约文件在/var/lib/dhcpd/dhcpd.leases,pxe-system-type可以通过查看/var/lib/dhcpd/dhcpd.leases获取,如下:

    lease 192.168.0.101 {
      starts 4 2022/08/25 01:47:58;
      ends 4 2022/08/25 07:47:58;
      tstp 4 2022/08/25 07:47:58;
      cltt 4 2022/08/25 01:47:58;
      binding state free;
      hardware ethernet 52:54:00:ed:b5:77;
      uid "\000\302\020eO\302\300\316K\207y\321\355\205\331\327\016";
      set vendor-class-identifier = "PXEClient:Arch:00011:UNDI:003000";
    }
    lease 192.168.0.103 {
      starts 4 2022/08/25 01:48:38;
      ends 4 2022/08/25 07:48:38;
      tstp 4 2022/08/25 07:48:38;
      cltt 4 2022/08/25 02:16:44;
      binding state free;
      hardware ethernet 52:54:00:b4:6e:8d;
      uid "\0007\301\254\201yCAA\237\033\323~z\305\316\312";
      set vendor-class-identifier = "PXEClient:Arch:00039:UNDI:003000";
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    其中PXEClient:Arch:00039是通过十进制显示,需要转成成十六进制写入/etc/dhcp/dhcpd.conf pxe-system-type字段指定。

    在ARM64下,ISO中的BOOTAA64.EFI和grubaa64.efi是一样的,任选其中之一即可,在LoongArch64下ISO里面自带的BOOTLOONGARCH.EFI存在问题,需要替换为自己编译的grubloongarch64.efi

    配置文件主要参数介绍:

    option domain-name "example.org"; //指定网域的域名
    option domain-name-servers ns1.example.org, ns2.example.org; //指定域名解析服务器(DNS)的ip地址。
    default-lease-time 600; //默认租约时间,单位为s
    max-lease-time 7200; //最大租约时间,单位为s。过期续约,续约直接发送request包即可。
    log-facility local7; //日志设备类型为local7.一般日志设备类型包括mail、crontab。通过此选项可以找到该服务的日志记录路径
    subnet 192.168.0.0 netmask 255.255.255.0 { //指定分配网段的ip地址以及子网掩码,括号内部为局部配置。
    range 192.168.0.101 192.168.0.200; //可使用的地址池范围
    option domain-name-servers ns1.internal.example.org; //该网段的域名,可以省略
    option domain-name "internal.example.org"; //网段DNS
    option routers 255.255.255.0; //指定网关
    option broadcast-address 192.168.0.255; //指定广播地址
    default-lease-time 600; //租约时间
    max-lease-time 7200; //最大租约时间。
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    绑定MAC地址和IP,如下:

    host compute1{
            hardware ethernet 2C:97:B1:C7:F3:6A;
             fixed-address 192.168.0.101;
    }
    host compute2{
            hardware ethernet b8:59:9f:bd:f7:92;
             fixed-address 192.168.0.102;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    2.3 配置TFTP

    修改TFTP配置文件,将disable改为no即可。默认情况下TFTP服务是禁用的编辑文件/etc/xinetd.d/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
    {
            socket_type             = dgram
            protocol                = udp
            wait                    = yes
            user                    = root
            server                  = /usr/sbin/in.tftpd
            server_args             = -s /var/lib/tftpboot
            disable                 = no
            per_source              = 11
            cps                     = 100 2
            flags                   = IPv4
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    拷贝ARM64镜像引导文件:

    mkdir -p /var/lib/tftpboot/ARM64
    cp -av /mnt/images/pxeboot/* /var/lib/tftpboot/ARM64
    cp -av /mnt/EFI/BOOT/grub*.efi  /var/lib/tftpboot/ARM64
    cp -av /mnt/EFI/BOOT/*.EFI /var/lib/tftpboot/ARM64
    
    • 1
    • 2
    • 3
    • 4

    拷贝LoongArch64镜像引导文件:

    mkdir -p /var/lib/tftpboot/LoongArch64
    cp -av /mnt/images/pxeboot/* /var/lib/tftpboot/LoongArch64
    cp -av /mnt/EFI/BOOT/*.EFI /var/lib/tftpboot/LoongArch64
    cp -av grubloongarch64.efi /var/lib/tftpboot/LoongArch64
    
    • 1
    • 2
    • 3
    • 4

    由于LoongArch64 grubloongarch64.efi仅支持80MB以内的引导文件,initrd文件过大(超过了80MB),报error: out of memory,通过解压重新用算法lzma压缩后小于80MB,如下:

    mkdir initrd
    cp initrd.img initrd/
    cd initrd/
    mv initrd.img initrd.xz
    xz -d initrd.xz
    cat initrd | cpio -idmv
    rm -rf initrd
    find . 2>/dev/null | cpio -o -c | xz -9 --format=lzma > ../initrd.img
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    关闭防火墙,SELINUX:

    systemctl stop firewalld
    systemctl disable firewalld
    setenforce 0
    
    • 1
    • 2
    • 3

    重启服务:

    systemctl restart xinetd
    systemctl restart tftp
    
    • 1
    • 2

    验证tftp是否正常下载:

    tftp 192.168.0.10
    tftp> get ARM64/grubaa64.efi
    tftp> quit
    
    • 1
    • 2
    • 3

    然后查看是否下载,成功下载说明tftp配置正常。

    2.4 配置vsftpd

    将ARM64 ISO镜像所有文件拷贝至vsftpd服务器:

    mkdir /var/ftp/pub/Kylin-Server-V10-ARM64
    cd /mnt
    cp -rv * /var/ftp/pub/Kylin-Server-V10-ARM64
    cp .discinfo .kyinfo .kylin-ks.cfg .kylin-post-actions .kylin-post-actions-nochroot .productinfo .treeinfo /var/ftp/pub/Kylin-Server-V10-ARM64
    
    • 1
    • 2
    • 3
    • 4

    将LoongArch64ISO镜像所有文件拷贝至vsftpd服务器:

    mkdir /var/ftp/pub/Kylin-Server-V10-LoongArch64
    cd /mnt
    cp -rv * /var/ftp/pub/Kylin-Server-V10-LoongArch64
    cp .discinfo .kyinfo .kylin-ks.cfg .kylin-post-actions .treeinfo /var/ftp/pub/Kylin-Server-V10-LoongArch64
    
    • 1
    • 2
    • 3
    • 4

    修改vsftpd配置文件,编辑/etc/vsftpd/vsftpd.conf,修改如下:

    anonymous_enable=YES
    
    • 1

    这里我们仅需要开启匿名访问即可,其他的高级参数暂且不用,若有需要可以参考参考文献中的链接。
    重启服务:

    systemctl restart vsftpd
    systemctl enable vsftpd
    
    • 1
    • 2

    通过浏览器输入ftp://192.168.0.10/pub可以匿名正常访问,且点击文件可以正常查看或者下载,说明vsftpd配置正常。

    2.5 配置ks.cfg文件

    ARM64的在/var/ftp/pub/Kylin-Server-V10-ARM64/目录下,已经有一份.kylin-ks.cfg,重命名为kylin-ks.cfg,略作修改,内容如下:

    #version=DEVEL
    # Use graphical install
    # 安装时使用图形化安装,亦可采用字符界面text
    graphical
    # 设置安装系统
    install
    # 设置安装源
    url --url=ftp://192.168.0.10/pub/Kylin-Server-V10-ARM64
    # Keyboard layouts
    # 设置键盘布局为cn
    keyboard --vckeymap=cn --xlayouts='cn'
    # System language
    # 设置系统语言
    lang zh_CN.UTF-8
    
    # Network information
    # 设置网卡和主机名等信息
    network  --bootproto=dhcp
    network  --hostname=localhost.localdomain
    # Root password
    # 设置root密码,根据实际情况变更密码
    rootpw --plaintext ******
    # X Window System configuration information
    xconfig  --startxonboot
    # Run the Setup Agent on first boot
     # 系统第一次引导时,启动"设置代理"。需要安装额外的工具包,关闭即可
    firstboot --disable
    # 关闭selinux
    selinux --disabled
    # 关闭防火墙
    firewall --disabled
    # System services
    # 启用chrony来同步时间
    services --enabled="chronyd"
    
    # 安装完成后自动重启
    reboot
    # System timezone
    # 设置时区
    timezone Asia/Shanghai --isUtc
    
    # 自动寻找磁盘进行系统安装
    # 删除硬盘上的所有分区并初始化磁盘标签
    %include /tmp/partition
    %pre
    # pick first drive that is not removable
    SYS_DIR="/sys/block"
    ROOT_DRIVE=""
    
    # sd: SCSI disk
    # hd: IDE disk
    # vd: virtio disk
    for dev in $SYS_DIR/sd? $SYS_DIR/hd? $SYS_DIR/vd?
    do
        if [ -d $dev ]; then
            REMOVABLE=$(cat $dev/removable)
            if [ "$REMOVABLE" = "0" ]; then
                ROOT_DRIVE=${dev##*/}
                break
            fi
        fi
    done
    
    # if there is no non-removable drive, pick the first drive that
    # is not the installation media
    if [ "$ROOT_DRIVE" = "" ]; then
        REPO=$(mount | grep "/run/install/repo" | awk '{print $1}')
        for dev in /dev/sd? /dev/hd? /dev/vd?
        do
            if ! [[ $REPO =~ ${dev}[0-9]+ ]]; then
                ROOT_DRIVE=${dev##*/}
                break
            fi
        done
    fi
    
    cat << EOF > /tmp/partition
    ignoredisk --only-use=$ROOT_DRIVE
    autopart --type=lvm
    clearpart --all --initlabel --drives=$ROOT_DRIVE
    EOF
    %end
    
    %post
    
    systemctl disable systemd-networkd-wait-online.service
    systemctl disable multipathd.service
    systemctl disable libvirtd.service
    
    #####copy kyinfo and LICENSE
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-ARM64/.kyinfo --random-wait --directory-prefix /etc/
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-ARM64/LICENSE --random-wait --directory-prefix /etc/
    
    ## copy kylin post scripts in new os, do kylin post action
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-ARM64/.kylin-post-actions --random-wait --directory-prefix /bin
    /bin/bash -x /bin/.kylin-post-actions &> /var/log/.kylin-post-actions.log
    
    ## copy and run .kylin-post-actions-nochroot
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-ARM64/.kylin-post-actions-nochroot --random-wait --directory-prefix /tmp
    /bin/bash -x /tmp/.kylin-post-actions-nochroot &> /var/log/.kylin-post-actions-nochroot.log
    
    # 配置ssh无密码登陆
    mkdir -p /root/.ssh/
    cat > /root/.ssh/id_rsa << EOF
    ******
    EOF
    
    cat > /root/.ssh/id_rsa.pub << EOF
    ******
    EOF
    
    cat >  /root/.ssh/authorized_keys << EOF
    ******
    EOF
    
    chmod 600  /root/.ssh/id_rsa 
    chmod 600 /root/.ssh/authorized_keys
    
    %end
    
    
    # Environment groups,通过repodata/xxxxxxxxxx-comps.xml可以查看
    # minimal-environment  最小安装
    # minimal-desktop-environment 最小图形系统
    # server-product-environment 基础服务器
    # kylin-desktop-environment 工作站(带有用于配置服务和开发的 UKUI GUI 的服务器。)
    
    %packages
    @^kylin-desktop-environment
    kexec-tools
    # 添加需要安装的包
    wget
    %end
    
    %addon com_redhat_kdump --disable --reserve-mb='auto'
    
    %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
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143

    LoongArch64的在/var/ftp/pub/Kylin-Server-V10-LoongArch64/目录下,已经有一份.kylin-ks.cfg,重命名为kylin-ks.cfg,略作修改,内容如下:

    #version=DEVEL
    # Use graphical install
    # 安装时使用图形化安装,亦可采用字符界面text
    graphical
    # 设置安装系统
    install
    # 设置安装源
    url --url=ftp://192.168.0.10/pub/Kylin-Server-V10-LoongArch64
    # Keyboard layouts
    # 设置键盘布局为cn
    keyboard --vckeymap=cn --xlayouts='cn'
    # System language
    # 设置系统语言
    lang zh_CN.UTF-8
    
    # Network information
    # 设置网卡和主机名等信息
    network  --bootproto=dhcp
    network  --hostname=localhost.localdomain
    # Root password
    # 设置root密码
    rootpw --plaintext ******
    # X Window System configuration information
    xconfig  --startxonboot
    # Run the Setup Agent on first boot
     # 系统第一次引导时,启动"设置代理"。需要安装额外的工具包,关闭即可
    firstboot --disable
    # 关闭selinux
    selinux --disabled
    # 关闭防火墙
    firewall --disabled
    # System services
    # 启用chrony来同步时间
    services --enabled="chronyd"
    
    # 安装完成后自动重启
    reboot
    # System timezone
    # 设置时区
    timezone Asia/Shanghai --isUtc
    
    # 自动寻找磁盘进行系统安装
    # 删除硬盘上的所有分区并初始化磁盘标签
    %include /tmp/partition
    %pre
    # pick first drive that is not removable
    SYS_DIR="/sys/block"
    ROOT_DRIVE=""
    
    # sd: SCSI disk
    # hd: IDE disk
    # vd: virtio disk
    for dev in $SYS_DIR/sd? $SYS_DIR/hd? $SYS_DIR/vd?
    do
        if [ -d $dev ]; then
            REMOVABLE=$(cat $dev/removable)
            if [ "$REMOVABLE" = "0" ]; then
                ROOT_DRIVE=${dev##*/}
                break
            fi
        fi
    done
    
    # if there is no non-removable drive, pick the first drive that
    # is not the installation media
    if [ "$ROOT_DRIVE" = "" ]; then
        REPO=$(mount | grep "/run/install/repo" | awk '{print $1}')
        for dev in /dev/sd? /dev/hd? /dev/vd?
        do
            if ! [[ $REPO =~ ${dev}[0-9]+ ]]; then
                ROOT_DRIVE=${dev##*/}
                break
            fi
        done
    fi
    
    cat << EOF > /tmp/partition
    ignoredisk --only-use=$ROOT_DRIVE
    autopart --type=lvm
    clearpart --all --initlabel --drives=$ROOT_DRIVE
    EOF
    %end
    
    %post
    
    systemctl disable systemd-networkd-wait-online.service
    systemctl disable multipathd.service
    systemctl disable libvirtd.service
    systemctl disable iscsi.service
    systemctl disable iscsid.socket
    
    
    #####copy kyinfo and LICENSE
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-LoongArch64/.kyinfo --random-wait --directory-prefix /etc/
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-LoongArch64/LICENSE --random-wait --directory-prefix /etc/
    
    ## copy kylin post scripts in new os, do kylin post action
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-LoongArch64/.kylin-post-actions --random-wait --directory-prefix /bin
    /bin/bash -x /bin/.kylin-post-actions &> /var/log/.kylin-post-actions.log
    
    ## copy and run .kylin-post-actions-nochroot
    wget ftp://192.168.0.10/pub/Kylin-Server-V10-LoongArch64/.kylin-post-actions-nochroot --random-wait --directory-prefix /tmp
    /bin/bash -x /tmp/.kylin-post-actions-nochroot &> /var/log/.kylin-post-actions-nochroot.log
    
    # 配置ssh无密码登陆
    mkdir -p /root/.ssh/
    cat > /root/.ssh/id_rsa << EOF
    ******
    EOF
    
    cat > /root/.ssh/id_rsa.pub << EOF
    ******
    EOF
    
    cat > /root/.ssh/authorized_keys << EOF
    ******
    EOF
    
    
    chmod 600  /root/.ssh/id_rsa
    chmod 600 /root/.ssh/authorized_keys
    
    %end
    
    
    # Environment groups,通过repodata/xxxxxxxxxx-comps.xml可以查看
    # minimal-environment  最小安装
    # minimal-desktop-environment 最小图形系统
    # server-product-environment 基础服务器
    # kylin-desktop-environment 工作站(带有用于配置服务和开发的 UKUI GUI 的服务器。)
    
    %packages
    @^kylin-desktop-environment
    kexec-tools
    # 添加需要安装的包
    wget
    %end
    
    %addon com_redhat_kdump --disable --reserve-mb='auto'
    
    %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
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147

    若通过python库调用的话,这里面涉及的ssh key需要转换下格式:ssh-keygen -p -m PEM -f ~/.ssh/id_rsa或者生成key时添加-m PEM,ssh-keygen -m PEM -t rsa

    手动分区如下:

     # 清除硬盘分区表
    zerombr
    # 删除硬盘上的所有分区并初始化磁盘标签               
    clearpart --all --initlabel         
    
    #UEFI引导,必须指定efi分区且分区的类型必须是efi,挂载到/boot/efi
    #size的单位: M --fstype是指定文件系统类型,例如:ext4、xfs
    part /boot/efi --fstype="efi" --ondisk=sda --size=1024 --fsoptions="defaults,uid=0,gid=0,umask=0077,shortname=winnt"
    part /boot --fstype="ext4" --size=1024
    part swap --fstype="swap" --size=8192
    part / --fstype="xfs" --size=102400
    # 分区使用全部空闲磁盘空间,如下
    # part / --fstype="xfs" --grow --size=1
    
    #基于LVM分区
    part /boot/efi --fstype="efi" --ondisk=sda --size=1024 --fsoptions="defaults,uid=0,gid=0,umask=0077,shortname=winnt"
    part /boot --fstype="ext4" --size=1024
    part klas --size=1 --grow
    volgroup klas00  klas
    logvol swap --vgname=swap --size=8192 --fstype="swap" --name=swap
    logvol / --vgname=root --size=1 --grow --fstype="xfs" --name=root
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    2.6 配置grub.cfg文件

    ARM64的grub编辑/var/lib/tftpboot/ARM64/grub.cfg,可参考EFI/BOOT/grub.cfg的内容,修改如下:

    set default="0"
    
    function load_video {
      if [ x$feature_all_video_module = xy ]; then
        insmod all_video
      else
        insmod efi_gop
        insmod efi_uga
        insmod ieee1275_fb
        insmod vbe
        insmod vga
        insmod video_bochs
        insmod video_cirrus
      fi
    }
    
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    
    set timeout=10
    ### END /etc/grub.d/00_header ###
    
    
    search --no-floppy --set=root -l 'KYLIN10-SVR'
    
    ### BEGIN /etc/grub.d/10_linux ###
    menuentry 'Install Kylin Linux Advanced Server V10 ARM64 From Network' --class red --class gnu-linux --class gnu --class os {
            set root=(tftp,192.168.0.10)
            linux /ARM64/vmlinuz inst.ks=ftp://192.168.0.10/pub/Kylin-Server-V10-ARM64/kylin-ks.cfg ro console=tty0 console=ttyS0,11520
            initrd /ARM64/initrd.img
    }
    
    menuentry "Kylin Linux Advanced Server V10 ARM64 From Disk"  {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_gpt
            insmod xfs
            set root='hd0,gpt2'
            linux   /vmlinuz-4.19.90-25.10.v2101.ky10.aarch64 root=/dev/mapper/klas-root ro rd.lvm.lv=klas/root rd.lvm.lv=klas/swap console=tty0 console=ttyS0,11520
            initrd /initramfs-4.19.90-25.10.v2101.ky10.aarch64.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
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46

    LoongArch64的grub编辑/var/lib/tftpboot/LoongArch64/grub.cfg,可参考EFI/BOOT/grub.cfg的内容,修改如下:

    set default="0"
    
    function load_video {
      if [ x$feature_all_video_module = xy ]; then
        insmod all_video
      else
        insmod efi_gop
        insmod efi_uga
        insmod ieee1275_fb
        insmod vbe
        insmod vga
        insmod video_bochs
        insmod video_cirrus
      fi
    }
    
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    
    set timeout=10
    ### END /etc/grub.d/00_header ###
    
    search --no-floppy --set=root -l 'KYLIN10-SVR'
    
    ### BEGIN /etc/grub.d/10_linux ###
    menuentry 'Install Kylin Linux Advanced Server V10 LoongArch64 From Network' --class red --class gnu-linux --class gnu --class os {
            set root=(tftp,192.168.0.10)
            linux /LoongArch64/vmlinuz inst.ks=ftp://192.168.0.10/pub/Kylin-Server-V10-LoongArch64/kylin-ks.cfg ro console=tty0 console=ttyS0,11520
            initrd /LoongArch64/initrd.img.new
    }
    
    menuentry "Kylin Linux Advanced Server V10 LoongArch64 From Disk"  {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_gpt
            insmod ext2
            set root='hd0,gpt2'
            echo    'Loading Linux 4.19.90-23.19.v2101.a.ky10.loongarch64 ...'
            linux   /vmlinuz-4.19.90-23.19.v2101.a.ky10.loongarch64 root=/dev/mapper/klas-root ro rd.lvm.lv=klas/root rd.lvm.lv=klas/swap console=ttyS0,11520 quiet
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-4.19.90-23.19.v2101.a.ky10.loongarch64.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
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47

    3.系统安装

    服务器启动选择通过网络启动安装(一般按F12选择网络引导)即可,如下图进入网络安装界面:
    ARM64:
    在这里插入图片描述

    LoongArch64:
    在这里插入图片描述


    4. 问题记录

    • No subnet declaration for enp6s0f0
    systemctl status dhcpd
    ● dhcpd.service - DHCPv4 Server Daemon
       Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
       Active: active (running) since Tue 2022-08-02 08:53:18 CST; 4s ago
         Docs: man:dhcpd(8)
               man:dhcpd.conf(5)
     Main PID: 3779296 (dhcpd)
       Status: "Dispatching packets..."
        Tasks: 1
       Memory: 13.7M
       CGroup: /system.slice/dhcpd.service
               └─3779296 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid
    
    8月 02 08:53:18 controller1 dhcpd[3779296]:
    8月 02 08:53:18 controller1 dhcpd[3779296]:
    8月 02 08:53:18 controller1 dhcpd[3779296]: No subnet declaration for enp6s0f0 (172.19.0.10).
    8月 02 08:53:18 controller1 dhcpd[3779296]: ** Ignoring requests on enp6s0f0.  If this is not what
    8月 02 08:53:18 controller1 dhcpd[3779296]:    you want, please write a subnet declaration
    8月 02 08:53:18 controller1 dhcpd[3779296]:    in your dhcpd.conf file for the network segment
    8月 02 08:53:18 controller1 dhcpd[3779296]:    to which interface enp6s0f0 is attached. **
    8月 02 08:53:18 controller1 dhcpd[3779296]:
    8月 02 08:53:18 controller1 dhcpd[3779296]: Sending on   Socket/fallback/fallback-net
    8月 02 08:53:18 controller1 dhcpd[3779296]: Server starting service.
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    物理机拥有多个带地址网卡引起的,配置dhcp所用的网卡即可,解决方案如下:
    vim /etc/sysconfig/dhcpd
    DHCPDARGS=enp4s0f0


    5. 参考文献

    https://www.cnblogs.com/easonscx/p/10724742.html
    https://bbs.huaweicloud.com/forum/thread-64622-1-1.html
    https://blog.51cto.com/u_14442495/2905867
    https://blog.csdn.net/aiynmimi/article/details/77012507
    https://www.cpci.dev/pxe-the-batch-deployment/

  • 相关阅读:
    【尚硅谷 Vue学习笔记】P14事件处理 P13事件修饰符 p16键盘事件 p17事件总结
    新晋国产证书品牌——JoySSL
    十四天学会C++之第八天:文件操作
    JAVA语法技术课第1课day01_Java基础语法&HelloWorld
    java+ssm基于微信小程序的高校新生自助报到迎新系统 uniapp 小程序
    【Unity】2D角色跳跃控制器
    Spring Cloud Contract 入门
    动态新增、修改Logback的Appender(可实现动态调整日志级别,Appender参数)
    找回共享盘里被误删文件的几种方法
    【linux】从linux学软件开发 | 变量与echo
  • 原文地址:https://blog.csdn.net/nanhai_happy/article/details/126369724