CentOS6.5 custom system iso Production

Source: Internet
Author: User

CentOS6.5 custom system iso Production
1. Install software

(1) software to be installed in the system

# Yum install anaconda repodata createrepo mkisofs system-config-kickstart

(2) The system centos6.5.iso and the rpm package to be installed, the modified image.

Ii. Create a custom system 1. CD files

(1) The isolinux directory stores the installation interface information when the CD is started.
(2) The images directory contains the necessary startup image files.
(3) The Packages directory stores the installation package and information
(4) The discinfo file is the identification information of the installation price.
(5) store rpm package dependency information in the Repodata directory

If you want to recreate the CD, follow these steps (skip the previous Cd content ).

1. Copy the rpm package and generate the repodata folder

# Mount-o loop centos6.5/mnt

# Cp/mnt/Packages/*. rpm/home/taiyang/work/anaconda/creatmcm/Packages

# Createrepo-v-g/mnt/repodata/*-comps. xml/home/taiyang/work/anaconda/creatmcm

Ii. Create a startup Image

# Yum install anaconda-runtime (or directly # yum install anaconda)

#/Usr/lib/anaconda-runtime/buildinstall -- version 1.0 -- buildarch x86_64 -- brand "Red Hat" -- product "Red Hat" -- release "Red Hat" -- final -- output/ home/taiyang/work/anaconda/creatmcm // home/taiyang/work/anaconda/creatmcm

Note: many errors and warnings are generated during the build process of buildinstall, but the complete directory structure is generated.

(Buildinstall is a shell script, which can be analyzed by yourself. Because anaconda adjusts the parameters, this command generates some useless content. You can manually delete the content and adjust the parameters to prevent unnecessary files from being generated .)

3. generate an iso file

# Mkisofs-o centos6.5Release. iso-V centos6.5Release-B isolinux/isolinux. bin-c isolinux/boot. cat-no-emul-boot-load-size 4-boot-info-table-R-J-v-T/home/taiyang/work/anaconda/creatmcm/

