安装方式
Loongnix Server 操作系统 发布件 包括 ISO 发布包和 repo 源。
镜像校验
从Loongnix Server镜像站点下载 ISO 镜像时,同下载路径将有一个同名的 .md5 文件,该文件内容为 ISO 镜像的 sha256sum 值。为了避免网络原因或者存储设备原因出现下载不完整的问题,请务必在下载 ISO 镜像之后核对文件校验值是否一致!
U盘安装简介
用户可使用 USB 盘(大于16G)安装Loongnix-Server系统。
如果用户有高速网络和U盘,可以选择从Loongnix镜像站点下载系统镜像,然后使用Windows/Linux制作镜像工具制作,Loongnix-Server系统可启动终端,使用dd命令进行镜像制作。
镜像制作命令如下:
dd if=镜像文件地址 of=/dev下识别的U盘设备 bs=8M && sync
镜像制作举例:
镜像文件为:/home/user/Loongnix-Server-23.2-loongarch64-dvd.iso
系统下识别的U盘设备: /dev/sdb (可通过fdisk -l或者lsblk命令查看)
镜像制作命令:dd if=/home/user/Loongnix-Server-23.2-loongarch64-dvd.iso of=/dev/sdb bs=8M && sync
PXE安装
1 PXE 简介
PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的一项便捷安装操作系统的技术。PXE工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像(images),并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端基本软件设置,从而引导预先安装在服务器中的终端操作系统。
要使用PXE安装,需要固件支持PXE启动模式,安装之前需要确认一下 固件是否支持PXE启动;开机后在UEFI BIOS中选择从网络启动。
2 PXE环境搭建
2.1 PXE启动目录设置
- 下载Loongnix Server 23.2的标准安装的ISO,下载地址如下:
https://pkg.loongnix.cn/loongnix-server/23.2/isos/Loongnix-Server-23.2-loongarch64-dvd.iso
注意:下载ISO之后必须要进行MD5值验证!
- 挂载 ISO 文件到 /mnt 目录
sudo mount Loongnix-Server-23.2-loongarch64-dvd.iso /mnt
- 创建PXE启动文件目录
mkdir -p /home/pxe
- 拷贝 ISO 中所有文件到 PXE 启动目录(包括隐藏文件)
注意:根据需要修改目录文件的权限,确保其他机器可以正常下载文件。
cp -a /mnt/. /home/pxe
- 在/home/pxe目录下新建一个ksdir文件夹,然后根据第5章ks文件示例创建符合自己要求的ks文件,放置到/home/pxe/ksdir目录下。
mkdir /home/pxe/ksdir
3 搭建PXE安装所需服务
3.1 配置TFTP服务
- 安装TFTP服务
root# yum install xinetd tftp-server tftp
- 增加配置文件 /etc/xinetd.d/tftp,内容参考如下:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /home/pxe -c -v
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
3.2 配置DHCP服务
- 安装DHCP服务
root# yum install dhcp-server
- 增加配置文件 /etc/dhcp/dhcpd.conf,内容参考如下:
#/etc/dhcp/dhcpd.conf 中的参考配置如下:
option domain-name "loongnix.org";
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.10.0 netmask 255.255.255.0 {
ignore-client-uids on;
next-server 192.168.10.1; #指向TFTP服务器地址
filename "EFI/BOOT/BOOTLOONGARCH.EFI"; #指向TFTP服务器上EFI文件位置
range 192.168.10.10 192.168.10.20;
option routers 192.168.10.1;
}
3.3 配置HTTP服务
- 安装HTTP服务
root# yum install httpd
- 配置HTTP服务
修改 httpd 配置文件 /etc/httpd/conf/httpd.conf 的 DocumentRoot 和 Directory 信息(默认目录为 /var/www/html,修改为: /home/pxe):
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/pxe"
#
# Relax access to content within /var/www.
#
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/home/pxe">
3.4 修改主机IP
上面安装完成后,需要将主机 IP 配置为内网 IP,如上面设置的 192.168.10.1。
[user@user ~]$ sudo nmcli connection add con-name wire-3 type ethernet ifname enp3s0 ip4 192.168.10.1/24
[sudo] user 的密码:
连接 "wire-3" (7cc4ec31-00e8-483d-8d24-f8aa04e4b638) 已成功添加。
[user@usern ~]$ sudo nmcli connection show
3.5 启动服务
- 启动DHCP服务
root# systemctl start dhcpd
- 启动TFTP服务
root# systemctl start xinetd
注意:使用 tftp 进行验证,确保 TFTP 服务正常可用!
- 启动HTTP服务
root# systemctl start httpd
注意:使用网页进行验证,确保 HTTP 服务正常可用!
- 关闭系统防火墙(或者配置相关规则)
root# systemctl stop firewalld
4 创建grub配置文件grub.cfg
grub.cfg放入 /home/pxe/EFI/loongnix-server中,grub.cfg参考配置内容如下:
注意:此处引用了 ks 配置文件,完成自动化安装。
set default="0"
set timeout=60
search --no-floppy --set=root -l 'Loongnix-Server-23.2-loongarch64'
echo -e "\nWelcome to Loongnix-Server 23.2 (loongarch64) Installer\n"
menuentry 'Install Loongnix-Server 23.2(PXE)' --class fedora --class gnu-linux --class gnu --class os {
echo 'Loading kernel ...'
linux images/pxeboot/vmlinuz ip=dhcp ks=http://192.168.100.1/ksdir/loongnix-server-23.2.ks inst.repo=http://192.168.100.1
echo 'Loading initrd ...'
initrd images/pxeboot/initrd.img
}
其中 inst.repo 后面的IP地址为 PXE 服务器的 IP 地址。
5 ks文件示例
# System authorization information
auth --enableshadow --passalgo=sha512
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.10.1/centos/8/"
# License agreement
eula --agreed
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network --hostname=192.168.10.1
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# Root password
rootpw --plaintext xxxxx
# System services
selinux --disabled
firewall --disabled
# System bootloader configuration
# bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda
clearpart --all
autopart
# Partition clearing information
%packages
@core
@standard
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
6 使用PXE批量自动安装 Loongnix Server 系统
将待安装系统的机器与搭建 PXE 服务的机器连接在同一局域网内。
在BIOS中设置机器开机启动顺序为网络优先,然后启动机器。
安装完成后,要断开机器的 PXE 环境,否则重启之后还是优先从 PXE 启动,继续执行安装系统的步骤!