PXE 02-CentOS6部署PXE

1. 部署http服务,我使用Nginx

yum install -y nginx

2. 安装dhcp服务

yum install -y dhcp

配置dhcp

[root@PXE ~]# cat /etc/dhcp/dhcpd.conf 
filename "pxelinux.0";
next-server 192.168.124.75;
subnet 192.168.124.0 netmask 255.255.255.0 {
  range 192.168.124.80 192.168.124.99;
  option subnet-mask 255.255.255.0;
}

开启服务

service dhcpd start

3. 安装其他服务

yum install -y tftp-server syslinux
[root@PXE ~]# cat /etc/xinetd.d/tftp 
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
service xinetd start

4. 下载镜像

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

mkdir /application/nginx/html/centos6
cp -r /mnt/cdrom/* /application/nginx/html/centos6/

5. 安装kickstart

yum install -y system-config-kickstart

6. 配置安装要求

mkdir /application/nginx/html/ksdir/
vi /application/nginx/html/ksdir/ks6.cfg

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.124.75/centos6"
# Root password
rootpw --iscrypted $1$5TA.u5mx$Eij791o1Swqnv9EPJ3kmr1
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --enforcing
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network  --bootproto=static --device=eth0 --gateway=192.168.124.254 --ip=192.168.124.99 --netmask=255.255.255.0 --onboot=on
#network        --bootproto=dhcp --device=eth0
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=1

shutdown now

%packages
@base
%end

%post # 安装后脚本,安装完系统后向做什么配置,都可以写在%post...%end中间
for con in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $con off;done
for con in crond network rsyslog sshd sysstat;do chkconfig --level 3 $con on;done

%end
chmod +r  /application/nginx/html/ksdir/ks6.cfg

7. 部署加载文件

cp /application/nginx/html/centos6/isolinux/{initrd.img,vmlinuz,boot.msg} /var/lib/tftpboot/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg

[root@PXE pxelinux.cfg]# cat /var/lib/tftpboot/pxelinux.cfg/default 
default linux
#prompt 1
timeout 600
#display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.6!
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 linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.124.75/ksdir/ks6.cfg

ks.cfg图形界面文件配置

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.124.75/centos6"
# Root password
rootpw --iscrypted $1$5TA.u5mx$Eij791o1Swqnv9EPJ3kmr1
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network  --bootproto=static --device=eth0 --gateway=192.168.124.254 --ip=192.168.124.99 --netmask=255.255.255.0 --onboot=on
#network        --bootproto=dhcp --device=eth0
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=1

shutdown now

#GUI
%packages
@base
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
mtools
pax
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
%end

%post # 安装后脚本,安装完系统后向做什么配置,都可以写在%post...%end中间
for con in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $con off;done
for con in crond network rsyslog sshd sysstat;do chkconfig --level 3 $con on;done

%end
posted @ 2018-07-17 11:34  瞎搞的富哥  阅读(210)  评论(0)    收藏  举报