一、准备rhel-server-5.4-i386-dvd.iso
二、准备4个文件
1、comps-server.xml
----来自原始光盘的repodata目录中的Server/repodata/目录中的comps-rhel5-server.xml的修改,修改方法参
考 http://cooker.techsnail.com/index.php/Custom_Linux_bootable_CD
2、install.log
----来自已经完成安装的系统,内容是选择core和base和dialup软件组后装完的系统中所带的RPM包列表。
3、makesrcdisk.sh 【未测试】 【注意:ks.cfg中有Extra目录, 但脚本中未添加Extra目录,如需要增加自己的软件,可以在上面的脚本中加入】
----安装过程脚本,内容如下,见脚本即见步骤。
#!/bin/bash
########################################################
## set parameter
########################################################
currentpath=`dirname $0`
cdromsourceiso=$currentpath/rhel-server-5.4-i386-dvd.iso
mediapath=/mnt
isoimagepath=/iso
installrpmlist=$currentpath/install.log
xmlrepofile=$currentpath/comps-hissage-server.xml
destisofile=mini32.iso
kickstartfile=$currentpath/ks_2.cfg
isomenufile=$currentpath/isolinux.cfg
if [[ -z $currentpath ]] || [[ -z $cdromsourceiso ]] || [[ -z $mediapath ]] || [[ -z $isoimagepath ]] || [[ -z $installrpmlist ]] || [[ -z $xmlrepofile ]] || [[ -z $destisofile ]]
then
echo "missing args"
exit
fi
########################################################
## mount iso image
########################################################
if [[ `ls /mnt|wc -l` -ne 0 ]]
then
echo "/mnt mount point is not empty"
exit
fi
mount -t iso9660 -o loop $cdromsourceiso /mnt
if [[ `ls /mnt|wc -l` -eq 0 ]]
then
echo "mount iso image failed"
exit
fi
########################################################
## check required rpm
########################################################
if ! rpm -qa|grep -q createrepo || ! rpm -qa|grep -q mkisofs || ! rpm -qa|grep -q rsync
then
echo "missing rpms createrepo or mkisofs or rsync"
exit
fi
########################################################
## copy required file
########################################################
rsync -av --exclude Server/ $mediapath/ $isoimagepath/
mkdir -p $isoimagepath/Server
########################################################
## copy customed rpms
########################################################
less $installrpmlist| awk -F" " '/Installing/ {print $2}'|while read line
do
line=`echo $line|sed 's/[0-9]\+:\(.*\)$/\1/'`
rpmfile=$line.rpm
if [[ ! -e $mediapath/Server/$rpmfile ]]
then
echo "not exit $rpmfile"
exit
fi
cp -a $mediapath/Server/$rpmfile $isoimagepath/Server/
done
########################################################
## create repo
########################################################
discinfo=$(head -1 $isoimagepath/.discinfo)
if [[ -z $discinfo ]] || [[ $discinfo = "" ]]
then
echo "missing discinfo"
exit
fi
/bin/rm -f $isoimagepath/Server/repodata/*
/bin/cp -f $xmlrepofile $isoimagepath/Server/repodata
createrepo -u "media://$discinfo" -g repodata/$xmlrepofile $isoimagepath/Server
########################################################
## create disk
########################################################
/bin/cp -f $isomenufile $isoimagepath/isolinux/isolinux.cfg
/bin/cp -f $kickstartfile $isoimagepath/ks.cfg
mkisofs -R -J -T -v -no-emul-boot -boot-load-size 4 -boot-info-table -V Hesine -b isolinux/isolinux.bin -c isolinux/boot.cat -o $destisofile $isoimagepath
echo "create iso success!"
4、ks.cfg
光盘kickstart文件,内容如下
install
cdrom
#xconfig --startxonboot
text
key 2515dd4e215225dd
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$ra5hd2y4$nqcZPQxT75.tewecKyf7Q1
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
firstboot --disable
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda
network --bootproto=dhcp --device=eth0 --onboot=on
reboot
# 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 --linux
#part swap --recommended
#part / --fstype ext3 --size=7000 --grow
%post --nochroot --log=/mnt/sysimage/root/copy.log --erroronfail
#!/bin/sh
mkdir -p /mnt/cdrom
mount -t iso9660 /tmp/cdrom /mnt/cdrom
cp -a /mnt/cdrom/Extra /mnt/sysimage
umount /mnt/cdrom
%post --log=/mnt/sysimage/root/post.log --erroronfail
#!/bin/sh
cd /Extra/software
/bin/bash /Extra/software/postscript.sh
%packages
@base
@core
@dialup
5.isolinux.cfg
修改头三行为
default linux ks=cdrom:/ks.cfg
prompt 1
timeout 1
三、必备软件包
rsync、createrepo、mkisofs
四、运行脚本
makesrcdisk.sh
五、制作Redhat6.0安装光盘
因为光盘目录有变化,因此制作库的软件包有升级,拷贝文件的脚本有变化,其他雷同
脚本如下
makesrcdisk.sh脚本如下
#!/bin/bash
六、参考
http://cooker.techsnail.com/index.php/Custom_Linux_bootable_CD
http://www.redhat.com/archives/kickstart-list/2011-March/msg00007.html
http://forums.fedoraforum.org/showthread.php?t=247303
http://www.linuxquestions.org/questions/red-hat-31/create-custom-rhel5-4-iso-802845/
http://www.linuxtopia.org/online_books/rhel6/rhel_6_migration_guide/rhel_6_migration_ch02s02s02s04.html