doc
https://linuxhint.com/pxe_boot_ubuntu_server/
https://stackoverflow.com/questions/43122080/how-to-use-init-parameter-in-docker-run
http://www.rodsbooks.com/efi-bootloaders/
踩雷
deepin 安装包 中 的 grubx64.efi 无法 nas 网络启动 更换为 openouler 中的 grubx64.efi 即可 网络启动
dhcpd 和 dnsmasq 区别
dhcpd 比较 专业 配置 较多, 但是 只提供了 dhcp 服务, 想要 域名服务 还需要 bind9 来 支持
dnsmasq 业余一点, 但是 同时 提供了 dhcp 以及 域名 解析的 功能 用来 装机 还是 不错的 address=/example.com/ is equivalent to --server=/example.com/
搭建 server
docker run -dit --privileged=true --name ubuntu-pxe docker-hub.one-k.xyz/ubuntu:20-04 bash
# ps -aux
# USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
# root 1 0.0 0.0 1104 4 pts/0 Ss 11:10 0:00 /bin/bash
# root 7 0.0 0.0 4240 3468 pts/0 S+ 11:10 0:00 bash
# 进入 容器
docker exec -it ubuntu-pxe bash
apt update
apt install dnsmasq -y
apt install vim -y
apt-get install --reinstall systemd
service dnsmasq restart
docker run -dit --privileged=true --init --name ubuntu-pxe docker-hub.one-k.xyz/ubuntu:pxe bash
# ps -aux
# USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
# root 1 0.0 0.0 1104 4 pts/0 Ss 11:10 0:00 /sbin/docker-init -- bash
# root 7 0.0 0.0 4240 3468 pts/0 S+ 11:10 0:00 bash
挂载 ubuntu18 iso
cd /root
wget https://nginx-static.one-k.xyz/whshare/iso/deepin/deepin-desktop-community-20.3-amd64.iso
curl https://nginx-static.one-k.xyz/whshare/iso/deepin/deepin-desktop-community-20.3-amd64.SHA256SUMS
wget https://nginx-static.one-k.xyz/whshare/iso/pxe/grubx64.efi
wget https://nginx-static.one-k.xyz/whshare/iso/pxe/undionly.kpxe
wget https://nginx-static.one-k.xyz/whshare/iso/pxe/ipxe.efi
iso_file='/root/deepin-desktop-community-20.3-amd64.iso'
iso_mount_dir='/root/iso'
tftp_dir='/root/tftpdata'
container_tftp_path='/netboot/tftp'
domain='pxe.lan'
dhcp_range="10.1.0.100,10.1.0.140,255.255.255.0,1h"
dhcp_option="option:router,10.1.0.254"
dhcp_boot="grubx64.efi"
mkdir -p ${iso_mount_dir}
mkdir -p ${tftp_dir}
umount ${iso_mount_dir}
mount -t iso9660 -o loop,ro ${iso_file} ${iso_mount_dir}
cp -a ${iso_mount_dir}/EFI ${tftp_dir}/
cp -a ${iso_mount_dir}/boot ${tftp_dir}/
cp -a ${iso_mount_dir}/live ${tftp_dir}/
# 下载的 pxe/grubx64.efi
cp grubx64.efi ${tftp_dir}/
cp undionly.kpxe ${tftp_dir}/
cp ipxe.efi ${tftp_dir}/
# /grub.cfg 要个 grubx64.efi 位于 同一个目录
rm ${tftp_dir}/grub.cfg
vi ${tftp_dir}/grub.cfg
vi ${tftp_dir}/ks-net.cfg
docker rm -f pxe-dnsmasq
# --dhcp-boot="EFI/BOOT/grubx64.efi,pxe.lan" \
# --tftp-no-blocksize
# registry.cn-hangzhou.aliyuncs.com/mkmk/all:dnsmasq-2.85-r2-alpine-edge
docker-hub.one-k.xyz/dnsmasq:2.85-r2-alpine-edge
docker run -d --privileged=true --net=host \
-v ${tftp_dir}:${container_tftp_path} \
--name pxe-dnsmasq docker-hub.one-k.xyz/dnsmasq:2.85-r2-alpine-edge \
--expand-hosts \
--domain="${domain}" \
--dhcp-range="${dhcp_range}" \
--dhcp-option="${dhcp_option}" \
--enable-tftp \
--tftp-max=1000 \
--tftp-root="${container_tftp_path}" \
--dhcp-boot=${dhcp_boot} \
--pxe-prompt='"Press F8 for PXE Network boot.", 2' \
--tftp-no-blocksize \
--log-facility=-
docker logs pxe-dnsmasq
# file /netboot/tftp/grubx64.efi not found
cp -a /root/tftpdata/EFI/BOOT/grubx64.efi /root/tftpdata/
# no such device /.disk/info
# dnsmasq-tftp[1]: error 8 User aborted the transfer received from 10.1.0.125
Well, this is embarrassing:
My system is using EFI and the setup described in the linked article is about legacy BIOS systems.
After swapping the boot path with the correct one (EFI/boot/bootx64.efi) I get readable error messages that I can google.
常见问题
docker logs pxe-dnsmasq
dnsmasq: failed to create listening socket for port 53: Address in use
# solvtion
lsof -i:53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 709 systemd-resolve 12u IPv4 25122 0t0 UDP 127.0.0.53:domain
systemd-r 709 systemd-resolve 13u IPv4 25123 0t0 TCP 127.0.0.53:domain (LISTEN)
systemctl stop systemd-resolved.service
systemctl disable systemd-resolved.service
# 验证
lsof -i:53
root@pxe-ubuntu:~#
标签:容器,--,deepin,网络,efi,iso,pxe,tftp,dir
From: https://www.cnblogs.com/ltgybyb/p/16882302.html