一、基础环境的搭建
1.1、操作环境:
VM7.1(版本不限)+CentOS6.4X86_64
VM需设置2个光驱,分别挂载DVD1和DVD2
安装centos6.4X 86_64系统,所需组件自行定义,安装后得到install.log和anaconda-ks.cfg文件(在此基础上修改比较方便)
[root@test01]#mkdir /mnt/cd{1,2} #建立光盘的挂载目录
[root@test01]#mkdir -p /home/ klcentos/Packages #建立定制光盘文件目录
[root@test01]#mount /dev/cdrom /mnt/cd1 #挂载DVD1
[root@test01]#mount /dev/cdrom1 /mnt/cd2 #挂载DVD2
说明:由于此处是采用的最大化软件安装,故需要用到DVD2,如不是最大化安装,则可以只用DVD1
推荐阅读:
CentOS 6.4 Grub加密码 http://www.linuxidc.com/Linux/2013-07/87124.htm
CentOS 6.4可以读写ntfs磁盘设备的方法 http://www.linuxidc.com/Linux/2013-07/86768.htm
CentOS 6.4 x64 minimal安装后的基本操作 http://www.linuxidc.com/Linux/2013-06/86593.htm
二、定制系统文件的准备
新定制系统由以上系统组件包说决定,文件由install.log安装日志得来
[root@test01]# vim /home/kuangl/cp_packages.sh
#!/bin/bash
for i in $(awk ‘/Installing/ {print $2}’ install.log)
do
cp /mnt/cd1/Packages/${i}.rpm /home/kuangl/klcentos/Packages
[ $? != 0 ] && echo “copy ${i} is faied”
done
rsync -a –exclude=Packages /mnt/cd1/ /home/kuangl/klcentos
三、重新生成repo文件
[root@test01]# vim /home/kuangl/klcentos/discinfo.sh
#!/bin/bash
ISO_DIR=/home/kuangl/klcentos
cd ${ISO_DIR}
declare -x discinfo=$(head -1 .discinfo)
mv ${ISO_DIR}/repodata/*x86_64-comps.xml ${ISO_DIR}/repodata/c6-x86_64-comps.xml
createrepo -g ${ISO_DIR}/repodata/c6-x86_64-comps.xml ${ISO_DIR}
createrepo -u “media://$discinfo” -g ${ISO_DIR}/repodata/*c6-x86_64-comps.xml ${ISO_DIR}
四、ks文件的准备
ks文件由系统安装所得anaconda-ks.cfg进行修改,当然也可以用system-config-kickstart工具制作而得,此处省略ks制作方法。
[root@test01]# vim /home/kuangl/klcentos/isolinux/ks.cfg
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
text
cdrom
lang en_US.UTF-8
keyboard us
skipx
network –onboot no –device eth0 –bootproto static –ip 192.168.5.30 –netmask 255.255.255.0 –gateway 192.168.5.1 –noipv6 –nameserver 8.8.8.8
rootpw 123456
firewall –service=ssh –port=80:tcp
authconfig –enableshadow –passalgo=sha512
selinux –disabled
timezone –utc Asia/Shanghai
bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto rhgb quiet”
# 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
clearpart –all –initlabel
zerombr
part /boot –fstype=ext4 –size=2000
part swap –size=2000
part / –fstype=ext4 –grow –size=200
reboot
#repo –name=”CentOS” –baseurl=cdrom:sr0 –cost=100
%packages
@core
@server-policy
%end
五、引导文件的修改
[root@test01 ]# vim /home/kuangl/klcentos/isolinux/isolinux.cfg
default auto
timeout 600
#default vesamenu.c32
#prompt 1
timeout 600
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 auto
menu label ^Auto Install system
menu default
kernel vmlinuz
append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
六、ISO文件的生成
[root@test01 klcentos]# mkisofs -o klcentos.iso -input-charset utf-8 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -V klcentos -T /home/kuangl/klcentos
生成结果如下:
[root@test01 klcentos]# ll
七、测试安装
7.1、创建虚拟机
7.2、启动虚拟机
7.3、安装Packages包
7.4、安装完毕,登陆系统
CentOS6.4X86_64系统定制完毕,定制完成之后安装系统只需要几分钟时间哦,是不是很方便。
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14