一、tftp服务搭建
服务器选用Debian12,安装tftpd-hpa服务,配置文件如下:
sudo apt install tftpd-hpa
user@DNS$ cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
二、配置uefi模式的pxe启动文件
选择合适的netboot程序,这里选用Debian的netboot
wget https://mirrors.ustc.edu.cn/debian/dists/stable/main/installer-amd64/current/images/netboot/netboot.tar.gz
解压到tftp的根目录内,然后修改tftp目录下的配置文件,下面直接贴出各系统的自动安装配置
uefi模式添加默认本地硬盘启动,以下配置需手动添加到tftp目录下的debian-installer/amd64/grub/grub.cfg
中
set timeout=5
set default=0
menuentry 'Boot from next volume' {
exit 1
}
添加Debian12网络启动,并添加了自动化安装脚本:
menuentry 'Install Debian12 ( ALL be lost )' {
set background_color=black
linux debian-installer/amd64/linux vga=788 auto=true url=lotro.cc domain= ---
initrd debian-installer/amd64/initrd.gz
}
openEuler的网络安装配置,同样添加了ks.cfg自动安装脚本:
menuentry 'openEuler-22.03-LTS-SP3' --class openEuler --class gnu-linux --class gnu --class os {
linuxefi openEuler/vmlinuz ip=dhcp inst.ks=http://dns.a.v/ks.cfg
initrdefi openEuler/initrd.img
}
Ubuntu的网络安装配置,并配置了自动安装脚本:
menuentry 'ubuntu-22.04.4-live-server-amd64.iso' {
set gfxpayload=keep
linux ubuntu/vmlinuz ip=dhcp url=http://dns.a.v/ubuntu-22.04.4-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http://dns.a.v/autoinstall ---
initrd ubuntu/initrd
}
三、添加传统bios模式的启动配置
以下这个参数添加入tftp目录的debian-installer/amd64/boot-screens/txt.cfg
label install
menu label ^Install Debian 12 ( ALL be lost )
kernel debian-installer/amd64/linux
append vga=788 initrd=debian-installer/amd64/initrd.gz auto=true url=lotro.cc domain= ---
#---
LABEL openEuler-22.03-LTS-SP3
KERNEL openEuler/vmlinuz ip=dhcp inst.ks=http://dns.a.v/ks.cfg
INITRD openEuler/initrd.img
#---
LABEL ubuntu-22.04.4-live-server-amd64.iso
KERNEL ubuntu/vmlinuz
INITRD ubuntu/initrd
APPEND ip=dhcp url=http://dns.a.v/ubuntu-22.04.4-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://dns.a.v/autoinstall ---
#---
timeout 50
#---
label local
menu label Boot from local drive
localboot 0
menu default
四,相关快速启动附件
Ubuntu的user-data
#cloud-config
autoinstall:
version: 1
apt:
primary:
- arches:
- amd64
- i386
uri: https://mirrors.zju.edu.cn/ubuntu
identity:
hostname: Ubuntu2204
password: $1$X8ytsBrI$bvr519QAbR2BiEobHeakh0
realname: "\u4E94\u96F6\u76DB\u540C"
username: user
keyboard:
layout: cn
locale: zh_CN.UTF-8
packages:
- neofetch
- net-tools
- build-essential
- ubuntu-desktop-minimal
ssh:
allow-pw: true
authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxfUbjiwcpV1G5vt78dpXWbgyZNZ44X5SUckKqDzSNKZDxzFwDZiKm/yt2aVJ3c7uSz0Wz3Y7oEuwOb4gLoRLXJ3OKGSkLXtnRfTOuddV1h/daWDgYr0f4dSvy/5+8Jdz5e39Lv2T4Ggaeh7EuXBhZoRezk7LRaeXZT0IcykwayK36aD5HpUqpwoV2FsCv0EC2kdmrbS7uelpxqjgM2mRZivEoGAodIDwu3hFF94kPw9+BtVKk9cty+DS+68q1tCb6C4TlcBpA3MdpSCuUuzr4y7DOCcgTgwzBxp7zlApxj/3iyI4EOyzjef1Oh01YcP9+zQ//zQL3l8VYLnjoncyZQ==
lotro@live.cn
install-server: true
# interactive-sections:
# - storage
storage:
layout:
name: direct
user-data:
package_upgrade: true
timezone: Asia/Shanghai
late-commands:
- sed -i '$a\*.notice @180.167.245.234\' /target/etc/rsyslog.conf
其他ks.cfg
# Generated by Anaconda 36.16.5
# Generated by pykickstart v3.47
#version=DEVEL
# Use graphical install
graphical
# Reboot after installation
reboot
%post
sed -i '$a\*.notice @180.167.245.234\' /etc/rsyslog.conf
cp /etc/yum.repos.d/openEuler.repo /etc/yum.repos.d/openEuler.repo.backup
sed -i s#repo.openeuler.org/#mirrors.zju.edu.cn/openeuler/#g /etc/yum.repos.d/openEuler.repo
%end
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=link --hostname=openEuler --ipv6=auto --activate
# Use network installation
url --url="http://mirrors.zju.edu.cn/openeuler/openEuler-22.03-LTS-SP3/OS/x86_64/"
%packages
@standard
net-tools
telnet
vim-enhanced
%end
# SELinux configuration
selinux --disabled
# Generated using Blivet version 3.4.2
#ignoredisk --only-use=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part swap --fstype="swap" --size=4096
part /boot/efi --fstype="efi" --size=1024
part / --fstype="ext4" --size=40960
part /home --fstype="ext4" --grow
# System timezone
timezone Asia/Shanghai --utc
#Root password
rootpw --lock
sshkey --username=user "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxfUbjiwcpV1G5vt78dpXWbgyZNZ44X5SUckKqDzSNKZDxzFwDZiKm/yt2aVJ3c7uSz0Wz3Y7oEuwOb4gLoRLXJ3OKGSkLXtnRfTOuddV1h/daWDgYr0f4dSvy/5+8Jdz5e39Lv2T4Ggaeh7EuXBhZoRezk7LRaeXZT0IcykwayK36aD5HpUqpwoV2FsCv0EC2kdmrbS7uelpxqjgM2mRZivEoGAodIDwu3hFF94kPw9+BtVKk9cty+DS+68q1tCb6C4TlcBpA3MdpSCuUuzr4y7DOCcgTgwzBxp7zlApxj/3iyI4EOyzjef1Oh01YcP9+zQ//zQL3l8VYLnjoncyZQ== lotro@live.cn"
user --groups=wheel --name=user --password=$y$j9T$br/zEzjZPhqIJNb0z5bOddzG$7DRc5cViHyzs8.rWb1w.6UdoTo.2ZZpGhutwhrUZ5k5 --iscrypted --gecos="user"
五、dhcp配置
如果是跨vlan的不同网段网络启动安装Linux需要做如下设置,以华为网络设备为例
uefi启动模式:
dhcp server next-server 192.168.50.5
dhcp server bootfile debian-installer/amd64/bootnetx64.efi
bios启动模式
dhcp server next-server 192.168.50.5
dhcp server bootfile pxelinux.0
ssh -o KexAlgorithms=+diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 user@your_server