Chinaunix首页 | 论坛 | 博客
  • 博客访问: 453003
  • 博文数量: 144
  • 博客积分: 5675
  • 博客等级: 大校
  • 技术积分: 1512
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-20 10:46
文章分类

全部博文(144)

文章存档

2014年(1)

2013年(1)

2012年(12)

2011年(39)

2010年(48)

2009年(29)

2008年(14)

我的朋友

分类: LINUX

2011-09-19 20:35:48

1、  在虚拟机中安装系统,选择所需的设置和软件包

2、  安装定制光盘所需软件

yum –y install createrepo mkisofs

3、  生成安装系统所需的rpm文件列表

awk '/Installing/{print $2}' install.log |sed 's/^[0-9]*://g' >/root/packages.list

4、  创建定制工作目录

mkdir /home/OS mount /dev/cdrom /mnt rsync –a --exclude=CentOS /mnt/ /home/OS mkdir /home/OS/CentOS

5、  复制系统安装所需rpm包
复制脚本cprpm.sh

#!/bin/bash DEBUG=0 DVD_CD=/disk/CentOS ALL_RPMS_DIR=/mnt/cdrom/CentOS/ DVD_RPMS_DIR=$DVD_CD packages_list=/root/packages.list number_of_packages=`cat $packages_list | wc -l` i=1 while [ $i -le $number_of_packages ] ; do line=`head -n $i $packages_list | tail -n -1` name=`echo $line | awk '{print $1}'` version=`echo $line | awk '{print $3}' | cut -f 2 -d :` if [ $DEBUG -eq "1" ] ; then echo $i: $line echo $name echo $version fi if [ $DEBUG -eq "1" ] ; then ls $ALL_RPMS_DIR/$name-$version* if [ $? -ne 0 ] ; then echo "cp $ALL_RPMS_DIR/$name$version* " fi else echo "cp $ALL_RPMS_DIR/$name-$version* $DVD_RPMS_DIR/" cp $ALL_RPMS_DIR/$name$version* $DVD_RPMS_DIR/ # in case the copy failed if [ $? -ne 0 ] ; then echo "cp $ALL_RPMS_DIR/$name$version* " cp $ALL_RPMS_DIR/$name* $DVD_RPMS_DIR/ fi fi i=`expr $i + 1` done

运行脚本复制文件到/home/OS/CentOS下

chmod +x cprpm.sh ./cprpm.sh

复制gcc和gcc-c++所需的7个rpm包

gcc: kernel-headers glibc-headers glibc-devel cpp gcc gcc-c++: libstdc++-devel gcc-c++

6、  定制kickstart文件ks.cfg

文件从/root/anaconda-ks.cfg中复制修改,修改如下
①   安装gcc和gcc-c++
②   移除sendmail, firstboot-tui, bluez-utils
③   关闭不使用的服务

/home/OS/ks.cfg内容如下:

# Kickstart file automatically generated by anaconda. install cdrom lang en_US.UTF-8 keyboard us network --device eth0 --bootproto dhcp rootpw --iscrypted $1$yDf6lXw3$bRYzQP269EcdjAy8qeOo30 firewall --enabled --port=22:tcp authconfig --enableshadow --enablemd5 selinux --enforcing timezone Asia/Shanghai 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 --drives=sda #part /boot --fstype ext3 --size=100 --ondisk=sda #part pv.2 --size=0 --grow --ondisk=sda #volgroup VolGroup00 --pesize=32768 pv.2 #logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow #logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512 --grow --maxsize=1024 %packages @base @core gcc gcc-c++ keyutils iscsi-initiator-utils trousers fipscheck device-mapper-multipath -sendmail -firstboot-tui -bluez-utils %post # Disable unused service chkconfig acpid off chkconfig anacron off chkconfig ip6tables off chkconfig lvm2-monitor off chkconfig netfs off chkconfig nfslock off chkconfig pcscd off chkconfig portmap off chkconfig restorecond off chkconfig rpcgssd off chkconfig rpcidmapd off

7、  修改/home/OS/isolinux/isolinux.cfg

把第一行的default linux改成default text ks=cdrom:/ks.cfg

 

8、  生成comps.xml

cd /home/OS declare -x discinfo=`head -1 .discinfo` createrepo –g repodata/comps.xml . 或者createrepo –g repodata/comps.xml /home/OS/

 

9、  生成ISO文件

cd /home/OS mkisofs -o CentOS-5.6-i386-CD.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /home/OS

/home/OS/CentOS-5.6-1386-CD.iso即生成的ISO文件,可以用虚拟机测试一下哦!

阅读(1257) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~