曦瑜爱你 發表於 2022-11-11 22:46:00

deepin网络启动容器

<h2 id="doc">doc</h2>
<p>https://linuxhint.com/pxe_boot_ubuntu_server/</p>
<p>https://stackoverflow.com/questions/43122080/how-to-use-init-parameter-in-docker-run</p>
<p>http://www.rodsbooks.com/efi-bootloaders/</p>
<h2 id="踩雷">踩雷</h2>
<p>deepin 安装包 中 的 grubx64.efi 无法 nas 网络启动 更换为 openouler 中的 grubx64.efi 即可 网络启动</p>
<h2 id="dhcpd-和-dnsmasq-区别">dhcpd 和 dnsmasq 区别</h2>
<p>dhcpd 比较 专业 配置 较多, 但是 只提供了 dhcp 服务, 想要 域名服务 还需要 bind9 来 支持</p>
<p>dnsmasq 业余一点, 但是 同时 提供了 dhcp 以及 域名 解析的 功能 用来 装机 还是 不错的 address=/example.com/ is equivalent to --server=/example.com/</p>
<h2 id="搭建-server">搭建 server</h2>
<pre><code>docker run-dit--privileged=true--name ubuntu-pxedocker-hub.one-k.xyz/ubuntu:20-04bash
# ps -aux
# USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
# root         10.00.0   1104   4 pts/0    Ss   11:10   0:00 /bin/bash
# root         70.00.0   42403468 pts/0    S+   11:10   0:00 bash

# 进入 容器
docker exec -it ubuntu-pxebash

apt update
apt installdnsmasq-y
apt install vim-y
apt-get install --reinstall systemd

service dnsmasq restart


docker run-dit--privileged=true--init--name ubuntu-pxedocker-hub.one-k.xyz/ubuntu:pxebash
# ps -aux
# USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
# root         10.00.0   1104   4 pts/0    Ss   11:10   0:00 /sbin/docker-init -- bash
# root         70.00.0   42403468 pts/0    S+   11:10   0:00 bash
</code></pre>
<h2 id="挂载-ubuntu18-iso">挂载 ubuntu18 iso</h2>
<pre><code>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 -fpxe-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-dnsmasqdocker-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: 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.
</code></pre>
<h2 id="常见问题">常见问题</h2>
<pre><code>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   12uIPv425122      0t0UDP 127.0.0.53:domain
systemd-r 709 systemd-resolve   13uIPv425123      0t0TCP 127.0.0.53:domain (LISTEN)


systemctl stop systemd-resolved.service
systemctl disable systemd-resolved.service

# 验证
lsof -i:53
root@pxe-ubuntu:~#
</code></pre>
<p><strong>欢迎大家一起交流呀</strong><br>
qq群:3638803451<br>
vx:wxid_sgdelhiwombj12</p><br><br>
来源:https://www.cnblogs.com/ltgybyb/p/16882302.html
頁: [1]
查看完整版本: deepin网络启动容器