pxe-centos

pxe服务搭建
gpxelinux.0   支持通过HTTP和FTP方式传输引导文件
pxelinux.0    基于TFTP来传输所有的启动文件
直接更改DHCP配置文件,指向到gpxelinux.0就可以了,我是直接把gpxelinux.0改名成pxelinux.0,原始配置文件基本不变
 
开机--dhcp获取ip--通过指定的tftp获取引导文件(pxelinux.0或者gpxelinux.0)--获取pxelinux.cfg/default--进行启动选项--kickstart安装
 
# cat /etc/redhat-release
CentOS Linux release 7.4 (Core)
 
IP:10.23.10.188
 
安装
# yum install xinetd dhcp tftp-server httpd syslinux -y
 
创建安装源
# mkdir -p /data/{iso,ks,os,tftpboot}
# mkdir -p /data/os/centos6
# cd /data/iso
# mount -o loop CentOS-6.10-x86_64-bin-DVD1.iso /media
# cp -r /media/* /data/os/centos6
 
配置http
# vim /etc/httpd/conf/httpd.conf
DocumentRoot "/data"
<Directory "/data">
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>
# systemctl start httpd
# systemctl enable httpd
 
配置dhcp
# vim /etc/dhcp/dhcpd.conf
allow booting;
allow bootp;
option space gpxe;
option gpxe-encap-opts code 175 = encapsulate gpxe;
option gpxe.bus-id code 177 = string;
 
subnet 10.23.10.0 netmask 255.255.255.0 {        #设定网段广播地址
       range 10.23.10.10 10.23.10.100;        #dhcp池
       option routers 10.23.10.1;        #路由
       option domain-name-servers 114.114.114.114,8.8.8.8;
       default-lease-time 36000;
       max-lease-time 86400;            #默认的租约时间,单位是秒
 
       class "pxeclients" {
               match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
               next-server 10.23.10.188;        #tftp服务器
               if not exists gpxe.bus-id {
                       filename "gpxelinux.0";       #指定引导代码文件的名字
               }
       }
}
# systemctl start dhcp
# systemctl enable dhcpd
 
配置tftp
# vi /etc/xinetd.d/tftp
disable                    = no                                                        #打开服务
server_args             = -s /data/tftpboot                                #修改目录路径
 
# vim /usr/lib/systemd/system/tftp.service
ExecStart=/usr/sbin/in.tftpd -s /data/tftpboot                      #修改目录路径
 
重新加载服务
# systemctl daemon-reload
# systemctl enable tftp
 
A.
# mkdir -p /data/tftpboot/pxelinux.cfg/
# cp /usr/share/syslinux/gpxelinux.0 /data/tftpboot/
# cp /usr/share/syslinux/memdisk /data/tftpboot/
# cp /data/os/centos6/isolinux/isolinux.cfg /data/tftpboot/pxelinux.cfg/default
 
# vim /data/tftpboot/pxelinux.cfg/default
#prompt 1
timeout 30
 
display boot.msg
 
menu background splash.jpg
menu title Welcome to CentOS 6.10!
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 mylinux
menu label ^Kickstart
menu default
 
B.
# mkdir -p /data/tftpboot/pxelinux.cfg/
# cp /usr/share/syslinux/gpxelinux.0 /data/tftpboot/
# cp /data/os/centos6/isolinux/isolinux.cfg /data/tftpboot/pxelinux.cfg/default
# cp /data/os/centos6/isolinux/{vesamenu.c32,initrd.img,vmlinuz} /data/tftpboot/
 
# vim /data/tftpboot/pxelinux.cfg/default
default vesamenu.c32
timeout 30
 
display boot.msg
 
menu background splash.jpg
menu title Welcome to CentOS 6.10!
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 mylinux
menu label ^Kickstart
menu default
kernel vmlinuz
  append initrd.img ksdevice=eth1 ks=http://10.23.10.188/ks/sen.cfg       #ksdevice=eth1双网卡时选择eth1
 
centos7 需添加inst.stage2=http://10.23.10.188/os/centos7.4
 
label kickstart
 menu label ^Install ks-CentOS7
 menu default
 
kickstart配置
# yum install system-config-kickstart pykickstart -y     #system-config-kickstart,需要图形化界面.支持中文,需要把系统语言设置为中文
 
软件包选择出现"由于下载软件包信息失败,软件包选择被禁止"
# vim /etc/yum.repos.d/ks.repo
[development]
name=ks
enabled=1
gpgcheck=0
# yum makecache
 
 
# vim /data/ks/centos6.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$VBTVqHjL$Bl/fvFhardoopS14TymjT1
# Use network installation
# System language
lang zh_CN
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
 
# Firewall configuration
firewall --enabled --ssh
# Network information
network  --bootproto=static --device=eth0 --gateway=172.23.10.1 --ip=172.23.10.189 --nameserver=223.5.5.5 --netmask=255.255.255.0
network  --bootproto=static --device=eth1 --ip=10.23.10.189 --netmask=255.255.255.0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --grow --size=1
 
%packages
@basic-desktop
@input-methods
@kde-desktop
@x11
-glx-utils
-plymouth-system-theme
-spice-vdagent
-xorg-x11-utils
-xvattr
 
%end
 
 
firewall配置
# systemctl start firewalld.service
# systemctl enable firewalld.service
# vim /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="dhcpv6-client"/>
<service name="ssh"/>
<service name="dhcp"/>
<service name="vnc-server"/>
<service name="http"/>
<port protocol="udp" port="69"/>
</zone>
 
# firewall-cmd --list-all
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: dhcpv6-client ssh dhcp vnc-server http
ports: 69/udp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

posted on 2018-11-23 10:19  森度  阅读(187)  评论(0编辑  收藏  举报

导航