Customized exclusively for your system installation image

1. Production Scene

Leading to a room requires you to install the system CentOS6 server and build a service, you go to the scene found the server is not only within the network outside the network, but no network yum warehouse, kickstart cobbler or not to think. The only tool is your hand usb U disk or CD-ROM. How to get? ?

To mirror an automated installation, and all the business needs of the whole package dependencies into account. start…

2. Mount Mirror

    1. # → first self CentOS-6.7-x86_64-bin-DVD1.iso mirror (3.63G), then mount the image to a virtual machine.
    2. # → CentOS6.8 the mirror can also be, as long as you can improvise later. Download https://pan.baidu.com/s/1dFDiJst
  •  
  • [root@zyiso ~]# mount /dev/cdrom /mnt/
  • mount: block device /dev/sr0 is write-protected, mounting read-only
  • [root@zyiso ~]# df -h
  • Filesystem Size Used Avail Use% Mounted on
  • /dev/sda3 19G 1.5G 16G 9% /
  • tmpfs 491M 0 491M 0% /dev/shm
  • /dev/sda1 190M 36M 145M 20% /boot
  • / Dev / sr0 3.7G 3.7G 0 100% / mnt
  • [root@zyiso mnt]# ll -ah
  • The total amount of 567K
  • dr-xr-xr-x 7 root root 4.0K 8月 5 2015 .
  • dr-xr-xr-x. 23 root root 4.0K 8月 24 11:48 ..
  • -r–r–r– 2 root root 14 8月 5 2015 CentOS_BuildTag
  • -r–r–r– 1 root root 31 8月 5 2015 .discinfo
  • dr-xr-xr-x 3 root root 2.0K 8月 5 2015 EFI
  • -r–r–r– 2 root root 212 11月 27 2013 EULA
  • -r–r–r– 2 root root 18K 11月 27 2013 GPL
  • dr-xr-xr-x 3 root root 2.0K 8月 5 2015 images
  • dr-xr-xr-x 2 root root 2.0K 8月 5 2015 isolinux
  • dr-xr-xr-x 2 root root 516K 8月 5 2015 Packages
  • -r–r–r– 2 root root 1.4K 7月 25 2015 RELEASE-NOTES-en-US.html
  • dr-xr-xr-x 2 root root 4.0K 8月 5 2015 repodata
  • -r–r–r– 2 root root 1.7K 11月 27 2013 RPM-GPG-KEY-CentOS-6
  • -r–r–r– 2 root root 1.7K 11月 27 2013 RPM-GPG-KEY-CentOS-Debug-6
  • -r–r–r– 2 root root 1.7K 11月 27 2013 RPM-GPG-KEY-CentOS-Security-6
  • -r–r–r– 2 root root 1.7K 11月 27 2013 RPM-GPG-KEY-CentOS-Testing-6
  • -r–r–r– 1 root root 3.4K 8月 5 2015 TRANS.TBL
  • -r–r–r– 1 root root 338 8月 5 2015 .treeinfo
  •  
  • Common file directory Application:
  • isolinux directory for installation interface when the compact disc boot information
  • images directory contains the necessary boot image file
  • Packages directory holding the installation package and information
  • repodata directory for rpm package dependency information
  • .discinfo media file identification information is installed

    3. Collect RPM package

  • [root@zyiso mnt]# mkdir -p /application/CentOS6 
  • [root@zyiso mnt]# rsync -a –exclude=Packages/ –exclude=repodata/ /mnt/ /application/CentOS6/
  • [root@zyiso mnt]# cd /application/CentOS6/
  • [root@zyiso CentOS6]# ls
  • CentOS_BuildTag GPL RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Security-6
  • EFI images RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Testing-6
  • EULA isolinux RPM-GPG-KEY-CentOS-Debug-6 TRANS.TBL
  • [Root @ zyiso CentOS6] # you -sh 
  • 268M 
  •  
  • [root@zyiso CentOS6]# mkdir -p /application/CentOS6/Packages
  • [root@zyiso CentOS6]# cd 
  • [root@zyiso ~]# ls 
  • anaconda-ks.cfg install.log install.log.syslog
  •  
  • [root@zyiso ~]# awk ‘/Installing/{print “rsync -a /mnt/Packages/”$2″.rpm /application/CentOS6/Packages/”}’ install.log|bash
  •  
  • [root@zyiso Packages]# pwd
  • /mnt/Packages
  • [root@zyiso Packages]# cp tree-1.5.3-3.el6.x86_64.rpm nmap-5.51-4.el6.x86_64.rpm sysstat-9.0.4-27.el6.x86_64.rpm lrzsz-0.12.20-27.1.el6.x86_64.rpm dos2unix-3.1-37.el6.x86_64.rpm telnet-0.17-48.el6.x86_64.rpm /application/CentOS6/Packages/
  •  
  • [root@zyiso ~]# cd /application/CentOS6/Packages/
  • [Root @ zyiso Packages] # you -sh
  • 368M.
  • [root@zyiso Packages]# ls|wc -l
  • 516
  •  
  • # → generate repodata directory
  • [root@zyiso ~]# yum -y install createrepo
  • [root@zyiso CentOS6]# pwd
  • /application/CentOS6
  •  
  • # → Copy the file name contains comps.xml file, which is stored package group information.
  • [root@zyiso CentOS6]# cp /mnt/repodata/4df092633ebecaeebdd78359a11a3c13f619f22605322e15e5e307beebd8e641-c6-x86_64-comps.xml comps.xml
  • [root@zyiso CentOS6]# createrepo -g comps.xml .
  • Spawning worker 0 with 516 pkgs
  • Workers Finished
  • Gathering worker results
  •  
  • Saving Primary metadata
  • Saving file lists metadata
  • Saving other metadata
  • Generating sqlite DBs
  • Sqlite DBs complete
  • [root@zyiso CentOS6]# ls repodata/
  • 1796ee77e0a9d1aedf4fc8e8bb112a05f58b37a48a97b3ad4ae96862f334e93b-primary.xml.gz
  • 1da2cadaadd73048ae5ac2275b46851b8829278568dcad09608015f0201ea42e-other.sqlite.bz2
  • 3c0626aafa36099243a809bcb7e4b2ae85d781e0b361916d52f73965582be885-other.xml.gz
  • 418aeb7685093a6eb90725f2c2c5e3306b3697f7a7c13067dee102e645bde860-filelists.xml.gz
  • 486d3ee62873814293a1be370640ae9c71863a35c7299eb76739e03369ad0c3f-comps.xml.gz
  • 4df092633ebecaeebdd78359a11a3c13f619f22605322e15e5e307beebd8e641-comps.xml
  • 54bcf19d09ed0221351fddc12a6d80f061c1c7adc83135a5940410617d0cbfd0-primary.sqlite.bz2
  • d7ad8946692006ed04f68494acb16da97fffa216b102568b809e9e1e519956c4-filelists.sqlite.bz2
  • repomd.xml
  •  
  • [root@zyiso CentOS6]# mv comps.xml /tmp/

    repodata file comps.xml file contains all the content associated with the user rpm seen during installation, it checks dependencies RPM package under Packages, the installation package if missing dependencies, it will prompt you which RPM package What needs to rely on libraries. While its role is equivalent to choose a package that links graphic installation.

    comps.xml mainly consists of three parts, a first list, which describes the different groups (or assembly) is required during the installation, including the group name, group description and the package contains RPM; followed hierarchical group of , the group will be divided into different classes, and defines a set sequence, so that the group can determine which need to be installed; the last packet of a series of RPM and the dependencies between them.

    4. custom installation script ks.cfg kickstart file

    Meaning we can refer to the following file another article "Automated operation and maintenance series 1-Kickstart automated installation of the operating system."

  • [root@zyiso ~]# vim /application/CentOS6/isolinux/ks.cfg
  • # Kickstart Configurator for CentOS 6.7 by yao zhang
  • install
  • cdrom
  • text
  • lang en_US.UTF-8
  • keyboard us
  • zerombr
  • bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto rhgb quiet”
  • network –bootproto=dhcp –device=eth0 –onboot=yes –noipv6 –hostname=oldboyedu
  • timezone –utc Asia/Shanghai
  • authconfig –enableshadow –passalgo=sha512
  • rootpw –iscrypted $6$X20eRtuZhkHznTb4$dK0BJByOSAWSDD8jccLVFz0CscijS9ldMWwpoCw/ZEjYw2BTQYGWlgKsn945fFTjRC658UXjuocwJbAjVI5D6/
  • clearpart –all –initlabel
  • part /boot –fstype=ext4 –asprimary –size=200
  • part swap –size=1024
  • part / –fstype=ext4 –grow –asprimary –size=200
  • firstboot –disable
  • selinux –disabled
  • firewall –disabled
  • logging –level=info
  • reboot
  • %packages
  • @base
  • @compat-libraries
  • @debugging
  • @development
  • tree
  • nmap
  • sysstat
  • lrzsz
  • dos2unix
  • telnet
  •  
  • %post
  • #→在这里可以定制一下系统
  • echo “Welcome to the Old Boys Education iso image”>/etc/motd
  • %end
  •  
  •  
  • [root@zyiso ~]# vim /application/CentOS6/isolinux/isolinux.cfg
  • default vesamenu.c32
  • #prompt 1
  • timeout 600
  •  
  • display boot.msg
  •  
  • menu background splash.jpg
  • menu title Welcome to CentOS 6.7!
  • 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 Oldboyedu Linux System
  • menu default
  • kernel vmlinuz
  • append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
  • 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 –

    5. 生成镜像

  • [root@zyiso CentOS6]# yum -y install mkisofs
  •  
  • [root@zyiso CentOS6]# mkisofs -o /application/CentOS-6.7-x86_64-oldboyedu.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T .

    6. 生成ISO文件MD5值

  • [root@zyiso ~]# yum -y install isomd5sum
  • #→以前每做出一个ISO都会同时生成一个md5值文件,防止复制过程中数据损坏;现使用implantisomd5和checkisomd5两个工具,可以将md5值嵌入ISO中并直接效验,方便不少。
  • [root@zyiso application]# implantisomd5 CentOS-6.7-x86_64-oldboyedu.iso #→只能植入一次
  • Inserting md5sum into iso image…
  • md5 = f4e43ec24d18fa09047f852adf6d2051
  • Inserting fragment md5sums into iso image…
  • fragmd5 = b3854c6e41d46c688616dda1e9c881e2119a271558f759b6b7eeee733ac1
  • frags = 20
  • Setting supported flag to 0
  • [root@zyiso application]# checkisomd5 CentOS-6.7-x86_64-oldboyedu.iso 
  • Press [Esc] to abort check.
  •  
  • The media check is complete, the result is: PASS.
  •  
    1. It is OK to use this media.

       

      提供镜像下载:https://pan.baidu.com/s/1dFDiJst

       

      镜像主要信息:

      1. 最小化安装及额外选择4个包组及tree nmap sysstat lrzsz dos2unix这几个软件

      2. 用户root密码123456

      3. 磁盘分区boot 200M swap 1G 剩余空间给/

      4. 防火墙和selinux关闭

      5. 大家按需要修改网卡/主机名/用户密码

      7. 安装制作的ISO镜像

       

      大家可以看到这张图片被修改了,大家想改的话,这个图片的路径为isolinux/splash.jpg

       

      8. 后记

      上面定制的镜像仅仅包含系统,如果需要将我们的web服务或者mysql服务内嵌进镜像,读者可以学习完下一篇文章《自动化运维系列4–定制化专属于你的软件包》,将这些服务定制成rpm包,然后在第3节收集rpm包这一步骤将自己制作的rpm包放进/application/CentOS6/Packages目录,然后再改改第4节的ks.cfg文件即可。Good Luck!

Guess you like

Origin www.cnblogs.com/flytor/p/11414997.html