准备材料:
1.CentOS-7.0-1406-x86_64-DVD.iso
2.安装genisoimage工具
制作步骤:
1.复制光盘文件
1)挂载iso镜像
创建目录用于挂载光盘:
挂载iso镜像:
- mount -o loop CentOS-7.0-1406-x86_64-DVD.iso/root/centos7
复制代码
2)复制光盘文件到编辑目录进行编辑
因为挂载上iso镜像是只读的,如果要编辑,需要将文件复制出来,再编辑。首先创建编辑目录:
复制光盘文件:
- cp -rf /root/centos7/* /root/centos7_iso/
复制代码
diskinfo文件需求单独拷贝下:
- cp /root/centos7/.discinfo /root/iso
复制代码
2.编辑ks.cfg文件
系统安装的时候,按照ks.cfg文件的内容进行安装,我们把ks.cfg文件放到centos7_iso目录下:
3.进入isolinux目录,编辑isolinux.cfg文件,整个文件代码如下:
注意点:
1)memu label 后面的内容是在光盘引导起来菜单的内容,^后面的字母是菜单的快捷键;
2)通过inst.ks关键字指明ks.cfg文件位置;
3)inst.stages2标识的是系统按照介质位置,这里使用hd:LABEL表明寻找的是label为CENTOS7的安装介质,使用LABEL关键字的好处是可以精确指定安装介质,为什么label是CENTOS7,是因为我在制作光盘镜像的时候指定的,方法在后面有介绍。
4.修改镜像源配置
1)将需要增加的rpm软件包放到Packages目录下面
2)复制comps.xml文件
- [root@localhost centos7_iso]# cd /root/centos7_iso/
- [root@localhost centos7_iso]# cp /root/centos7_iso/repodata/*comps.xml comps.xml
复制代码
3)清空repodata目录
- [root@localhost centos7_iso]# rm -rf repodata/*
复制代码
4)重新生成源文件
- [root@localhost centos7_iso]# createrepo -g comps.xml .
复制代码
注意:
如果是需要删除软件包,则步骤是:
1)将需要删除的rpm软件包从Packages目录下面删除
2)复制comps.xml文件
- [root@localhost centos7_iso]# cd /root/centos7_iso/
- [root@localhost centos7_iso]# cp /root/centos7_iso/repodata/*comps.xml comps.xml
- [root@localhost centos7_iso]# vim comps.xml
复制代码
此时需要编译comps.xml文件将删除的包名从comps.xml文件里面删除
3)清空repodata目录
- [root@localhost centos7_iso]# rm -rf repodata/*
复制代码
4)重新生成源文件
- [root@localhost centos7_iso]# createrepo -g comps.xml .
复制代码
5.生成镜像
- genisoimage -v -cache-inodes -joliet-long -R -J -T -V CENTOS7 -o /root/CentOS-7-x86_64_Custom.iso -c isolinux/boot.cat -bisolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -b images/efiboot.img -no-emul-boot .
复制代码
|