搭建PXE服务及实现安装银河麒麟高级服务器操作系统

一、安装PXE服务器前的准备

服务器操作系统:银河麒麟高级服务器操作系统V10 SP1

服务器IP地址:em1 172.17.31.163 用于连接外网,可以进行yum安装相关服务
em2 192.168.1.1 用于DHCP服务网段的配置

arm安装引导文件:grubaa64.efi(如果是其他架构平台,则需要更改该文件)

arm镜像文件:Kylin-Server-10-SP1-Release-Build04-20200711-arm64.iso

二、安装PXE服务

1、配置dhcp服务

(1)检查系统是否有dhcp服务,如果没有就通过yum install安装;

[root@localhost ~]# rpm -qa | grep dhcp

dhcp-4.3.6-37.ky10.x86_64

(2)修改dhcp配置文件dhcpd.conf;

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf

#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;

ddns-update-style none;

ignore client-updates;

option space PXE;

allow booting;

allow bootp;

class "pxeclients"{

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

    next-server 192.168.1.1; #此处为TFTP Server端的IP地址

    filename "uefi/grubaa64.efi"; #告诉TFTP目录下的bootstarp文件

}

subnet 192.168.1.0 netmask 255.255.255.0{ ## 定义子网

    range 192.168.1.2 192.168.1.200;#配置DHCP分配地址区间(地址池)

    option broadcast-address 192.168.1.255;#此处为DHCP服务的广播地址

    option routers 192.168.1.1;

    option subnet-mask 255.255.255.0;

}

2、配置tftp服务

(1)检查系统是否有tftp服务,如果没有通过yum install安装

[root@localhost ~]# rpm -qa | grep tftp

tftp-server-5.2-27.ky10.x86_64

syslinux-tftpboot-6.04-5.ky10.noarch

(2)修改tftp配置文件,将其状态改为启用状态

[root@localhost ~]# vim /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 -c  #tftp服务根目录

        disable                 = no  #no表明tftp处于启用状态

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}#默认disable状态为yes,需要改为no

(3)将arm镜像文件中casper/的initrd.lz和vmliuz拷贝到tftpboot/casper

[root@localhost tftpboot]# cd casper/

[root@localhost casper]# ls

initrd.lz  vmlinuz

[root@localhost casper]#

(4)在tftpboot目录下创建uefi文件夹,并创建grub.cfg文件;

[root@localhost tftpboot]# mkdir uefi

[root@localhost tftpboot]# cd uefi/

[root@localhost pxelinux.cfg]# vim grub.cfg # 修改linux内核引导文件

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

  #insmod all_video

  fi

}

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(x86_64)'

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

menuentry '1)Install Kylin Server V10SP1 0710 ARM' --class red --class gnu-linux --class gnu --class os {
linux casper/vmlinuz inst.stage2=http://192.168.1.1/arrch64-kylin/v10sp1 quiet inst.ks=http://192.168.1.1/arrch64-kylin/v10sp1/ks.cfg
initrd casper/initrd.img
}



}

(5)将arm的引导文件efi拷贝到uefi文件夹下

[root@localhost uefi]# ls
grubaa64.efi grub.cfg grubx64_desktop.efi grubx64.efi ldlinux.c32 mips pxelinux.0

(7)将tftpboot目录下的所有文件、目录添加777权限

3、配置http服务

(1)检查系统是否有http服务,如果没有通过yum install安装

[root@localhost ~]# rpm -qa | grep http
http-parser-help-2.9.2-2.ky10.noarch
httpd-tools-2.4.34-17.p02.ky10.x86_64
mod_http2-help-1.10.20-4.ky10.noarch
nghttp2-help-1.39.2-2.ky10.noarch
mod_http2-1.10.20-4.ky10.x86_64
httpd-2.4.34-17.p02.ky10.x86_64
libnghttp2-1.39.2-2.ky10.x86_64
httpd-filesystem-2.4.34-17.p02.ky10.noarch
[root@localhost ~]#

(2)在/var/www/html/创建相关iso文件目录

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ll
总用量 0
drwxrwxrwx 3 root root 20 1月 9 10:39 arrch64-kylin
drwxrwxrwx 3 root root 20 1月 25 10:52 mips64-kylin
drwxrwxrwx 3 root root 20 1月 9 10:39 x86_64-kylin
[root@localhost html]#