(# Mkisofs-R-J-T-r-l-d-allow-multidot-allow-leading-dots-no-bak-o. /CentOS6.iso-B isolinux/isolinux. bin-c isolinux/boot. cat-no-emul-boot-load-size 4-boot-info-table-eltorito-alt-boot. the parameter meanings are understood slowly .)

Iv. Install the md5 Verification Code

# Implantisomd5 centos6.5Release. iso

2. Create a system directory and copy files

(1) create a directory for storing the production system

# Mkdir/home/source/

(2) Copy all files except Packages (rpm package folder)

# Mount-t iso9660-o loopcentos6.5.iso/mnt (the disk uses mount/dev/sr0/mnt)

# Cd/mnt

# Ls-A. | grep-v Packages | xargs-I cp-rp {}/home/source (you can also manually copy all files except Packages, but remember to hide the files)

(Or use rsync-a -- exclude = Packages/mnt // home/source, rsync copies hidden files)

# Cp/root/anaconda-ks.cfg/root/install. log/home/source

(Using the anaconda-ks.cfg without configuring the ks file, you can use install. log to view the list of packages that have been installed on the local machine to reduce unnecessary copies)

# Mkdir/home/source/Packages

# Awk '/install/{print $2}'/home/source/install. log | xargs-I cp/mnt/Packages /{}. rpm/home/source/Packages/

(In an English System: change installation to Installing)

(3) custom installation control file anaconda-ks.cfg

The ks file is modified by the system installation anaconda-ks.cfg, or by using the system-config-kickstart tool.

Note:

[Html] view plaincopy
  1. Clearpart -- all -- initlabel
  2. Part/boot -- fstype = ext4 -- size = 2000
  3. Partswap -- size = 5000
  4. Part/-- fstype = ext4 -- grow -- size = 200
  5. Reboot
  6. Repo -- name = "CentOS6.5" -- baseurl = cdrom: sr0 -- cost = 100
Add the startup script after installation:
[Html] view plaincopy
  1. # Add a script to run after installation
  2. % Post
  3. # Bootecho custom system startup information
  4. Echo "CentOSRelease6.5">/etc/centos-release
  5. Sed-I's/CentOSLinuxrelease6.0 (Final)/CentOSRelease6.5/G'/etc/issue
  6. Sed-I's/CentOSLinuxrelease6.0 (Final)/CentOSRelease6.5/G'/etc/issue.net
  7. Sed-I's/localhost. localdomain/CentOSRelease/G'/etc/sysconfig/network
  8. Sed-I's/CentOS/CentOSRelease/G'/etc/rc. d/rc. sysinit
  9. Sed-I's/rhgb // G'/boot/grub. conf
  10. # Closecdrom after installation is complete
  11. Eject
  12. # Restart After reboot is complete
  13. Reboot-f
  14. % End
(4) modify the text title of the installation Interface

You can remove the "CentOS" text in the installation process. There are two installation discs. buildstamp file, one in stage2.img and the other in initrd. in img, initrd is read when the installation disc is running. in img. buildstamp file, so extract initrd. imgfile.

Decompress and modify:

# Cd/home/source/isolinux

# Mkdir tmp (you can also create temporary files in other directories)

# Cd tmp/

# Xz-dc/home/source/isolinux/initrd. img | cpio-id

# Vim. buildstamp

[Html] view plaincopy
  1. 201112091719. x86_64
  2. Centos6.5Release
  3. 1.0
  4. Http://wiki.centos.org/
Compression:

# Find. | cpio-c-o | xz-9 -- format = lzma> initrd. img

Sometimes the following error occurs: xz: Adjusted LZMA1 dictionary size from 64 MiB to 35 MiB to not exceed the memory usage limit of 398 MiB
Change xz-9 to xz-5 to reduce the compression strength level. You can ignore it, but it does not affect the result.

# Cpinitrd. img/home/source/isolinux/initrd. img

# Rm-rf/home/source/isolinux/tmp

-----------------------------------------------------------------

Note: centos6.4 cannot be decompressed as described above

# Gzip compression when fileinitrd. img is viewed

Decompress:

# Cd/home/source/isolinux

# Mkdir tmp

# Cpinitrd. imgtmp/initrd.img.gz

# Cd tmp

#Gunzipinitrd.img.gz

# Cpio-ivmd <initrd. img

# Vim. buildstamp

Compression:

# Cd/home/source/isolinux/tmp

# Rminitrd. img

# Find. | cpio-c-o> initrd. img

# Gzip initrd. img

# Mv initrd.img.gz/home/source/isolinux/initrd. img

# Rm-rf/home/source/isolinux/tmp

-----------------------------------------------------------------

(5) modify the background image of the installation disc

1. Modify the boot Display Screen

In/home/source/isolinux/splash.jpg, replace the file.

Modify the configuration file of the file displayed on the page:

# Vim/home/source/isolinux. cfg

[Html] view plaincopy
  1. Defaultvesamenu. c32
  2. # Prompt1
  3. Timeout600
  4. Displayboot. msg
  5. Menubackgroundsplash.jpg
  6. MenutitleWelcometoCentOS6. <spanstyle = "font-family: Arial;"> 5 </span>!
  7. Menucolorborder0 # ffffffff #00000000
  8. Menucolorsel7 # ffffffff # ff000000
  9. Menucolortitle0 # ffffffff #00000000.
  10. Menucolortabmsg0 # ffffffff #00000000
  11. Menucolorunsel0 # ffffffff #00000000.
  12. Menucolorhotsel0 # ff000000 # ffffff
  13. Menucolorhotkey7 # ffffffff # ff000000
  14. Menucolorscrollbar0 # ffffffff #00000000
  15. Labellinux
  16. Menulabel ^ Install <spanstyle = "font-family: Arial;"> </span> system
  17. Menudefault
  18. Kernelvmlinuz
  19. Appendinitrd = initrd. imgks = cdrom:/anaconda-ks.cfg
Keep only the default installation, ks = cdrom:/The anaconda-ks.cfg is added to achieve automated installation (without manual next installation ).

2. Modify the background image when installing the rpm package

The image is in the/home/source/images/install. img image file.

# Mount-t squashfs-o loop/home/source/images/install. img/mnt/

Copy a file, equivalent to cp

# Mdkir/tmp/install

# Rsync-av/mnt/tmp/install/

Modify the/tmp/install/usr/share/anaconda/pixmaps/progress_first.png background image. You can also modify all other related images.

# Cd/tmp

# Mksquashfsinstall/install. img-all-root-noF

# Cpinstall. img/home/source/images/install. img

(6) generate a new configuration folder repodata

Comps. the xml file contains all the rpm-related content that you see during installation. It checks the dependency of the RPM package under Packages. If the dependency package is missing during installation, it will prompt you which RPM package requires which dependent libraries. At the same time, its role is equivalent to selecting the software package during graph installation.

Comps. xml consists of three parts: the group list, which describes the different groups (or components) required during the installation process ), the group name, group description, and RPM package are included. The second is the group hierarchy, which divides the group into different classes and defines the order of the groups, this allows you to determine which groups need to be installed first, and finally a series of RPM packages and their dependencies.

Go to the/home/source/repodata directory, and change hosts to comps. xml. * The file name of comps. xml is very long.

# Cd/home/source/
# Cprepodata/* comps. xml./comps. xml
# Rm-rfrepodata
# Createrepo-g comps. xml.
(
You may also use commands to check the time when the file is generated:
# Declare-x discinfo = 'head-1. discinfo'
# Createrepo-u "media: // $ discinfo"-g comps. xml.
)
So far, the comps. xml file and other associated files have been regenerated to the repodata directory. Note: If the RPM package in the Packages directory is added or deleted, generate the comps. xml file again.

(7) Add a custom software package to the installer (omitted if not required)

An important step for customizing the Linux release is to add custom software packages to the installer.

1. Interface for selecting Customize now custom package

First, you need to understand the concept. Generally, a package refers to a software package. A group contains several packages and a category contains several groups. When you install the system using a Linux CD, you need to follow the steps to customize the software package. In this step, category is displayed on the left and group is displayed on the right. Mappings between them are documented in the repodata/xxx-comps.xml file.

Repodata/xxx-comps.xml file writing:

[Html] view plaincopy
  1. <? Xmlversion = '1. 0' encoding = 'utf-8'?>
  2. <! DOCTYPEcompsPUBLIC "-// CentOS // DTDCompsinfo // EN" "comps. dtd">
  3. <Comps>
  4. <Group>
  5. <Id> base </id>
  6. <Name> Base </name>
  7. <Namexml: lang = 'en _ gb'> Base </name>
  8. <Namexml: lang = 'zh _ cn'> basic </name>
  9. <Description> ThebasicinstallationofCentOSLinux. </description>
  10. <Descriptionxml: lang = 'zh _ cn'> Basic installation of Red Hat Enterprise Linux. </Description>
  11. <Descriptionxml: lang = 'zh _ TW '> basic security for centos Linux. </Description>
  12. <Default> true </default>
  13. <Uservisible> true </uservisible>
  14. <Packagelist>
  15. <Packagereqtype = "default"> zip </packagereq>
  16. <Packagereqtype = "mandatory"> traceroute </packagereq>
  17. <Packagereqtype = "optional"> zsh </packagereq>
  18. </Packagelist>
  19. </Group>
  20. <Group>... </group>
  21. ...
  22. <Category>
  23. <Id> development </id>
  24. <Name> Development </name>
  25. <Namexml: lang = 'en _ gb'> Development </name>
  26. <Namexml: lang = 'zh _ cn'> development </name>
  27. <Namexml: lang = 'zh _ TW '> program development </name>
  28. <Description> Developmenttoolsandlibraries. </description>
  29. <Descriptionxml: lang = 'zh _ cn'> development tools and libraries. </Description>
  30. <Descriptionxml: lang = 'zh _ TW '> development tool and function handler. </Description>
  31. <Grouplist>
  32. <Groupid> additional-devel </groupid>
  33. <Groupid> desktop-platform-devel </groupid>
  34. <Groupid> development </groupid>
  35. <Groupid> eclipse </groupid>
  36. <Groupid> server-platform-devel </groupid>
  37. </Grouplist>
  38. </Category>
  39. <Category>... </category>
  40. ...
  41. </Comps>

Add a custom category and group to the installation disc of CentOS 6.4:

# Cd/home/source/
# Cprepodata/* comps. xml./comps. xml

# Vimcomps. xml

Add inspur-security-group and inspur-optimization-tools group, with the default software packages installed.

[Html] view plaincopy
  1. <Group>
  2. <Id> inspur-security-group </id>
  3. <Name> InspurSecurityGroup </name>
  4. <Namexml: lang = 'en _ G'> InspurSecurityGroup </name>
  5. <Namexml: lang = 'zh _ cn'> Custom </name>
  6. <Description> SomesecuritypackagesprovidedbyInspurcompany </description>
  7. <Descriptionxml: lang = 'zh _ cn'> custom installation 1 </description>
  8. <Default> true </default>
  9. <Uservisible> true </uservisible>
  10. <Packagelist>
  11. <Packagereqtype = "default"> httpd </packagereq>
  12. <Packagereqtype = "default"> mysql </packagereq>
  13. </Packagelist>
  14. </Group>
  15. <Group>
  16. <Id> inspur-optimization-tools </id>
  17. <Name> InspurOptimizationTools </name>
  18. <Namexml: lang = 'en _ G'> InspurSecurityGroup </name>
  19. <Namexml: lang = 'zh _ cn'> Custom </name>
  20. <Description> SomeoptimizationpackagesprovidedbyInspurcompany. </description>
  21. <Descriptionxml: lang = 'zh _ cn'> custom installation 2 </description>
  22. <Default> true </default>
  23. <Uservisible> true </uservisible>
  24. <Packagelist>
  25. <Packagereqtype = "default"> php </packagereq>
  26. <Packagereqtype = "default"> php-mysql </packagereq>
  27. </Packagelist>
  28. </Group>
Added the inspur-extra category, which is displayed on the left side of the installation.

[Html] view plaincopy
  1. <Category>
  2. <Id> inspur-extra </id>
  3. <Name> InspurextraPackages </name>
  4. <Namexml: lang = 'zh _ cn'> custom development </name>
  5. <Descriptionxml: lang = 'zh _ cn'> custom development tools and libraries </description>
  6. <Grouplist>
  7. <Groupid> inspur-security-group </groupid>
  8. <Groupid> inspur-optimization-tools </groupid>
  9. </Grouplist>
  10. </Category>

Then generate the comps. xml file again:

# Declare-x discinfo = 'head-1. discinfo'

# Cd/home/aoyang/source

# Createrepo-u "media: // $ discinfo"-g comps. xml ./

(Edited comps. xml to generate a new one, because comps. the sha value of xml will change, which will lead to repomd. the error "An error occurred umounting the CD. please make sure you 'are not accessing/mnt/source from the shell on tty2 an the click OK retry)

2. Modify the default package of system default options and corresponding options

Two phases of system installation:
Phase 1: load the kernel image vmlinuz and the initial RAM disk initrd. img in the isolinux directory to create the installation environment. The/init program in initrd. img calls the/sbin/loader program, loader loads the kickstart file, and finally runs the/usr/bin/anaconda main program to enter the second stage.
Stage 2: The anaconda program loads various python and bash modules and performs various installation steps.
The file calling sequence is isolinux/vmlinuz-> isolinux/initrd. img->/init->/sbin/loader-> imagaes/install. img->/usr/bin/anaconda.

Anaconda is an installation and management program for Linux such as RedHat, CentOS, and Fedora. It is written in Python. It provides installation management methods such as text and graphics, and supports scripts such as Kickstart to provide automatic installation functions.

The Anaconda program exists in the images/install. img image of the CD. Therefore, to modify the preceding installation graphical interface, decompress the install. imgfile,

Main execution file of usr/bin/anaconda Installer
Usr/lib/anaconda/iw/graphic installation mode Module
Usr/lib/anaconda/textw/Text installation mode module.
Usr/share/anaconda/pixmaps/image of the image Installation Process
Usr/share/anaconda/ui/Text displayed during installation
Usr/lib/anaconda/dispatch. py to control the entire installation process. When a Next or Back button is clicked
Usr/lib/anaconda/vnc. py is used to control VNC settings (when VNC is requested during installation)

Go to the decompressed install. img directory and modify: # vim usr/lib/anaconda/dispatch. py

[Html] view plaincopy
  1. ......
  2. InstallSteps = [
  3. ("Welcome ",),
  4. ("Betanag", betaNagScreen ,),
  5. ("Language ",),
  6. ("Keyboard ",),
  7. ("Regkey", regKeyScreen ,),
  8. ("Findrootparts", findRootParts ,),
  9. ("Findinstall ",),
  10. ("Partitionobjinit", partitionObjectsInitialize ,),
  11. ("Parttype ",),
  12. ("Autopartitionexecute", doAutoPartition ,),
  13. ("Partition ",),
  14. ("Upgrademount", upgradeMountFilesystems ,),
  15. ("Upgradecontinue", queryUpgradeContinue ,),
  16. ("Upgradeswapsuggestion", upgradeSwapSuggestion ,),
  17. ("Addswap ",),
  18. ("Partitiondone", partitioningComplete ,),
  19. ("Upgrademigfind", upgradeMigrateFind ,),
  20. ("Upgrademigratefs ",),
  21. ("Upgbootloader ",),
  22. ("Bootloadersetup", bootloaderSetupChoices ,),
  23. ("Bootloader ",),
  24. ("Bootloaderadvanced ",),
  25. ("Reipl", doReIPL ,),
  26. ("Networkdevicecheck", networkDeviceCheck ,),
  27. ("Network ",),
  28. ("Timezone ",),
  29. ("Accounts ",),
  30. ("Reposetup", doRepoSetup ,),
  31. ("Basepkgsel", doBasePackageSelect ,),
  32. ("Tasksel ",),
  33. ("Group-selection ",),
  34. ("Postselection", doPostSelection ,),
  35. ("Confirminstall ",),
  36. ("Confirmupgrade ",),
  37. ("Install ",),
  38. ("Enablefilesystems", turnOnFilesystems ,),
  39. ("Migratefilesystems", doMigrateFilesystems ,),
  40. ("Setuptime", setupTimezone ,),
  41. ("Preinstallconfig", doPreInstall ,),
  42. ("Installpackages", doInstall ,),
  43. ("Postinstallconfig", doPostInstall ,),
  44. ("Writeconfig", writeConfiguration ,),
  45. ("Firstboot", firstbootConfiguration ,),
  46. ("Instbootloader", writeBootloader ,),
  47. ("Writexconfig", writeXConfiguration ,),
  48. ("Writeksconfig", writeKSConfiguration ,),
  49. ("Writeregkey", writeRegKey ,),
  50. ("Setfilecon", setFileCons ,),
  51. ("Copylogs", copyAnacondaLogs ,),
  52. ("Methodcomplete", doMethodComplete ,),
  53. ("Dopostaction", doPostAction ,),
  54. ("Complete ",),
  55. ]
  56. ......

(8) Create ISO

(You can delete all TRANS first. the TBL file may not be deleted # ls-ld 'Find. '| grep "TRANS. TBL "| awk '{print $9}' | xargs-I rm-f {}

Or # find.-name TRANS. TBL-exec rm-f {}";")

# Mkisofs-o centos6.5Release. iso-V centos6.5Release-B/home/source/isolinux. bin-c/home/source/isolinux/boot. cat-no-emul-boot-load-size 4-boot-info-table-R-J-v-T/home/source

#/Usr/bin/implantisomd5 centos6.5Release. iso

(Embed the md5 value into ISO to prevent data corruption during the replication process. Verify checkisomd5centos6.5Release. iso .)

Volume Table: centos6.5Release, boot Image File: isolinux/isolinux. bin, boot file name:/isolinux/boot. cat.

(Note: boot failed cocould not read from cdrom will appear when the iso parameter is not extended)

Possible errors:

1. When executing the mkisofs command, the system prompts: boot image './isolinux. bin' has not an allowable size.
Solution: because a soft drive is used by default, add-hard-disk-boot or-no-emul-boot.

2. After the Linux Image is created, the system prompts: ISOLINUX 3.86 2010-04-01 ETCDisolinux: Image checksum error during boot.
Solution: add the-boot-info-table parameter when executing the mkisofs command.

Iii. Refer to mkisofs parameters: http://linux.about.com/library/cmd/blcmdl8_mkisofs.htm

Recreate a CD: http://vega.sra-tohoku.co.jp /~ Kabe/ventricular septal change/c5-i586/dvd.html

Make iso and dvd scripts: http://scientificlinux.mirror.ac.za/59/x86_64/build/scripts/buildisoimages/archives/make-dvd.sh

Iv. Summary

(1) The summary of many contents in this article involves many problems. Please modify the content according to the actual environment.

(2) because each part involves a lot of content and code, you can only list brief directories. For others, you can refer to the official website or others.

(3) My ideas are limited. If you have better design suggestions, you can send an email to us. Thank you first! Email Address aoyang888@qq.com.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.