要在内网中实现 PXE 安装 Debian,您需要完成以下步骤:
确保您的网络拓扑支持 PXE 启动和 TFTP 服务。
在一台服务器上安装 TFTP 服务。这可以使用 apt-get 命令安装:
sudo apt-get install tftpd-hpa
- 配置 TFTP 服务器以启用 PXE 引导。编辑 /etc/default/tftpd-hpa 文件,并确保以下行存在并取消注释:
TFTP_OPTIONS="--secure"
- 将 Debian ISO 映像文件下载到 TFTP 服务器的根目录中。例如,如果您要下载 Debian 10 Buster 的 ISO 映像,则可以使用以下命令:
sudo wget http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.5.0-amd64-netinst.iso -O /var/lib/tftpboot/debian-10.5.0-amd64-netinst.iso
- 创建一个名为 pxelinux.cfg 的目录,并在其中创建一个名为 default 的文件夹。例如,
sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg/default/
sudo touch /var/lib/tftpboot/pxelinux.cfg/default
- 编辑 default 文件以包含以下内容:
default linux
prompt 0
timeout 1
label linux
menu label ^Install Debian Linux
kernel debian-installer/amd64/linux
append initrd=debian-installer/amd64/initrd.gz netcfg/disable_autoconfig=true netcfg/get_hostname=mydebian preseed/url=http://<your-web-server>/preseed.cfg auto=true priority=critical ---
- 创建一个名为 preseed.cfg 的文件,其中包含要应用于 Debian 安装的预设设置。以下是示例 preseed.cfg 文件:
# Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string mydebian
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string 192.168.1.100
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.1.1
d-i netcfg/get_nameservers string 8.8.8.8
# Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
# Partitioning settings
partman-auto partman-auto/method select regular
partman-auto/choose_recipe select atomic
partman/default_filesystem ext4
partman-partitioning/confirm_write_new_label boolean true
partman/choose_partition select finish
partman/confirm boolean true
# Account setup
passwd/root-login boolean false
passwd/user-fullname string My User Name
passwd/username string myuser
passwd/user-password-crypted password $6$WjUwVWxGmTwKcUQh$cLRxOncZz7E0P2XlLs9CJyf5.BwRuSHAV3JvXbmeYnFg7mbjRq/UeMkCu4uKu9TmAz0.bkQDGM5VoHzZLPKD80
# Grub bootloader settings
grub-installer/only_debian boolean true
grub-installer/bootdev string default
# Package selection
tasksel tasksel/first multiselect standard, ssh-server
# Finish installation without manual intervention
d-i finish-install/reboot_in_progress note
d-i debian-installer/exit/halt boolean false
d-i debian-installer/exit/poweroff boolean false
将 preseed.cfg 文件上传到 Web 服务器,以便在安装期间使用。请注意,preseed.cfg 文件中的 URL 应该指向您的 Web 服务器。
启动客户端计算机,并确保其支持 PXE 引导。
在客户端计算机上,通过按 F12 或类似键启动网络引导。计算机应该从 TFTP 服务器启动 Debian 安装程序,并使用预设设置自动完成安装过程。
希望这些步骤对您有所帮助!




