• CentOS 6.4一键自动化安装ISO镜像光盘


    下载CentOS-6.4-x86_64-minimal.iso

    1

    http://mirrors.163.com/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso

    定制步骤:

    1

    2

    3

    4

    5

    6

    7

    1、安装一个干净的操作系统.包括基本的系统和所需要的工具等.

    比如:对于http,mysql等软件,建议使用编译的方式安装, 然后打包放进去,可以减少许多依赖包的麻烦.

    2、安装系统后,收集系统已安装的软件包,使用脚本统一转存到一个目录中.

    3、在安装光盘复制images镜像,从光盘启动centos安装所需的文件等.

    4、定义自己的kickstart安装脚本.

    5、按照之前转存的软件(rpm)包, 重新生成光盘的report信息.

    6、打包生成ISO文件,及MD5效验码.

    光盘结构介绍:

    1

    2

    3

    4

    * isolinux目录存放光盘启动时的安装界面信息

    * images目录包括了必要的启动映像文件

    * CentOS目录存放安装软件包及信息

    * .discinfo文件是安装价质的识别信息

       安装时默认第一项是text自动安装,也可以选择第二项进行手动安装...

    安装完成后的ISO:

    IP地址:192.168.7.110

      root密码:nopassword


    操作过程记录:


    (一)挂载光盘,使用脚本拷贝相关软件包到/ISO/Packages目录下

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    [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,只能读,无法修改

    1

    2

    3

    4

    5

    6

    [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文件

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    [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文件

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    [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值

    1

    2

    3

    4

    5

    6

    7

    8

    [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文件内容如下:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    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文件传输到本机,就可以刻盘安装了...

  • 相关阅读:
    Android中的Looper , Handler , Message有什么关系
    理解Android系统的进程间通信原理(二)----RPC机制
    深入浅出JVM
    Linux个人常用命令汇总
    垃圾收集器与内存分配策略
    Linux上部署Java应用+Python3环境搭建
    List中remove元素的理解
    Java异常
    深入理解Java 8 Stream
    深入理解Java 8 Lambda
  • 原文地址:https://www.cnblogs.com/heidsoft/p/3430213.html
Copyright © 2020-2023  润新知