準備環境:先手動安裝一臺centos6.4系統
[root@localhost ~]# mkdir /iso
[root@localhost ~]# mount -o loop /dev/cdrom /media
#注意有了兩個.開頭的文件,也要拷過去 .treeinfo與.discinfo這兩個隱藏文件
[root@localhost ~]# cp -a /media/ /iso
[root@localhost ~]# cp ks.cfg /iso/media/ #通常按照我下面配就好了
[root@localhost ~]# vim ks.cfg #rootpw能夠在手動安裝系統的anaconda-ks.cfg找到當時設置加密後的密碼
# Kickstart file automatically generated by anaconda.
install
text
cdrom
lang en_US.UTF-8
keyboard us
skipx
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$c/EHNTH5$3bRky/m4LJpozrExEQpMP1
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
# 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 --all --initlabel
part /boot --fstype=ext4 --size=200
part / --fstype=ext4 --size=30720
part swap --size=6144
part /data --fstype=ext4 --size=1 --growhtml
rebootjava
%packages
@base
@chinese-support
@core
@development
@server-policy
sgpio
cmake
lrzsz
ntplinux
%post #post做用是當系統初始化安裝完畢後須要執行的工做
# Disable unused service
chkconfig acpid off
chkconfig ip6tables off
chkconfig netfs off
chkconfig nfslock off
chkconfig restorecond off
chkconfig rpcgssd off
chkconfig rpcidmapd offexpress
[root@localhost ~]# cd /iso/media/
[root@localhost ~]# chmod +w isolinux/isolinux.cfg
[root@localhost ~]# vim isolinux/isolinux.cfg #通常按照我下面配就好了
default elive
prompt 1
timeout 50vim
display boot.msgcentos
menu background splash.jpg
menu title Welcome to CentOS 6.4!
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 elive
kernel vmlinuz
append ks=cdrom:/ks.cfg initrd=initrd.img
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -app
#精簡rpm包縮小iso鏡像文件
[root@localhost ~]# cd /iso/media/Packages/less
#刪除java、eclipse的rpm包,尋找佔用空間大且沒必要要的rpm包刪除
[root@localhost CentOS]# ls|grep ^java |xargs rm -f
[root@localhost CentOS]# ls|grep ^eclipse|xargs rm -f
[root@localhost CentOS]# du -sh
3.5G #嗯,差很少了就這樣吧
[root@localhost CentOS]# cd ..eclipse
#若是沒有mkisofs以及createrepo命令 本身yum -y install createrepo mkisofs安裝一下ide
[root@localhost media]# createrepo -g repodata/*-comps.xml /iso/media/
[root@localhost media]# mkisofs -r -T -J -V "CentOS" -joliet-long -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/CENTOS_6.4_FINAL-NEW.iso /iso/media/
[root@localhost media]# ls -lh /tmp/
-rw-r--r--. 1 root root 3.7G Aug 21 17:40 CENTOS_6.4_FINAL-NEW.iso
參考連接:http://kerry.blog.51cto.com/172631/646549/
http://www.lampbo.org/linux-xuexi/linux-advance/diy-centos6.html