shenzhang 发表于 2018-10-22 11:36:29

PXE安装Centos 6.6 x86-64 basic server

#!/bin/bash  
######################################################################
  
#0、Centos 6.6 x86_64
  
#设置服务器IP地址为192.168.11.250
  
#确保该网络中无DHCP服务
  
#且192.168.11.100 - 200 无机器使用
  
######################################################################
  
#1、配置yum源,安装TFTP、FTP、DHCP服务
  
######################################################################
  
#!/bin/bash
  
mkdir /mnt/cdromxxx
  
umount /dev/sr0
  
mount /dev/sr0 /mnt/cdromxxx
  
mkdir /etc/yum.repos.d/bak
  
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
  
echo '
  
name=local
  
baseurl=file:///mnt/cdromxxx
  
gpgcheck=0
  
enabled=1
  
'>/etc/yum.repos.d/local.repo
  
yum install dhcp tftp-server vsftpd syslinux -y
  
rm -rf /etc/yum.repos.d/local.repo
  
mv /etc/yum.repos.d/bak/* /etc/yum.repos.d/
  
rm -rf /etc/yum.repos.d/bak
  
umount /dev/sr0
  
rm -rf /mnt/cdromxxx
  
######################################################################
  
#2、配置DHCP服务
  
######################################################################
  
#!/bin/bash
  
echo 'ddns-update-style interim;
  
ignore client-updates;
  
option space PXE;
  
option PXE.mtftp-ip    code 1 = ip-address;
  
option PXE.mtftp-cport code 2 = unsigned integer 16;
  
option PXE.mtftp-sport code 3 = unsigned integer 16;
  
option PXE.mtftp-tmout code 4 = unsigned integer 8;
  
option PXE.mtftp-delay code 5 = unsigned integer 8;
  
option arch code 93 = unsigned integer 16;
  
class "pxeclients" {
  
   match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
  
   next-server 192.168.11.250;
  
   if option arch = 00:02 {
  
      filename "ia64/elilo.efi";
  
   } else {
  
      filename "legacy/pxelinux.0";
  
   }
  
}
  
#next-server 192.168.11.250;   #指定TFTP服务器的地址
  
#filename "legacy/pxelinux.0";   #指定PXE引导程序的文件名
  
subnet 192.168.11.0 netmask 255.255.255.0 {
  
   option routers 192.168.11.1;
  
   option subnet-mask 255.255.255.0;
  
   range 192.168.11.100 192.168.11.200;
  
   option broadcast-address 192.168.11.255;
  
}
  
'>/etc/dhcp/dhcpd.conf
  
/etc/init.d/dhcpd restart
  
chkconfig dhcpd on
  
######################################################################
  
#3、配置FTP服务
  
######################################################################
  
mkdir /var/ftp/pub/isoxxx
  
mount /dev/sr0 /var/ftp/pub/isoxxx
  
echo 'mount /dev/sr0 /var/ftp/pub/isoxxx'>>/etc/rc.local
  
echo '#platform=x86, AMD64, 或 Intel EM64T
  
#version=DEVEL
  
# Firewall configuration
  
firewall --enabled --ssh
  
# Install OS instead of upgrade
  
install
  
# Use network installation
  
url --url="ftp://192.168.11.250/pub/isoxxx"
  
# Root password
  
rootpw --iscrypted $1$2B0mua0h$2VLnGqw4bvQpvEHuBhObP.
  
# System authorization information
  
auth--useshadow--passalgo=sha512
  
# Use text mode install
  
text
  
# System keyboard
  
keyboard us
  
# System language
  
lang en_US
  
# SELinux configuration
  
selinux --permissive
  
# Do not configure the X Window System
  
skipx
  
# Installation logging level
  
logging --level=info
  
# Reboot after installation
  
reboot
  
# System timezone
  
timezone --isUtc Asia/Shanghai
  
# System bootloader configuration
  
bootloader --location=mbr
  
# Clear the Master Boot Record
  
zerombr
  
# Partition clearing information
  
clearpart --all
  
# Disk partitioning information
  
part / --fstype="ext4" --grow --size=1
  

  
%packages
  
@base
  
@console-internet
  
@core
  
@debugging
  
@directory-client
  
@hardware-monitoring
  
@java-platform
  
@large-systems
  
@network-file-system-client
  
@performance
  
@perl-runtime
  
@server-platform
  
@server-policy
  
@workstation-policy
  
pax
  
oddjob
  
sgpio
  
device-mapper-persistent-data
  
samba-winbind
  
certmonger
  
pam_krb5
  
krb5-workstation
  
perl-DBD-SQLite
  
%end
  

  
%pre
  
%end
  

  
%post
  
%end
  
'>/var/ftp/pub/ks.cfg
  
/etc/init.d/vsftpd restart
  
chkconfig vsftpd on
  
######################################################################
  
#4、配置TFTP服务
  
######################################################################
  
sed -i '8 s/^/      disable=no\n/' /etc/xinetd.d/tftp
  
mkdir /var/lib/tftpboot/legacy
  
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/legacy
  
cp /var/ftp/pub/isoxxx/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/legacy
  
cp /var/ftp/pub/isoxxx/isolinux/{boot.msg,vesamenu.c32} /var/lib/tftpboot/legacy
  
mkdir /var/lib/tftpboot/legacy/pxelinux.cfg
  
echo 'default linux
  
prompt 1
  
timeout 5
  
display boot.msg
  
F1 boot.msg
  
F2 options.msg
  
F3 general.msg
  
F4 param.msg
  
F5 rescue.msg
  
label linux
  
kernel vmlinuz
  
append ks=ftp://192.168.11.250/pub/ks.cfginitrd=initrd.img ksdevice=eth0
  
'>/var/lib/tftpboot/legacy/pxelinux.cfg/default
  
/etc/init.d/xinetd restart
  
chkconfig tftp on
  
chkconfig xinetd on
  
######################################################################
  
#5、更改系统安全设置
  
######################################################################
  
setenforce 0
  
echo '# This file controls the state of SELinux on the system.
  
# SELINUX= can take one of these three values:
  
#       enforcing - SELinux security policy is enforced.
  
#       permissive - SELinux prints warnings instead of enforcing.
  
#       disabled - SELinux is fully disabled.
  
SELINUX=permissive
  
# SELINUXTYPE= type of policy in use. Possible values are:
  
#       targeted - Only targeted network daemons are protected.
  
#       strict - Full SELinux protection.
  
SELINUXTYPE=targeted'>/etc/sysconfig/selinux
  
/etc/init.d/iptables stop
  
chkconfig iptables off


页: [1]
查看完整版本: PXE安装Centos 6.6 x86-64 basic server