制作CentOS 6.4自动安装光盘iso镜像

准备环境:先手动安装一台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 --grow

reboot

%packages
@base
@chinese-support
@core
@development
@server-policy
sgpio
cmake
lrzsz
ntp

%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 off

[root@localhost ~]# cd /iso/media/
[root@localhost ~]# chmod +w isolinux/isolinux.cfg
[root@localhost ~]# vim isolinux/isolinux.cfg #一般按照我下面配就行了
default elive
prompt 1
timeout 50

display boot.msg

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 -

#精简rpm包缩小iso镜像文件
[root@localhost ~]# cd /iso/media/Packages/

#删除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 ..

#如果没有mkisofs以及createrepo命令 自己yum -y install  createrepo mkisofs安装一下

[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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值