和朋友今天正好聊到CentOS的自动化安装光盘制作问题,就顺便把自己之前的测试过程发出来。希望能够帮到大家。 直接发下自己之前做的时候的工作记录了,因为是工作中使用,添加了一些所需的软件包之类的东西,其实您也完全可以自由发挥,直接装完系统,一个优化好的LNMP等等众多软件都已经安装好了的系统也是完全可能的,想想网上的那些一键安装的ISO... 所以大家加油哦!后期我也会完善本篇文章的具体注释的。
下载CentOS-6.4-x86_64-minimal.iso
定制步骤:
光盘结构介绍:
安装时默认第一项是text自动安装,也可以选择第二项进行手动安装...
安装完成后的ISO: IP地址: 192.168 . 7.110
操作过程记录:
(一)挂载光盘,使用脚本拷贝相关软件包到/ISO/Packages目录下
[root@CentOS ~]# mkdir /mnt/cdrom [root@CentOS ~]# mount /dev/cdrom /mnt/cdrom [root@CentOS~]# /usr/bin/rsync -a --exclude=Packages/ --exclude=repodata/ /mnt/cdrom/ /ISO/ [root@CentOS ~]# mkdir -p /ISO/{Packages,repodata} [root@CentOS ~]# vi copy.sh #!/bin/bash cd /root awk '/Installing/{print $2}' install.log | sed 's/^*://g' >package.txt DVD='/mnt/cdrom/Packages' PACKDIR='/root/package.txt' NEW_DVD='/ISO/Packages' while read LINE do cp ${DVD}/${LINE}*.rpm /${NEW_DVD} || echo "$LINE don't cp......." done < package.txt rm -f package.txt [root@CentOS ~]# chmod +x copy.sh [root@CentOS ~]# ./copy.sh [root@CentOS ~]# ll /ISO/Packages/ |wc -l 285
(二)定制kickstart安装脚本ks.cfg,并修改/ISO/isolinux/isolinux.cfg文件,默认isolinux.cfg的权限为444,只能读,无法修改
[root@CentOS ~]# cd /ISO [root@CentOS ISO]# cp ~/anaconda-ks.cfg isolinux/ks.cfg [root@CentOS ISO]# vi isolinux/ks.cfg [root@CentOS ISO]# chmod 644 isolinux/isolinux.cfg [root@CentOS ISO]# vi isolinux/isolinux.cfg [root@CentOS ISO]# chmod 444 isolinux/isolinux.cfg
(三)安装anaconda repodata createrepo mkisofs等工具,执行createrepo程序生成repodata下的comps.xml文件
[root@CentOS ISO]# yum -y install anaconda repodata createrepo mkisofs rsync [root@CentOS ISO]# cp /mnt/cdrom/repodata/*-minimal-x86_64.xml /ISO/repodata/minimal-x86_64.xml [root@CentOS ISO]# createrepo -g repodata/minimal-x86_64.xml ./ 285/285 - Packages/audit-libs-2.2-2.el6.x86_64.rpm Saving Primary metadata Saving file lists metadata Saving other metadata [root@CentOS ISO]# declare -x discinfo=`head -1 .discinfo` [root@CentOS ISO]# echo $discinfo 1341569670.539525 [root@CentOS ISO]# createrepo -u "media://$discinfo" -g repodata/minimal-x86_64.xml . 285/285 - Packages/audit-libs-2.2-2.el6.x86_64.rpm Saving Primary metadata Saving file lists metadata Saving other metadata [root@CentOS ISO]# ll repodata/ total 724 -rw-r--r--. 1 root root 266266 Jul 17 02:30 filelists.xml.gz -rw-r--r--. 1 root root 11334 Jul 17 02:30 minimal-x86_64.xml -rw-r--r--. 1 root root 1387 Jul 17 02:30 minimal-x86_64.xml.gz -rw-r--r--. 1 root root 183083 Jul 17 02:30 other.xml.gz -rw-r--r--. 1 root root 265795 Jul 17 02:30 primary.xml.gz -rw-r--r--. 1 root root 2125 Jul 17 02:30 repomd.xml
(四)使用mkisofs命令生成ISO文件
[root@CentOS ISO]# mkisofs -o CentOS-6.4_64.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /ISO/ I: -input-charset not specified, using utf-8 (detected in locale settings) genisoimage 1.1.9 (Linux) Scanning /ISO/ Scanning /ISO/EFI Scanning /ISO/EFI/BOOT Excluded: /ISO/EFI/BOOT/TRANS.TBL Excluded: /ISO/EFI/TRANS.TBL Scanning /ISO/repodata Scanning /ISO/images Excluded: /ISO/images/TRANS.TBL Scanning /ISO/isolinux Excluded: /ISO/isolinux/TRANS.TBL Excluded by match: /ISO/isolinux/boot.cat …………………………………………. 98.05% done, estimate finish Tue Jul 17 02:43:01 2012 Total translation table size: 81205 Total rockridge attributes bytes: 35197 Total directory bytes: 59644 Path table size(bytes): 96 Done with: The File(s) Block(s) 203755 Writing: Ending Padblock Start Block 203836 Done with: Ending Padblock Block(s) 150 Max brk space used 65000 203986 extents written (398 MB)
(五)生成ISO文件MD5值 [root@CentOS ISO]# /usr/bin/implantisomd5 /ISO/CentOS-6.4_64.iso Inserting md5sum into iso image... md5 = 1355f3a08334162777e6ad867c448d2e Inserting fragment md5sums into iso image... fragmd5 = a832435cd7aeb593363287aa551476c9dd21be459aada4c29e9f3475da1e frags = 20 Setting supported flag to 0 [root@CentOS ISO]# isolinux.cfg文件内容如下:
default vesamenu.c32 #prompt 1 timeout 100 ###10秒钟 display boot.msg menu background splash.jpg menu title Welcome to use CentOS 6.4! menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000 label linux menu label ^Auto Install Xlogin Linux System menu default kernel vmlinuz append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img ###ks文件路径 label vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img xdriver=vesa nomodeset label rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff label memtest86 menu label ^Memory test kernel memtest append -
以上是整个ISO的制作所有的操作过程,看起来绝对够简单吧!附件中是ks文件,希望这篇文章能够帮到你哦! 最后找个例如winscp之类的工具将ISO文件传输到本机,就可以刻盘安装了...
本文出自 “虫子的博客” 博客,请务必保留此出处http://xlogin.blog.51cto.com/3473583/1261632 (责任编辑:IT) |