建个PXE服务器,通过PXE服务器安装Linux还是很方便的。

  • 安装
sudo yum -y install syslinux xinetd tftp-server
mkdir /home/data/tftpboot/pxelinux.cfg
cp -rf /usr/share/syslinux/pxelinux.0 /home/data/tftpboot
sudo chcon -ht tftpdir_rw_t /home/data/tftpboot
  • 启动TFTP

编辑/etc/xinetd.d/tftp

disable = no #yes改成no
        server_args             = -s /var/lib/tftpboot

改成

        server_args             = -s /home/data/tftpboot
sudo systemctl enable xinetd
sudo systemctl start xinetd
  • 编辑/home/data/tftpboot/pxelinux.cfg/default文档

内容如下:

#default vesamenu.c32
timeout 30
#default menu.c32
#prompt 0
default vesamenu.c32
prompt 1

menu title ########## PXE Boot Menu ##########
label 1
        menu label ^1) Fedora29 LiveCD
        kernel fedora/vmlinuz
        append initrd=fedora/initrd.img root=live:nfs://192.168.1.24:/home/data/tftpboot/fedora/source/LiveOS/squashfs.img ro rd.live.image rd.lvm=0 rd.luks=0 rd.md=0 rd.dm=0 vga=794
label 2
        menu label ^2) CentOS 7 Installer(NFS)
        kernel centos7/vmlinuz
        append initrd=centos7/initrd.img inst.stage2=nfs:192.168.1.24:/home/data/tftpboot/centos7/source devfs=nomount

label 3
        menu label ^3) Rescue Installed System
        kernel centos7/vmlinuz
        append initrd=centos7/initrd.img inst.stage2=nfs:192.168.1.24:/home/data/tftpboot/centos7/source rescue devfs=nomount

label 4
        menu label ^5) Install Windows 10 x64
        KERNEL memdisk
        INITRD windows/Win10PE_amd64.iso
        APPEND iso raw

label 5
        MENU DEFAULT
        menu label ^6) Boot from local drive
#       localboot 0xffff
        localboot 0
  • 设置DHCP

添加如下信息:

filename        "pxelinux.0";
next-server     10.150.20.1;
sudo systemctl restart dhcpd
  • 防火墙
firewall-cmd --permanent --add-service=tftp
firewall-cmd --reload

Related content