1,下载光盘

http://mirrors.163.com/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso


2,挂载光盘

#mount /dev/cdrom /mnt


3,cp光盘

#cd

#mkdir iso

#rsync -av /mnt/ /root/iso/


4,修改isolinux.cfg

 append initrd=initrd.img ks=cdrom:/ks.cfg


5,准备ks.cfg文件

# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
cdrom

text
lang en_US.UTF-8
keyboard us
firewall --disabled
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $1$kfLaJM67$LIlVx1fz9kAyYXk.XtnA3.

reboot

firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
selinux --disabled
# Do not configure the X Window System
skipx
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --none
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel

part /boot --fstype="ext4" --size=200
part pv.008002 --size=61440
volgroup vg0 --pesize=8192 pv.008002
logvol / --fstype=ext4 --name=root --vgname=vg0 --size=20480
logvol swap --name=swap --vgname=vg0 --size=2048
logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=10240
logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=20480


#repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100

reboot


%packages --nobase
@core

vim-minimal
%end

%post

/etc/init.d/NetworkManager stop
chkconfig NetworkManager off
cd /etc/yum.repos.d/
tar jcvf /etc/yum.repos.d/repo.tar.bz2 * &>/dev/null
rm -rf /etc/yum.repos.d/*.repo
cat >/etc/yum.repos.d/centos.repo <<!
[epel]
name=epel
baseurl=http://192.168.100.100/epel-x86_64/
enaled=1
gpgcheck=0
cost=1000          
[centos6]
name=centos6
baseurl=http://192.168.100.100/centos6.5-x86_64/
enaled=1
gpgcheck=0
cost=1000  
!

yum -y install gcc gcc-c++ vim-enhanced unzip unrar sysstat
#配置ntpdate自动对时
yum -y install ntp
echo "01 01 * * * /usr/sbin/ntpdate ntp.api.bz    >> /dev/null 2>&1" >> /etc/crontab
ntpdate ntp.api.bz
service crond restart
#配置文件的ulimit值
ulimit -SHn 65535
echo "ulimit -SHn 65535" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
*                     soft     nofile             60000
*                     hard     nofile             65535
EOF
#tune kernel parametres(基础系统内核优化)
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024 65535
EOF
/sbin/sysctl -p
#禁用control-alt-delete组合键以防止误操作
sed -i 's/^exec/#exec/g' /etc/init/control-alt-delete.conf
#关闭SElinux
sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config
#ssh服务配置优化
sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' /etc/ssh/sshd_config
sed -i 's@#UseDNS yes@UseDNS no@' /etc/ssh/sshd_config
service sshd restart
#禁用ipv6地址
echo "alias net-pf-10 off" >> /etc/modprobe.conf
echo "alias ipv6 off" >> /etc/modprobe.conf
echo "install ipv6 /bin/true" >> /etc/modprobe.conf
echo "IPV6INIT=no" >> /etc/sysconfig/network
sed -i 's@NETWORKING_IPV6=yes@NETWORKING_IPV6=no@'    /etc/sysconfig/network
chkconfig ip6tables off
#vim基础语法优化
echo "syntax on" >> /root/.vimrc
echo "set nohlsearch" >> /root/.vimrc
#停用系统中不必要的服务
chkconfig bluetooth off
chkconfig sendmail off
chkconfig kudzu off
chkconfig nfslock off
chkconfig portmap off
chkconfig iptables off
chkconfig autofs off
chkconfig yum-updatesd off



%end


5,做成光盘

mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot -allow-leading-dots -no-bak -o ./CentOS-6.5-x86_64-mini.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /root/iso