- 在 Centos 7 上安裝設定 PXE 服務!
- 利用 PXE 系統,提供安裝 Linux OS 服務!
-
利用 yum 安裝 tftp Server、DHCP Server、Vsftp Server 以及 syslinux 等套件:
#yum install tftp-server dhcp syslinux vsftpd
-
設定 DHCP Server:(可參考這一篇設定)
#vim /etc/dhcp/dhcpd.conf (編寫下列內容即可!) ### 基本設定 ### ddns-update-style interim; ignore client-updates; authoritative; allow booting; allow bootp; allow unknown-clients; ### 想要配發的網路 IP 位址 ### subnet 192.168.4.0 netmask 255.255.254.0 { range 192.168.4.110 192.168.4.120; option domain-name-servers 8.8.8.8; option domain-name "example.com"; option routers 192.168.5.254; option broadcast-address 192.168.5.255; #not important default-lease-time 86400; max-lease-time 86400; ### PXE SERVER IP 位置 ### next-server 192.168.5.104; # DHCP server ip filename "pxelinux.0"; }
-
修改 tftp 套件內容:
#cd /usr/lib/systemd/system #cp tftp.service /root/tftp.service.orig #vim tftp.service [Unit] Description=Tftp Server Requires=tftp.socket Documentation=man:in.tftpd [Service] ExecStart=/usr/sbin/in.tftpd -s /tftpboot ##修改本行至合適的目錄 StandardInput=socket [Install] Also=tftp.socket
-
建立 tftpboot 目錄:
#mkdir /tftpboot
-
修改 SELinux 相關設定:
#semanage fcontext -a -t public_content_t "/tftpboot(/.*)?" #restorecon -F -R -v /tftpboot
-
將必要的 syslinux 檔案,複製到 tftp Server 分享目錄內:
#cd /usr/share/syslinux #cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /tftpboot/ #chmod 644 -R /tftpboot #chmod 755 /tftpboot #restorecon -F -R -v /tftpboot
-
在 tftp Server 目錄內,建立可提供 Linux 開機核心的目錄:
#mkdir /tftpboot/pxelinux.cfg #mkdir -p /tftpboot/netboot/ #restorecon -R -F -v /tftpboot/
-
將 Linux OS ISO 檔案內容,複製到 vsftp 分享目錄上:
#mount linux.iso /mnt #cp -R /mnt/* /var/ftp/pub
-
將 Linux PXE 開機核心檔案,放置於 tftp Server 分享目錄上:
#cd /var/ftp/pub/images/pxeboot #cp vmlinuz initrd.img /tftpboot/netboot/ #restorecon -R -F -v /tftpboot/netboot/
-
將 Linux Kstart 檔案,複製到/var/ftp/pub 目錄下:
#cp /root/anaconda-ks.cfg /var/ftp/pub/ks.cfg #chmod 644 /var/ftp/pub/ks.cfg #restorecon -R -F -v /var/ftp/pub/
-
編寫 PXE Server 開機選單:
#vim /tftpboot/pxelinux.cfg/default default menu.c32 prompt 0 timeout 30 MENU TITLE example.com PXE Menu LABEL CentOS7_x64 MENU LABEL CentOS 7.2 X86_64 KERNEL /netboot/vmlinuz APPEND initrd=/netboot/initrd.img inst.repo=ftp://192.168.5.104/pub ks=ftp://192.168.5.104/pub/ks.cfg
-
啟動各項服務:
#systemctl enable vsftpd #systemctl start vsftpd #systemctl enable tftp #systemctl start tftp #systemctl daemon-reload #systemctl enable dhcpd #systemctl start dhcpd
-
開啟防火牆設定:
#firewall-cmd --permanent --add-service=dhcp #firewall-cmd --permanent --add-service=ftp #firewall-cmd --permanent --add-service=tftp #firewall-cmd --reload
參考文獻:
- https://www.unixmen.com/install-pxe-server-and-configure-pxe-client-on-centos-7/
- https://www.unixmen.com/install-pxe-server-centos-7/
- http://www.tecmint.com/configure-pxe-server-to-install-windows-on-centos/
- http://www.tecmint.com/installing-windows-7-over-pxe-network-boot-in-centos/
- https://technet.microsoft.com/zh-tw/library/dd744541(v=ws.10).aspx
- https://technet.microsoft.com/en-us/library/cc730907(v=ws.10).aspx#Capture
- http://www.sandeploy.com/solutions/PXE-iSCSI-BOOT-SAN/Pxe-Boot-Windows/iSCSI-PXE-Boot-Windows-7.php
- http://silent.gumph.org/content/4/7/071-diskless-windows-pxe.html