Ubuntu 服务器 — PXE 网络引导安装 Windows 10/11 & Ubuntu 20 完整教程
本教程在一台局域网 Ubuntu 服务器上搭建完整的网络引导环境,实现通过 PXE 启动来安装 Windows 10、Windows 11 和 Ubuntu 20.04。
整体架构
整个方案由以下组件协同工作:
| 组件 | 软件 | 作用 |
|---|---|---|
| DHCP 服务 | dnsmasq | 为客户端分配 IP 并指引 PXE 引导文件 |
| TFTP 服务 | dnsmasq(内置) | 传输 iPXE 引导程序(体积小,TFTP 足够) |
| HTTP 服务 | nginx | 提供 iPXE 菜单、内核/initrd、WinPE 镜像下载 |
| SMB 共享 | samba | 共享 Windows 安装源(install.wim 体积大,需通过 SMB 挂载) |
| 引导菜单 | iPXE | 支持 HTTP/iSCSI/SMB 等高级协议,替代传统 pxelinux |
网络拓扑示意:
┌─────────────────────────────────────────────────────────┐
│ Ubuntu Server (192.168.1.10) │
│ │
│ dnsmasq ──► DHCP + TFTP(:69) ──► iPXE 二进制 │
│ nginx ──► HTTP(:8080) ──► iPXE菜单/内核/WinPE │
│ samba ──► SMB(:445) ──► Windows安装源 │
└──────────────────────┬──────────────────────────────────┘
│ LAN
┌──────────────┼──────────────┐
▼ ▼ ▼
[PC-A 装Win10] [PC-B 装Win11] [PC-C 装Ubuntu20]
第一步:基础环境准备
1.1 系统更新与安装软件包
sudo apt update && sudo apt upgrade -y
sudo apt install -y dnsmasq nginx samba ipxe-qemu wget pigz
说明:ipxe-qemu 包提供 iPXE 的网络引导二进制文件(undionly.kpxe 用于 BIOS,ipxe.efi 用于 UEFI)。
1.2 固定服务器 IP
编辑 Netplan 配置(文件名可能不同,看 /etc/netplan/ 下的实际文件):
sudo tee /etc/netplan/01-static.yaml << 'EOF'
network:
version: 2
ethernets:
eth0: # 改成你的网卡名,用 ip a 查看
dhcp4: no
addresses:
- 192.168.1.10/24
routes:
- to: default
via: 192.168.1.1 # 你的网关/路由器地址
nameservers:
addresses: [223.5.5.5, 114.114.114.114]
EOF
sudo netplan apply
重要:后续所有配置中涉及的 IP 地址(192.168.1.10)请替换为你服务器的实际地址。子网网段也要与实际网络匹配。
1.3 创建目录结构
# TFTP 根目录(仅放 iPXE 二进制,体积小)
sudo mkdir -p /srv/tftp
# HTTP 根目录(放所有引导文件)
sudo mkdir -p /srv/pxe/{images/win10,images/win11,images/ubuntu20,ipxe}
# SMB 共享目录(Windows 安装源)
sudo mkdir -p /srv/pxe/win10_share /srv/pxe/win11_share
第二步:配置 dnsmasq(DHCP + TFTP)
2.1 备份原有配置
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
2.2 编写 dnsmasq 配置
sudo tee /etc/dnsmasq.d/pxe.conf << 'EOF'
# ========== 接口绑定 ==========
# 只在局域网网卡上提供 DHCP,避免影响外网
interface=eth0 # 改成你的网卡名
bind-interfaces
except-interface=lo
# ========== DHCP 配置 ==========
# 地址池范围(排除已占用的地址)
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h
# 网关
dhcp-option=3,192.168.1.1
# DNS
dhcp-option=6,223.5.5.5,114.114.114.114
# ========== PXE 引导 ==========
# --- BIOS 模式 ---
# 先加载 iPXE,由 iPXE 再加载 HTTP 菜单
dhcp-boot=tag:bios,undionly.kpxe,192.168.1.10,192.168.1.10
# --- UEFI x86_64 模式 ---
dhcp-boot=tag:efi64,ipxe.efi,192.168.1.10,192.168.1.10
# --- UEFI ARM64 模式(可选) ---
dhcp-boot=tag:efiaarch64,ipxe-arm64.efi,192.168.1.10,192.168.1.10
# 通过 DHCP option 60 区分客户端类型
dhcp-vendorclass=bios,PXEClient:Arch:00000
dhcp-vendorclass=efi32,PXEClient:Arch:00006
dhcp-vendorclass=efi64,PXEClient:Arch:00007
dhcp-vendorclass=efi64,PXEClient:Arch:00009
dhcp-vendorclass=efiaarch64,PXEClient:Arch:00011
# ========== TFTP 配置 ==========
enable-tftp
tftp-root=/srv/tftp
# ========== 日志 ==========
log-dhcp
log-queries
EOF
2.3 复制 iPXE 二进制到 TFTP 目录
# BIOS 引导
sudo cp /usr/lib/ipxe/undionly.kpxe /srv/tftp/
# UEFI x64 引导
sudo cp /usr/lib/ipxe/ipxe.efi /srv/tftp/
# 如果有 ARM64 客户端
sudo cp /usr/lib/ipxe/snponly-x86_64.efi /srv/tftp/ipxe.efi 2>/dev/null || true
注意:不同 Ubuntu 版本的 ipxe-qemu 包路径可能不同。用
dpkg -L ipxe-qemu | grep -E '\.(kpxe|efi)$'查看实际文件位置。如果/usr/lib/ipxe/下没有ipxe.efi,可能需要从 iPXE 官网下载编译好的 EFI 二进制。
2.4 启动 dnsmasq
sudo systemctl restart dnsmasq
sudo systemctl enable dnsmasq
# 检查状态
sudo systemctl status dnsmasq
如果报错"failed to bind DHCP server socket",通常是因为已有其他 DHCP 服务在运行:
# 检查并停止冲突的服务
sudo systemctl stop isc-dhcp-server 2>/dev/null
sudo systemctl disable isc-dhcp-server 2>/dev/null
警告:如果局域网内已有路由器提供 DHCP(绝大多数家庭/公司网络都是),你需要选择以下方案之一:
方案 A — ProxyDHCP(推荐):不分配 IP,只提供 PXE 引导信息。修改 dnsmasq 配置:
# 注释掉 dhcp-range,改用 proxy dhcp-range=192.168.1.0,proxy这样 dnsmasq 不会分配 IP(由路由器继续负责),只响应 PXE 客户端的引导请求。
方案 B — 独立网段:服务器接一块独立网卡,划分单独子网,不影响现有网络。
第三步:配置 nginx(HTTP 文件服务)
iPXE 支持通过 HTTP 下载引导文件,比 TFTP 快得多,且没有文件大小限制。
3.1 编写 nginx 配置
sudo tee /etc/nginx/sites-available/pxe << 'EOF'
server {
listen 8080;
server_name _;
root /srv/pxe;
# 开启目录浏览(方便调试)
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
# iPXE 脚本需要特殊 MIME 类型
location /ipxe/ {
default_application/octet-stream;
types { }
}
# 大文件优化
sendfile on;
tcp_nopush on;
tcp_nodelay on;
}
EOF
3.2 启用站点
sudo ln -sf /etc/nginx/sites-available/pxe /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default # 移除默认站点(可选)
sudo nginx -t # 测试配置语法
sudo systemctl reload nginx
sudo systemctl enable nginx
第四步:配置 iPXE 引导菜单
这是整个方案的"大脑"——客户端通过 iPXE 看到选择菜单,决定安装哪个系统。
4.1 主菜单脚本
sudo tee /srv/pxe/ipxe/menu.ipxe << 'IPXE_EOF'
#!ipxe
# 设置 HTTP 服务器地址
set server http://192.168.1.10:8080
# 显示启动信息
colour --rgb 0x0056b3 2 2
cpalette --bg 0 2
menu PXE Network Boot Menu
menu --gap 1
menu --timeout 15000
menu --default ubuntu20
item --gap ===== 操作系统安装 =====
item ubuntu20 Install Ubuntu 20.04 LTS
item win10 Install Windows 10 Pro
item win11 Install Windows 11 Pro
item --gap ===== 工具 =====
item shell iPXE Command Shell
item reboot Reboot
choose --default ubuntu20 --timeout 15000 target && goto ${target}
:ubuntu20
echo Booting Ubuntu 20.04 LTS Installer...
kernel ${server}/images/ubuntu20/vmlinuz
initrd ${server}/images/ubuntu20/initrd
imgargs vmlinuz initrd=initrd root=/dev/ram0 ramdisk_size=1500000 \
url=${server}/images/ubuntu20/ubuntu-20.04.6-live-server-amd64.iso \
auto=true priority=critical netcfg/dhcp_timeout=60 \
locale=en_US.UTF-8 keymap=us
boot || goto menu
:win10
echo Booting Windows 10 Installer (WinPE)...
initrd ${server}/images/win10/boot.wim
chain ${server}/ipxe/wimboot || goto menu
:win11
echo Booting Windows 11 Installer (WinPE)...
initrd ${server}/images/win11/boot.wim
chain ${server}/ipxe/wimboot || goto menu
:shell
echo Dropping to iPXE shell...
echo Type 'help' for available commands.
shell
goto menu
:reboot
reboot
IPXE_EOF
4.2 创建 iPXE 自动引导脚本(BIOS 客户端首次加载)
iPXE 二进制加载后会自动请求 TFTP 上的 boot.ipxe 或 default.ipxe:
sudo tee /srv/tftp/boot.ipxe << 'EOF'
#!ipxe
# 从 TFTP 获取主菜单(HTTP更快)
chain http://192.168.1.10:8080/ipxe/menu.ipxe
EOF
第五步:准备 Ubuntu 20.04 安装源
5.1 下载 ISO
cd /tmp
wget https://releases.ubuntu.com/20.04.6/ubuntu-20.04.6-live-server-amd64.iso
# 如果需要桌面版:
# wget https://releases.ubuntu.com/20.04.6/ubuntu-20.04.6-desktop-amd64.iso
5.2 提取内核和 initrd
# 挂载 ISO
sudo mkdir -p /mnt/iso
sudo mount -o loop /tmp/ubuntu-20.04.6-live-server-amd64.iso /mnt/iso
# 复制内核和 initrd 到 HTTP 目录
sudo cp /mnt/iso/casper/vmlinuz /srv/pxe/images/ubuntu20/
sudo cp /mnt/iso/casper/initrd /srv/pxe/images/ubuntu20/
# 复制完整 ISO 到 HTTP 目录(安装过程需要读取)
sudo cp /tmp/ubuntu-20.04.6-live-server-amd64.iso /srv/pxe/images/ubuntu20/
# 卸载
sudo umount /mnt/iso
5.3 验证文件
ls -lh /srv/pxe/images/ubuntu20/
# 应该看到:
# initrd (~80MB)
# vmlinuz (~12MB)
# ubuntu-20.04.6-live-server-amd64.iso (~1.4GB)
第六步:准备 Windows 10/11 安装源
Windows 的网络安装比 Linux 复杂得多,核心思路是:通过 iPXE + wimboot 启动 WinPE 环境,WinPE 内通过 SMB 挂载完整安装源来执行安装。
6.1 下载 wimboot
wimboot 是一个特殊的引导加载器,让 iPXE 能直接启动 Windows 的 boot.wim。
sudo mkdir -p /srv/pxe/ipxe
cd /srv/pxe/ipxe
# 下载 wimboot
sudo wget https://github.com/ipxe/wimboot/releases/latest/download/wimboot
# 或者从 iPXE 官方:
# sudo wget http://git.ipxe.org/releases/wimboot/wimboot-latest.tar.gz
# sudo tar xzf wimboot-latest.tar.gz
# sudo cp wimboot-*/wimboot /srv/pxe/ipxe/
sudo chmod 644 /srv/pxe/ipxe/wimboot
6.2 准备 Windows 10 安装源
假设你已经有 Windows 10 的 ISO 文件(Win10_22H2_Chinese_x64.iso)。
方法 A — 在 Ubuntu 上直接解压 ISO:
# 挂载 Windows ISO
sudo mkdir -p /mnt/win10iso
sudo mount -o loop /path/to/Win10_22H2_Chinese_x64.iso /mnt/win10iso
# 复制全部文件到 HTTP 目录
sudo cp -r /mnt/win10iso/* /srv/pxe/images/win10/
# 卸载
sudo umount /mnt/win10iso
方法 B — 在 Windows 上解压后通过 SMB 共享(更常见):
如果你有一台 Windows 机器,用 UltraISO 或 7-Zip 解压 ISO 到一个文件夹,然后通过 SMB 共享出去。
6.3 准备 Windows 11 安装源
同样的方法:
sudo mkdir -p /mnt/win11iso
sudo mount -o loop /path/to/Win11_23H2_Chinese_x64.iso /mnt/win11iso
sudo cp -r /mnt/win11iso/* /srv/pxe/images/win11/
sudo umount /mnt/win11iso
6.4 提取 boot.wim 用于 iPXE 直接引导
boot.wim 是 WinPE 环境,体积约 300-500MB,iPXE 通过 wimboot 加载它。
# Windows 10 的 boot.wim
sudo cp /srv/pxe/images/win10/sources/boot.wim /srv/pxe/images/win10/
# Windows 11 的 boot.wim
sudo cp /srv/pxe/images/win11/sources/boot.wim /srv/pxe/images/win11/
注意:
install.wim(或install.esd)通常在 3-5GB,不能通过 wimboot 直接加载。WinPE 启动后需要通过 SMB 或本地拷贝来获取它。
第七步:配置 Samba(SMB 共享 Windows 安装源)
WinPE 启动后需要通过网络访问完整的 Windows 安装文件(主要是 install.wim),通过 SMB 共享是最稳定的方式。
7.1 备份并编写 Samba 配置
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo tee /etc/samba/smb.conf << 'EOF'
[global]
workgroup = WORKGROUP
server string = PXE Server
security = user
map to guest = Bad User
guest account = nobody
# 允许匿名访问(WinPE 中不方便输入密码)
# 如果你需要密码认证,注释掉 "map to guest" 行
# 并在 WinPE 中用 net use 命令连接
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
# 性能优化
socket options = TCP_NODELAY IPTOS_LOWDELAY
read raw = Yes
write raw = Yes
[win10]
comment = Windows 10 Installation Files
path = /srv/pxe/images/win10
browseable = yes
read only = yes
guest ok = yes
create mask = 0644
[win11]
comment = Windows 11 Installation Files
path = /srv/pxe/images/win11
browseable = yes
read only = yes
guest ok = yes
create mask = 0644
EOF
7.2 启动 Samba
sudo systemctl restart smbd nmbd
sudo systemctl enable smbd nmbd
# 检查状态
sudo systemctl status smbd
7.3 测试 SMB 共享
在另一台 Windows 电脑上,打开文件资源管理器,地址栏输入:
\\192.168.1.10\win10
应该能看到 Windows 10 的安装文件。
第八步:创建 WinPE 自动挂载脚本(关键步骤)
WinPE 启动后需要自动连接 SMB 共享并启动 Windows 安装程序。我们创建一个启动脚本注入到 boot.wim 中。
8.1 创建启动脚本
sudo tee /srv/pxe/images/win10/startnet.cmd << 'EOF'
@echo off
echo ============================================
echo PXE Network Install - Windows 10
echo ============================================
echo.
REM 等待网络就绪
echo Waiting for network...
wpeinit
ping -n 5 127.0.0.1 >nul
REM 挂载 SMB 共享
echo Connecting to installation source...
net use Z: \\192.168.1.10\win10 /user:guest ""
if %errorlevel% neq 0 (
echo SMB connection failed. Trying with empty password...
net use Z: \\192.168.1.10\win10 "" /user:""
)
REM 如果挂载成功,启动安装程序
if exist Z:\setup.exe (
echo Starting Windows Setup...
Z:\setup.exe
) else (
echo ERROR: Cannot find setup.exe on SMB share.
echo Please check network connection and SMB share.
echo.
echo Manual steps:
echo net use Z: \\192.168.1.10\win10
echo Z:\setup.exe
cmd /k
)
EOF
对 Windows 11 做同样的操作,只需改路径:
sudo cp /srv/pxe/images/win10/startnet.cmd /srv/pxe/images/win11/startnet.cmd
# 编辑 win11 版本,把 \win10 改成 \win11
sudo sed -i 's|\\win10|\\win11|g' /srv/pxe/images/win11/startnet.cmd
8.2 将脚本注入 boot.wim(进阶)
这一步需要在 Windows 环境下操作(使用 DISM 工具)。如果你不想修改 boot.wim,可以跳过此步,在 WinPE 启动后手动执行 net use 和 setup.exe。
在 Windows 上操作:
# 以管理员身份运行 PowerShell
# 挂载 boot.wim
mkdir C:\winpe_mount
dism /Mount-Image /ImageFile:D:\path\to\boot.wim /Index:2 /MountDir:C:\winpe_mount
# 替换启动脚本
copy /Y D:\path\to\startnet.cmd C:\winpe_mount\Windows\System32\startnet.cmd
# 保存
dism /Unmount-Image /MountDir:C:\winpe_mount /Commit
提示:boot.wim 通常有 2 个 Index,Index:1 是基础 WinPE,Index:2 是 Windows Setup 环境。你需要修改 Index:2。
第九步:更新 iPXE 菜单(完善 Windows 引导)
考虑到 wimboot 的限制和 SMB 挂载的需求,优化 Windows 部分的菜单项:
sudo tee /srv/pxe/ipxe/menu.ipxe << 'IPXE_EOF'
#!ipxe
set server http://192.168.1.10:8080
# 获取客户端信息
iseq ${platform} efi && set boot_type UEFI || set boot_type BIOS
colour --rgb 0x0056b3 2 2
cpalette --bg 0 2
menu =============================================
menu PXE Network Boot Server
menu =============================================
menu --gap 1
menu --timeout 30000
menu --default ubuntu20
item --gap -- Operating Systems --
item ubuntu20 [1] Install Ubuntu 20.04 LTS Server
item win10 [2] Install Windows 10 Pro
item win11 [3] Install Windows 11 Pro
item --gap -- Utilities --
item memtest [4] MemTest86+
item shell [5] iPXE Command Shell
item reboot [6] Reboot
choose --default ubuntu20 --timeout 30000 target && goto ${target}
# ==================== Ubuntu 20.04 ====================
:ubuntu20
echo Booting Ubuntu 20.04 LTS...
kernel ${server}/images/ubuntu20/vmlinuz
initrd ${server}/images/ubuntu20/initrd
imgargs vmlinuz initrd=initrd root=/dev/ram0 ramdisk_size=1500000 \
url=${server}/images/ubuntu20/ubuntu-20.04.6-live-server-amd64.iso \
auto=true priority=critical \
locale=en_US.UTF-8 keymap=us
boot || goto failed
# ==================== Windows 10 ====================
:win10
echo Booting Windows 10 Setup (WinPE)...
echo After WinPE loads, connect to SMB share:
echo net use Z: \\192.168.1.10\win10
echo Z:\setup.exe
echo.
initrd ${server}/images/win10/boot.wim
chain ${server}/ipxe/wimboot || goto failed
# ==================== Windows 11 ====================
:win11
echo Booting Windows 11 Setup (WinPE)...
echo After WinPE loads, connect to SMB share:
echo net use Z: \\192.168.1.10\win11
echo Z:\setup.exe
echo.
initrd ${server}/images/win11/boot.wim
chain ${server}/ipxe/wimboot || goto failed
# ==================== MemTest86+ ====================
:memtest
echo Downloading MemTest86+...
kernel ${server}/images/memtest/memtest.efi || kernel ${server}/images/memtest/memtest
boot || goto failed
# ==================== Shell ====================
:shell
echo Type 'help' for commands, 'exit' to return to menu.
shell
goto menu
# ==================== Reboot ====================
:reboot
reboot
# ==================== Error Handler ====================
:failed
echo Boot failed! Check server connection and try again.
echo Press any key to return to menu...
prompt
goto menu
IPXE_EOF
第十步:防火墙配置
确保以下端口在服务器上开放:
# 如果使用 ufw
sudo ufw allow 67/udp # DHCP
sudo ufw allow 68/udp # DHCP client
sudo ufw allow 69/udp # TFTP
sudo ufw allow 8080/tcp # HTTP (nginx)
sudo ufw allow 137/udp # NetBIOS
sudo ufw allow 138/udp # NetBIOS
sudo ufw allow 139/tcp # NetBIOS
sudo ufw allow 445/tcp # SMB
sudo ufw allow 4011/udp # ProxyDHCP (如果需要)
# 如果 ufw 已启用
sudo ufw --force enable
sudo ufw status
生产环境建议:用
ufw limit替代ufw allow对 DHCP/TFTP 做速率限制,防止广播风暴。
第十一步:客户端引导测试
11.1 BIOS 模式测试
- 找一台测试机,开机按 F12(或 Del/F2,取决于主板)进入启动菜单
- 选择 "Network Boot" / "PXE Boot" / "LAN Boot"
- 应看到 iPXE 菜单出现
- 选择要安装的系统
11.2 UEFI 模式测试
- 在 BIOS 设置中确保启用 UEFI 模式并关闭 CSM(兼容支持模块)
- 选择网络启动
- 应加载
ipxe.efi,然后显示同样的菜单
11.3 常见问题排查
看不到 iPXE 菜单:
# 在服务器上查看 dnsmasq 日志
sudo journalctl -u dnsmasq -f
# 检查 TFTP 是否响应
# 在客户端同网段另一台机器上测试:
tftp 192.168.1.10 -c get undionly.kpxe
iPXE 菜单出现但无法引导 Ubuntu:
# 检查 HTTP 服务
curl -I http://192.168.1.10:8080/ipxe/menu.ipxe
curl -I http://192.168.1.10:8080/images/ubuntu20/vmlinuz
WinPE 启动后黑屏或蓝屏:
wimboot 对 UEFI + Secure Boot 兼容性有限。尝试:
- 关闭 Secure Boot
- 使用 BIOS/Legacy 模式引导 Windows
- 更新 wimboot 到最新版本
SMB 连接失败:
# 在服务器上检查 Samba 状态
sudo systemctl status smbd
sudo testparm -s # 验证配置语法
# 在 WinPE 命令行中手动测试
net use
net use Z: \\192.168.1.10\win10 /user:guest ""
dir Z:
第十二步:服务管理与维护
12.1 一键启停脚本
sudo tee /usr/local/bin/pxe-start << 'EOF'
#!/bin/bash
echo "Starting PXE Boot Server services..."
sudo systemctl start dnsmasq
sudo systemctl start nginx
sudo systemctl start smbd
sudo systemctl start nmbd
echo "All PXE services started."
echo " DHCP/TFTP : 192.168.1.10:67/69"
echo " HTTP : http://192.168.1.10:8080"
echo " SMB Win10 : \\\\192.168.1.10\\win10"
echo " SMB Win11 : \\\\192.168.1.10\\win11"
EOF
sudo tee /usr/local/bin/pxe-stop << 'EOF'
#!/bin/bash
echo "Stopping PXE Boot Server services..."
sudo systemctl stop dnsmasq
sudo systemctl stop nginx
sudo systemctl stop smbd
sudo systemctl stop nmbd
echo "All PXE services stopped."
EOF
sudo chmod +x /usr/local/bin/pxe-start /usr/local/bin/pxe-stop
使用:
pxe-start # 启动所有服务
pxe-stop # 停止所有服务
12.2 添加新系统
要添加新操作系统(如 Ubuntu 22.04),只需:
- 下载 ISO 并提取 vmlinuz/initrd 到
/srv/pxe/images/ubuntu22/ - 编辑
/srv/pxe/ipxe/menu.ipxe,添加新的菜单项 - 无需重启任何服务(iPXE 脚本是动态加载的)
附录 A:完整文件目录结构
/srv/
├── tftp/ # TFTP 根目录
│ ├── undionly.kpxe # BIOS iPXE 引导
│ ├── ipxe.efi # UEFI iPXE 引导
│ └── boot.ipxe # iPXE 初始脚本(链式加载到 HTTP)
│
├── pxe/ # HTTP 根目录 (nginx :8080)
│ ├── ipxe/
│ │ ├── menu.ipxe # 主菜单脚本
│ │ └── wimboot # Windows 引导加载器
│ │
│ └── images/
│ ├── ubuntu20/
│ │ ├── vmlinuz # Linux 内核
│ │ ├── initrd # 初始内存盘
│ │ └── ubuntu-20.04.6-live-server-amd64.iso # 完整 ISO
│ │
│ ├── win10/
│ │ ├── boot.wim # WinPE(iPXE 直接加载)
│ │ ├── sources/
│ │ │ └── install.wim # Windows 安装映像(通过 SMB 访问)
│ │ ├── setup.exe # Windows 安装程序
│ │ └── ... # 其他安装文件
│ │
│ └── win11/
│ ├── boot.wim
│ ├── sources/
│ │ └── install.wim
│ ├── setup.exe
│ └── ...
附录 B:Windows 11 TPM 2.0 绕过
Windows 11 安装程序会检查 TPM 2.0 和安全启动。在 PXE 网络安装环境中,可以在 WinPE 阶段绕过这些限制:
在 startnet.cmd 中,setup.exe 之前添加:
REM 绕过 Windows 11 的 TPM 和安全启动检查
reg add HKLM\System\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1 /f
reg add HKLM\System\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1 /f
reg add HKLM\System\Setup\LabConfig /v BypassRAMCheck /t REG_DWORD /d 1 /f
附录 C:安全建议
本教程为了简化配置,SMB 使用了匿名访问。如果在生产环境中使用,建议:
- 为 SMB 创建专用只读用户,设置密码
- 在 WinPE 的 startnet.cmd 中使用
net use Z: \\server\share /user:pxeuser "password"连接 - 限制 dnsmasq 的 DHCP 范围,或改用 ProxyDHCP 模式
- 考虑为 iPXE 菜单添加密码保护(iPXE 支持
--password参数) - 如果跨网段引导,配置 DHCP Relay(ip helper)指向 PXE 服务器

浙公网安备 33010602011771号