定制CentOS,增加自己的内容

本文详细介绍了如何基于 CentOS 6.3 制作自定义 ISO 镜像,包括安装工具、复制安装盘内容、编写 ks.cfg 文件、声明使用 ks.cfg 文件、生成 repo 文件及最终生成 ISO 的全过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考: http://kling.blog.51cto.com/3320545/1249962

1.   安装工具

yum -y install createrepo mkisofs

2.   复制CentOS6.3的安装盘内容到相应目录

假如到‘/root/iso/’目录下,注意隐藏文件

cp -rf /mnt/cdrom/* /root/iso/

cp -rf /mnt/cdrom/.discinfo  /root/iso/

cp -rf /mnt/cdrom/.treeinfo  /root/iso/

3.   编写ks.cfg文件

从已加载好的系统上拷贝一个

cp/root/anaconda-ks.cfg /root/iso/isolinux/ks.cfg

目前修改了ks.cfg中的内容只有:

3.1   注释掉了一行

#repo--name="Packages"  --baseurl=cdrom:sr0--cost=100

3.2   删除两行

删除了关于eth1和eth2的信息,只保留eth0的

network--onboot no --device eth0 --bootproto dhcp --noipv6

3.3   增加自定义包

在packages模块增加声明:

%packages

@core

@ kimchi-master

其中kimchi-master模块就是自定义的模块名字,对应到repodata目录下的comps.xml中的某个group-id.

修改repodata/comps.xml文件:

<group>

   <id>kimchi-master</id>

   <name>Kimchi master</name>

   <name xml:lang='es'>Kimchi master</name>

   <default>true</default>

   <uservisible>true</uservisible>

   <packagelist>

       <packagereq type="mandatory">GeoIP</packagereq>

       <packagereq type="mandatory">PyPAM</packagereq>

       <packagereq type="mandatory">autoconf</packagereq>

       <packagereq type="mandatory">automake</packagereq>

       <packagereq type="mandatory">cloog-ppl</packagereq>

       <packagereq type="mandatory">cpp</packagereq>

       <packagereq type="mandatory">elfutils</packagereq>

       <packagereq type="mandatory">elfutils-libs</packagereq>

       <packagereq type="mandatory">gcc</packagereq>

       <packagereq type="mandatory">gd</packagereq>

       <packagereq type="mandatory">gdb</packagereq>

       <packagereq type="mandatory">gettext-devel</packagereq>

       <packagereq type="mandatory">gettext-libs</packagereq>

       <packagereq type="mandatory">glibc-devel</packagereq>

       <packagereq type="mandatory">glibc-headers</packagereq>

       <packagereq type="mandatory">kernel-headers</packagereq>

       <packagereq type="mandatory">libXpm</packagereq>

       <packagereq type="mandatory">libgcj</packagereq>

       <packagereq type="mandatory">libtool</packagereq>

       <packagereq type="mandatory">libtool-ltdl</packagereq>

       <packagereq type="mandatory">libtool-ltdl-devel</packagereq>

       <packagereq type="mandatory">m2crypto</packagereq>

       <packagereq type="mandatory">make</packagereq>

       <packagereq type="mandatory">mpfr</packagereq>

       <packagereq type="mandatory">nginx</packagereq>

       <packagereq type="mandatory">patch</packagereq>

       <packagereq type="mandatory">ppl</packagereq>

       <packagereq type="mandatory">pyparted</packagereq>

       <packagereq type="mandatory">python-cheetah</packagereq>

       <packagereq type="mandatory">python-cherrypy</packagereq>

       <packagereq type="mandatory">python-decorator</packagereq>

       <packagereq type="mandatory">python-ethtool</packagereq>

       <packagereq type="mandatory">python-imaging</packagereq>

       <packagereq type="mandatory">python-ipaddr</packagereq>

       <packagereq type="mandatory">python-jsonschema</packagereq>

       <packagereq type="mandatory">python-lxml</packagereq>

       <packagereq type="mandatory">python-markdown</packagereq>

       <packagereq type="mandatory">python-ordereddict</packagereq>

       <packagereq type="mandatory">python-psutil</packagereq>

       <packagereq type="mandatory">python-pygments</packagereq>

       <packagereq type="mandatory">python-setuptools</packagereq>

       <packagereq type="mandatory">python-unittest2</packagereq>

       <packagereq type="mandatory">rpm-build</packagereq>

       <packagereq type="mandatory">sos</packagereq>

       <packagereq type="mandatory">unzip</packagereq>

       <packagereq type="mandatory">xz-lzma-compat</packagereq>

       <packagereq type="mandatory">zip</packagereq>

       <packagereq type="mandatory">kimchi</packagereq>

   </packagelist>

  </group>

# 同时,要在类中对group进行声明

<category>

   <id>base-system</id>

   <name>Base System</name>

   <description xml:lang='es'>Componentes de sistema Core</description>

   <grouplist>

    <groupid>backup-client</groupid>

    <groupid>base</groupid>

  <groupid>cloud-agent</groupid>

  <groupid>kimchi-master</groupid>

   </grouplist>

</category>

当然,这需要提前将需要的安装包(group中packagelist声明的内容)放到Package目录中。

所以需要自己事前将需要的包过滤出来,通常可以在现成的环境上用yum安装某个部件,如cloud-agent,在安装时,会自动将需要的依赖包显示出来。然后把这些包拷贝过来,其它不涉及的包忽略。

4.   声明使用ks.cfg文件

vi /root/iso/isolinux/isolinux.cfg

#修改isolinux.cfg中第一个label

#initrd=initrd.img修改成下面的

append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img

红色为新增。

5.   生成repo文件

生成一些文件的关联关系:

注意:此处的命令很重要,有某次,因为下面的某一个命令没有执行,就导致iso安装失败。

createrepo -g repodata/comps.xml /root/iso/

declare -x discinfo=`head -1 .discinfo`

createrepo -u "media://$discinfo" -g repodata/comps.xml /root/iso/

6.   生成iso

使用命令:

mkisofs -o CentForOS6.3.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /root/iso/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值