系统版本:
root@zjh-server-pxe:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal
1、dhcp
安装 isc-dhcp-server
apt-get install isc-dhcp-server
修改 /etc/default/isc-dhcp-server
INTERFACESv4="ens33"
修改 /etc/dhcp/dhcpd.conf,在最后一行添加配置如下:
subnet 192.168.57.0 netmask 255.255.255.0 { range 192.168.57.100 192.168.57.200; option subnet-mask 255.255.255.0; option routers 192.168.57.2; option domain-name-servers 192.168.57.2; option broadcast-address 192.168.57.255; filename "pxelinux.0"; next-server 192.168.57.149; }
启动dhcp服务并设置开机启动
systemctl start isc-dhcp-server systemctl enable isc-dhcp-server
2、tftp
安装 tftpd-hpa
apt-get install tftp-hpa
修改 /etc/default/tftpd-hpa
TFTP_USERNAME="tftp" TFTP_DIRECTORY="/var/lib/tftpboot" TFTP_ADDRESS="0.0.0.0:69" TFTP_OPTIONS="-l -c -s"
创建 tftp目录并设置权限
mkdir /var/lib/tftpboot/ && chmod 777 /var/lib/tftpboot/
启动 tftp服务并设置开机启动
systemctl start tftpd-hpa.service systemctl enable tftpd-hpa.service
3、http
安装 apache2
apt-get install apache2
启动 apache2服务并设置开机启动
systemctl start apache2.service systemctl enable apache2.service
4、pxe
创建工作目录
mkdir /var/lib/tftpboot/Centos7.2 mkdir /var/www/html/Centos7.2
由于ubuntu20.04已经没有pxelinux.0这个启动文件,所以我们需要到官网下载
wget http://www.archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/netboot.tar.gz /var/lib/tftpboot/
解压
root@zjh-server-pxe:/var/lib/tftpboot# tar -zxvf netboot.tar.gz root@zjh-server-pxe:/var/lib/tftpboot# ls ldlinux.c32 netboot.tar.gz pxelinux.0 pxelinux.cfg ubuntu-installer version.info Centos7.2
挂载光盘并拷贝镜像文件到工作目录
root@zjh-server-pxe:~# mount /dev/sr0 /mnt/ root@zjh-server-pxe:~# cd /mnt/ root@zjh-server-pxe:/mnt# cp -r * /var/www/html/Centos7.2/
拷贝启动内核到工作目录
root@zjh-server-pxe:/mnt# cd /var/www/html/Centos7.2/isolinux/ root@zjh-server-pxe:/var/www/html/Centos7.2/isolinux# cp vmlinuz initrd.img /var/lib/tftpboot/Centos7.2/
修改 /var/lib/tftpboot/pxelinux.cfg/default
default Centos7.2 prompt 0 timeout 600 display boot.msg label Centos7.2 kernel Centos7.2/vmlinuz append initrd=Centos7.2/initrd.img repo=http://192.168.57.149/Centos7.2 ks=http://192.168.57.149/Centos7.2/ks.cfg
5、kickstart
这里可以通过安装system-config-kickstart,通过图形化界面生成ks.cfg文件;
还有一种方法就是 已经安装完成的机器上都有/root/anaconda-ks.cfg这个文件,可以改名为ks.cfg直接使用。
root@zjh-server-pxe:/var/www/html/Centos7.2# more ks.cfg #version=DEVEL # System authorization information auth --enableshadow --passalgo=sha512 # Use network installation url --url="http://192.168.57.149/Centos7.2" # Use graphical install graphical # Run the Setup Agent on first boot firstboot --enable ignoredisk --only-use=sda # Keyboard layouts keyboard --vckeymap=us --xlayouts='us','cn' # System language lang zh_CN.UTF-8 # Network information network --bootproto=dhcp --device=eno16777736 --ipv6=auto --activate network --hostname=localhost.localdomain # Root password rootpw --iscrypted $6$totlFMklPXP1obga$zC1nRV6L2YcB5ZF88Y6JjdE3OT6Vm6GBVkEmpXy22xKK9umMR5ofDJiCEoYCVuiVGDvPCGLYzX5TeXxidkhM3. # System services services --enabled="chronyd" # System timezone timezone Asia/Shanghai --isUtc user --name=zjh --password=$6$gucjhf1N9pliUxRk$VkC.HHC6QvHjm6g6mDENczlwwwGbhpgUDnqk0pOg9KCWo.5QreEp254hXlhZeAxLmKyOOU0j9ebiG1tvE4.Qh1 --iscrypted --gecos="zjh" # System bootloader configuration bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda autopart --type=lvm # Partition clearing information clearpart --none --initlabel %packages @^infrastructure-server-environment @base @core @development @dns-server @file-server @ftp-server @ha @infiniband @java-platform @mail-server @mariadb @postgresql @remote-system-management @resilient-storage chrony kexec-tools %end %addon com_redhat_kdump --enable --reserve-mb='auto' %end