uos系统PXE搭建原理和过程
1.1.1 dnsmasq 方式
1.1.1.1 安装dnsmasq
/# sudo apt-get install dnsmasq
1.1.1.2 修改配置文件
/# sudo vim /etc/dnsmasq.conf
Listen-address=192.168.1.1
interface=enp5s0 // 要使用的网卡节点
bind-interfaces
dhcp-range=192.168.1.10,192.168.1.100,255.255.255.0,8h
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.1
dhcp-option=28,192.168.1.255
dhcp-option=42,0.0.0.0
enable-tftp
dhcp-match=set:Intel_x86PC,option:client-arch,0
dhcp-boot=tag:Intel_x86PC,x86_64-legacy/pxelinux.0
dhcp-match=set:EFI_BC,option:client-arch,7
dhcp-boot=tag:EFI_BC,x86_64-efi/netbootx64.efi
dhcp-match=set:EFI_x86_64,option:client-arch,9
dhcp-boot=tag:EFI_x86_64,x86_64-efi/netbootx64.efi
dhcp-match=set:EFI_Arm64,option:client-arch,11
dhcp-boot=tag:EFI_Arm64,arm64-efi/netbootaa64.efi
dhcp-match=set:Mips,option:client-arch,12
tftp-root=/var/lib/tftpboot // -----提前建好目录
1.1.1.3 tftpd 中的文件放置
创建tftp 根目录
/# mkdir /var/lib/tftpboot
arm64.tar.gz //---- 已经 获得
如果目标安装机器为新四核或者鲲鹏,则将arm64.tar.gz 解压出来的
arm64-efi 目录拷贝至tftp 根目录下;并将系统iso 中casper/下的initrd.img 和Image
放到arm64-efi/casper 下。
请注意对应修改boot/grub/grub.cfg 或pxelinux.cfg/default 或KlConfig.cfg 或
pxelinux.0 或者grub2/grub.cfg 中nfsroot 的IP 地址!
1.1.1.4 启动dnsmasq 服务
/# sudo systemctl restart dnsmasq
查看服务状态:
/# systemctl status dnsmasq
security=
1.1.2 tftp+dhcp 方式
1.1.2.1 tftp 服务器搭建
安装tftp 相关包:
/# sudo apt-get install tftp-hpa tftpd-hpa
修改配置文件:
将/var/lib/tftpboot 设为tftp 的根目录
/# vim /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"
如果目标安装机器为新四核或者鲲鹏,则将arm64.tar.gz 解压出来的
arm64-efi 目录拷贝至tftp 根目录下;并将iso 中casper/下的initrd.img 和Image
放到arm64-efi/casper 下。
请注意对应修改boot/grub/grub.cfg 或pxelinux.cfg/default 或KlConfig.cfg 或
pxelinux.0 或者grub2/grub.cfg 中nfsroot 的IP 地址!
重启服务:
/# sudo systemctl restart tftpd-hpa
1.1.2.2 tftp 测试
以arm64-efi/netbootaa64.efi 为例:
/# tftp 127.0.0.1
>get /var/lib/tftpboot/arm64
-efi/netbootaa64.efi
>quit
查看获取的文件,不报错且文件大小正常,则说明配置成功。
/# ll netbootaa64.efi
-rw-rw-r-- 1 kylin kylin 1958400 5 月13 15:36 netbootaa64.efi
1.1.2.3 dhcp 服务器搭建
安装dhcp 相关包:
/# sudo apt-get install isc-dhcp-server isc-dhcp-client
修改配置文件:
/# vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
option space PXE;
option client-system-arch code 93 = unsigned integer 16;
allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.100;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.1.1;
filename "arm64-efi/netbootaa64.efi";
}
设置使用的网络设备,若使用eth0,则:
/# vim /etc/default/isc-dhcp-server
INTERFACES="eth0"
重启服务:
/# sudo systemctl restart isc-dhcp-server
1.2 nfs 服务搭建
1.2.1 安装nfs 相关包
/# sudo apt-get install nfs-kernel-server
1.2.2 修改配置文件
将/opt/nfs 设置为nfs 的根目录:
/# vim /etc/exports
/opt/nfs *(rw,sync,no_root_squash,no_subtree_check)
1.2.3 文件放置
在/opt/nfs/创建一个iso 目录:
目标安装机器为鲲鹏或者飞腾新四核架构:
/# mkdir -p /opt/nfs/aarch64-kylin
将整个iso 挂载后的内容对应拷贝至上述目录下。请注意隐藏文件和隐藏
文件夹的拷贝。
1.2.4 重启服务
/# sudo systemctl restart nfs-kernel-server
2 客户端操作
开机,等待固件就绪,在固件启动阶段根据相应提示进入PXE 网络引导模
式(如无该功能,请联系固件提供相应支持)。
如果是UEFI PXE,则等待一小段时间后会显示grub 菜单,选择Net Install
Kylin, 等待进入系统,开始安装;
sudo iptables -F
sudo systemctl status nfs-kernel-server
sudo systemctl status tftpd-hpa
sudo systemctl status isc-dhcp-server
sudo systemctl restart nfs-kernel-server
sudo systemctl restart networking
sudo systemctl restart tftpd-hpa
sudo systemctl status tftpd-hpa
sudo systemctl restart isc-dhcp-server
sudo systemctl status isc-dhcp-server
set default=0
set timeout=5
set color_normal=white/black
set color_highlight=black/light-gray
menuentry "GRG Try Kylin-Desktop without installing" {
linux ${root}/casper/Image boot=casper ro locale=zh_CN KEYBOARDTYPE=pc KEYTABLE=us console=tty audit=0 netboot=nfs nfsroot=192.168.1.1:/opt/nfs/aarch64-kylin/ security=
initrd ${root}/casper/initrd.img
}
menuentry "GRG Install Kylin-Desktop" {
linux ${root}/casper/Image boot=casper only-ubiquity ro locale=zh_CN KEYBOARDTYPE=pc KEYTABLE=us console=tty audit=0 netboot=nfs nfsroot=192.168.1.1:/opt/nfs/aarch64-kylin/ security=
initrd ${root}/casper/initrd.img
}
menuentry "GRG Install uos" {
set gfxpayload=keep
linux ${root}/casper-uos/live/vmlinuz console=tty boot=live netboot=nfs nfsroot=192.168.1.1:/opt/nfs/arm64-uos/ components union=overlay locales=zh_CN.UTF-8 livecd-installer --
initrd ${root}/casper-uos/live/initrd.img
}
menuentry "GRG Try uos without installing" {
set gfxpayload=keep
linux ${root}/casper-uos/live/vmlinuz console=tty boot=live union=overlay quiet splash --
initrd ${root}/casper-uos/live/initrd.img
}
menuentry "Install uos" {
set gfxpayload=keep
linux /debian-installer/deepin/live/vmlinuz console=tty boot=live netboot=nfs nfsroot=192.168.0.1:/var/nfs/deepin/ components union=overlay locales=zh_CN.UTF-8 livecd-installer --
initrd /debian-installer/deepin/live/initrd.img
}
menuentry "Try uos without installing" {
set gfxpayload=keep
linux /debian-installer/deepin/live/vmlinuz console=tty boot=live union=overlay quiet splash --
initrd /debian-installer/deepin/live/initrd.img
}