搭建PXE服务器
用的镜像是uniontechos-desktop-20-professional-1030-fix_amd64.iso,
首先安装必要软件
apt install isc-dhcp-server tftpd-hpa nfs-kernel-server
创建和复制必要文件(已将UOS镜像挂载到 /mnt/uos 目录)
sudo mkdir -p /tftpboot/pxelinux.cfg
sudo touch /tftpboot/pxelinux.cfg/default
cp -r /mnt/uos/isolinux/. /tftpboot
cp /mnt/uos/live/vmlinuz /tftpboot
cp /mnt/uos/live/initrd.lz /tftpboot
cp ./pxelinux.0 /tftpboot #pxelinux.0文件下载地址在最后
vim /etc/dhcp/dhcpd.conf
vim /tftpboot/pxelinux.cfg/default
vim /etc/default/isc-dhcp-server
vim /etc/default/tftpd-hpa
vim /etc/exports
#/etc/dhcp/dhcpd.conf内容
allow booting;
allow bootp;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.50 192.168.0.150;
option routers 192.168.0.4;
option broadcast-address 192.168.0.255;
option domain-name-servers 192.168.0.4;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.0.4;
filename "pxelinux.0";
}
#/tftpboot/pxelinux.cfg/default内容
default vesamenu.c32
timeout 5
menu autoboot Starting Linux install in # second{,s}. Press any key to interrupt.
menu clear
menu title UOS20
label UOS
menu label Start UOS20
kernel vmlinuz
append initrd=initrd.lz boot=live livecd-installer netboot=nfs nfsroot=(Your_IP):/mnt/uos locale=zh_CN.UTF-8
#/etc/default/isc-dhcp-servern内容
INTERFACESv4="enp3s0"
#/etc/default/tftpd-hpa内容
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot" #目录
TFTP_ADDRESS="0.0.0.0:69" #端口
TFTP_OPTIONS="-l -c -s" #权限设置
#/etc/exports内容
/mnt/uos *(ro)
修改/tftpboot权限
chmod -R 777 /tftpboot
将这几个服务全部重启一遍
systemctl restart nfs-kernel-server
systemctl restart isc-dhcp-server
systemctl restart tftpd-hpa
参考:
[1]. PXE安装兆芯版UOS