yum -y install tftp-server httpd dhcp syslinux
html
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
egrep -v "^#|^$" /etc/dhcp/dhcpd.conf
linux
option domain-name "contoso.com"; option domain-name-servers ns1.contoso.com, contoso.com; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 192.168.10.0 netmask 255.255.255.0 { //服务端IP网段及掩码 option routers 192.168.10.254; //网关 option subnet-mask 255.255.255.0; //掩码 option domain-name-servers 192.168.10.2; range dynamic-bootp 192.168.10.100 192.168.10.120; //dhcp分发的地址范围 default-lease-time 21600; //设置默认的IP租用期限 max-lease-time 43200; //设置最大的IP租用期限 next-server 192.168.10.7; //TFTP服务器地址 filename "pxelinux.0"; //指定引导文件位置,这里是TFTP根目录下的pxelinux.0 }
systemctl start dhcpd.service
# default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = yes per_source = 11 cps = 100 2 flags = IPv4 }
[Unit] Description=Tftp Server Requires=tftp.socket Documentation=man:in.tftpd [Service] ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot StandardInput=socket [Install] Also=tftp.socket
启动tftp-server服务
systemctl start tftp.socket
vim
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
#基于pxe安装使用的光盘上的文件(本身本地挂载光盘便可)或者是yum仓库里mkdir /var/lib/tftpboot/pxelinux.cfg/
default menu.c32 #加载时显示的默认菜单控制的程序(配置没法启动,menu.c32 改为Linux) prompt 5 #显示提示符时间 timeout 30 #超时时长 MENU TITLE CentOS 7 PXE Menu #标题为CentOS7 PXE Menu LABEL linux #指明下面菜单项的label MENU LABEL Install CentOS 7 x86_64 #菜单的label KERNEL vmlinuz #指明kernel文件 APPEND initrd=initrd.img inst.repo=http://192.168.121.17/centos7 ks=http://192.168.121.17/centos7.cfg #附加给kernel的参数,inst.repo能够是教室的ftp服务器,或者把光盘当作yum仓库,把它做为一个网站的访问就能够了
mkdir -pv /media/cdrom
mount -r /dev/cdrom /media/cdrom
mkdir -pv /var/www/html/centos7/
mount --bind /media/cdrom /var/www/html/centos7
centos
#platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$kncWgT41$Z37pYAKljSaTTQ4EadDqE1 # Use network installation url --url="http://10.2.1.10/centos7" # System language lang en_US # System authorization information auth --useshadow --passalgo=sha512 # Use text mode install text # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=ens33 network --hostname=localhost.pxe # Reboot after installation reboot # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --location=mbr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="xfs" --size=1024 part swap --fstype="swap" --size=4096 part / --fstype="xfs" --grow --size=1 %post systemctl disable postfix.service %end %packages @^minimal @compat-libraries @debugging @development bash-completion dos2unix lrzsz nmap sysstat tree vim wget %end