注:所有的目录及文件都要添加777权限

(3)将整个iso挂载后的内容对应拷贝到上述目录中。

注:隐藏文件和隐藏目录也需要拷贝。可以使用如下命令

[root@localhost /] cp -ar .* /var/www/html/arrch64-kylin/v10sp1

注:html下面所有文件及文件夹的权限都为777

三、编写自动安装系统脚本
将自动化安装系统脚本ks.cfg添加到http相关系统镜像文件下(ks.cfg负责引导自动化安装)

注:x86和arm的ks.cfg文件内容一致,mips的ks.cfg文件内容有一些更改

arm和x86的ks.cfg文件:

```powershell
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --startxonboot
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=cn --xlayouts='cn'
# Root password
rootpw --iscrypted $1$CtjaC3gR$wwKd6TWI6Kd4PndMa84/M.
# Use network installation
url --url="http://192.168.1.1/arrch64-kylin/v10sp1"
# System language
lang zh_CN
user --name=kylin --password=$6$M50j65Pr5.exzlyp$1Da/aWH2tpR4YLZxV/VO4fY06v8fvpd0CivRKMS6LmxtQEtHOppdvqWh0ZeZUfzfyrYeCc/IcGLI2AlTZ4xDp0 --iscrypted --gecos="kylin"
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled

# System services
services --enabled="chronyd"
ignoredisk --only-use=sda
# Firewall configuration
firewall --disabled
# Network information
#network --bootproto=dhcp --device=enp10s0f0
#network --bootproto=dhcp --device=enp10s0f1
#network --bootproto=dhcp --device=enp11s0f0
#network --bootproto=dhcp --device=enp11s0f1
network --bootproto=dhcp --device=enp11s0f1 --onboot=on

reboot
eula --agreed
# System timezone
timezone Asia/Shanghai
#network --bootproto=dhcp --device=enp11s0f0 --onboot=on
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part /boot --fstype="xfs" --size=1024
part /boot/efi --fstype="vfat" --size=512
part swap --fstype="swap" --size=4096
part / --fstype="xfs" --grow --size=1

%packages
@^kylin-desktop-environment

chrony
kexec-tools

%end

mips的ks.cfg文件:

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --startxonboot
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=cn --xlayouts='cn'
# Root password
rootpw --iscrypted $1$CtjaC3gR$wwKd6TWI6Kd4PndMa84/M.
# Use network installation
url --url="http://192.168.1.1/mips64-kylin/v10sp1"
# System language
lang zh_CN
user --name=kylin --password=$6$M50j65Pr5.exzlyp$1Da/aWH2tpR4YLZxV/VO4fY06v8fvpd0CivRKMS6LmxtQEtHOppdvqWh0ZeZUfzfyrYeCc/IcGLI2AlTZ4xDp0 --iscrypted --gecos="kylin"
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled

# System services
services --enabled="chronyd"
ignoredisk --only-use=sda
# Firewall configuration
firewall --disabled
# Network information
#network --bootproto=dhcp --device=enp10s0f0
#network --bootproto=dhcp --device=enp10s0f1
#network --bootproto=dhcp --device=enp11s0f0
#network --bootproto=dhcp --device=enp11s0f1
network --bootproto=dhcp --device=enp8s0f0 --onboot=on

reboot
eula --agreed
# System timezone
timezone Asia/Shanghai
#network --bootproto=dhcp --device=enp11s0f0 --onboot=on
# System bootloader configuration
#bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Clear the Master Boot Record
#zerombr
# System bootloader configuration
#bootloader --location=mbr --driveorder=sda
# Partition clearing information
#clearpart --all --initlabel
# Disk partitioning information
#part /boot --fstype="xfs" --size=1024
#part /boot/efi --fstype="vfat" --size=512
#part swap --fstype="swap" --size=4096

#part / --fstype="xfs" --grow --size=1

xconfig --startxonboot
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
clearpart --all --initlabel --drives=sda

%packages
@^kylin-desktop-environment

chrony
kexec-tools

%end

四、启动相关服务

systemctl start tftp

systemctl start dhcpd.service

systemctl start httpd.service

systemctl stop firewalld.service
  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值