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:~#

原文地址:http://www.cnblogs.com/ltgybyb/p/16882302.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性