分类: LINUX
2010-02-06 19:30:17
一、系统准备
1、CentOS系统
2、CentOS安装光盘
二、详细步骤
1、在用户目录下新建目录iso及其子目录CentOS
# mkdir -pv /root/iso/CentOS
2、挂载CentOS光盘到/media目录下
# mount /dev/cdrom /media
3、写一个脚本从/root/install.log中提取需要的安装包
#!/bin/bash
awk '{print $2}' /root/install.log | sed > pack.txt
FILE='/root/pack.txt'
DIR1='/media/CentOS'
DIR2='/root/iso/CentOS'
while read LINE
do
cp -v $DIR1/$LINE.rpm $DIR2 || echo "The $LINE cann't copy...." &> /root/error.txt
done < $FILE
# bash cp.sh
4、复制光盘上文件到/root/iso目录下
# cd /media/
# cp -rv .discinfo .treeinfo images/ isolinux/ repodata/ RPM-GPG-KEY-CentOS-5 EULA GPL /root/iso
5、复制/root/anaconda-ks.cfg 到/root/iso/下并改名为ks.cfg
# cp /root/anaconda-ks.cfg /root/iso/ks.cfg
6、编辑ks.cfg
text
cdrom
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$XZbjukW/$Cg90V.dpQ/K4nRaT3fBTV/
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc America/New_York
bootloader --location=mbr --driveorder=sda
# 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 / --fstype ext3 --size=6000
part swap --size=1024
bootloader
reboot
%packages
@base
@core
@dialup
@editors
@text-internet
keyutils
trousers
fipscheck
device-mapper-multipath
reboot
7、编辑isolinux.cfg
# vim /root/iso/isolinux/isolinux.cfg
在第一行“linux”后面插入 ks=cdrom:/ks.cfg
然后强行写入 w!
8、解决RPM包的依赖关系
# cd /root/iso
# createrepo -g repodata/comps.xml ./
9、封装ISO
# cd /root/iso
# mkisofs -o MyCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T iso/
好了,打工告成!挂在镜像,直接安装吧。全自动精简版~~~