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/
dhcpd 和 dnsmasq 区别
dhcpd 比较 专业 配置 较多, 但是 只提供了 dhcp 服务, 想要 域名服务 还需要 bind9 来 支持
dnsmasq 业余一点, 但是 同时 提供了 dhcp 以及 域名 解析的 功能 用来 装机 还是 不错的 address=/example.com/ is equivalent to --server=/example.com/
使用 详情 参考
USAGE
client
# 根据 需要 修改
# pxe_compose/tftpdata/grub.cfg
# pxe_compose/tftpdata/ks-net.cfg
# 修改 服务器 部署 ip
# pxe_compose/.env
# 根据 需求 修改 并执行
# update_grub_cfg.md
# update_ks_cfg.md
# 修改完成后, 将 配置文件 发送到 服务器
rsync -avz /root/essay/learn_docker/networkboot/openeulero网络启动容器/pxe_compose root@10.1.0.31:/root/
server
cd /root
wget https://nginx-static.one-k.xyz/whshare/iso/openeuler/openEuler-21.09-x86_64-dvd.iso
iso_file='/root/openEuler-21.09-x86_64-dvd.iso'
iso_mount_dir='/root/openEuler'
tftp_dir='/root/pxe_compose/tftpdata'
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 -r ${iso_mount_dir}/images/pxeboot/. ${tftp_dir}/
# -n: do not overwrite an existing file,
# reserver file tftpdata/grub.cfg
cp -r -n ${iso_mount_dir}/EFI/BOOT/. ${tftp_dir}/
cd /root/pxe_compose
docker-compose up -d
docker-compose down
# 查看 compose 中的 容器 list
docker-compose ps
# 查看 compose 中 定义 容器 的 运行进程
docker-compose top
搭建 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
# 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:~#
欢迎大家一起交流呀
qq群:3638803451
vx:wxid_sgdelhiwombj12