定制linux自动化安装镜像
安装必须的软件
yum -y install createrepo mkisofs anaconda-runtime
yum -y install rsync
制作镜像基本模型
mkdir /yousm/CentOS6.2 #创建镜像目录
mount /dev/cdrom /mnt #挂载现有的安装系统盘
/usr/bin/rsync -a --exclude=Packages/--exclude=repodata/ /mnt/ /yousm/CentOS6.2 #同步镜像的基本文件(rsync可以复制隐藏文件)
mkdir /yousm/CentOS6.2/Packages
mkdir /yousm/CentOS6.2/repodata
获取系统需要的安装包
awk ‘/Installing/{print $2}‘ install.log|sed ‘s/^[0-9]*://g‘ >/root/packages.list #将系统的安装包写入packages.list
for fileRpm in `cat packages.list`;do cp –r /mnt/Packages/$fileRpm*/yousm/CentOS6.2 /Packages ; done #复制系统安装包
生产rpm包依赖关系
cp /mnt/repodata/*-minimal-i386.xml /yousm/CentOS6.2/repodata/minimal-i386.xml
cd /yousm/CentOS6.2
createrepo -g repodata/minimal-i386.xml ./
declare -x discinfo=`head -1 .discinfo`
createrepo -u"media://$discinfo" -grepodata/ebdb6ed3f5842c0d6445a25f41e51d724f5768798d417e6353ff6a4a6ae52024-minimal-i386.xml.
修改替换isolinux文件和添加自动应答文件ks.cfg
cp isolinux.cfg /yousm/CentOS6.2/isolinux/
mkdir /yousm/CenytOS6.2/ks
cp ks.cfg /yousm/CentOS6.2/ks/
ks.cfg文件见附件
封装iso镜像和md5校验
mkisofs -o CentOS-6.2_X86.iso -bisolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4-boot-info-table -R -J -v -T /yousm/CentOS6.2/
/usr/bin/implantisomd5./CentOS-6.2_X86.iso