PXE

PXE是什么

preboot excution environment即预启动执行环境

在CentOS上的部署

  • dhcp (ip/netmask, gw, dns; filename, next-server;)
  • tftp server (bootloader, kernel, initrd)
  • kickstart

配置tftp server

端口是:69/udp

CentOS 6:
	chkconfig  tftp  on
	service  xinetd restart
	
CentOS 7:
	systemctl  start  tftp.socket

默认的文件根目录:/var/lib/tftpboot/

dhcp server:

配置示例

option domain-name "magedu.com";
option routers 192.168.10.9;
option domain-name-servers 172.18.0.1;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
    range 192.168.10.101 192.168.10.120;
    filename "pxelinux.0";
    next-server 192.168.10.9;
} 

配置PXE环境

CentOS 7

yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot
cp /usrshare/systelinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg/
vim /var/lib/tftpboot/pxelinux.cfg/default
    default menu.c32
    prompt 5
    timeout 30
    MENU TITLE CentOS 7 PXE Menu

    LABEL linux
    MENU LABEL Install CentOS 7 x86_64
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=http://192.168.10.9/centos/7/x86_64
    LABEL linux_autoinst
    MENU LABEL Install CentOS 7 x86_64 auto
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=http://192.168.10.9/centos/7/x86_64 ks=http://192.168.10.9/kickstarts/centos7.cfg            

CentOS 6

yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /media/cdrom/isolinux/{boot.msg,vesamenu.c32,splash.png} /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg/       
cp /media/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

内容如下所示

display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.7 MageEdu!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label autoinst
menu label ^Auto Install CentOS
menu default
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.10.16/pub/centos6.cfg
label linux
menu label ^Install or upgrade an existing system
kernel vmlinuz
append initrd=initrd.img
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
原文地址:https://www.cnblogs.com/xuelong3/p/7628070.html