1 case description
The idea comes from two origins: one is the CactiEZ installation disk, which is awesome. At first, I didn't consider customization. Later, Xiao Jinghai proposed whether we could release our own Linux, after the system disk is packed with our program, you can directly install it on the disc, minus the installation process of our software. Later, du Niang found it feasible.
2 Case Analysis
The entire process is basically divided into: Create a folder for storing the content of the CD; then extract the content based on the package to be installed; Package A third-party software package and start production. For details about the journey, refer to the "solution process ".
3. Solution Process 3.1 Preparation
According to our production environment, we use the CentOS5.564-bit linux system. This document takes the production environment as an example. The preparation is as follows.
3.1.1 prepare the environment and mount the image
Install a CentOS5.564-bit system and use the system as the environment to complete this case. Upload the CentOS5.564 image file to the system "/opt" and mount the image under the "/mnt/CentOS-5.5-x86_64" directory to prepare the yum source and extract the files required to make the CD.
Mount the file. Use vim to edit the/etc/fstab file and add the following lines to the last line:
/Opt/CentOS-5.5-x86_64-bin-DVD-1of2.iso/mnt/CentOS-5.5-x86_64iso9660loop, defaults00
Save the fstab file and run "mount-a" to mount the CD. The CD will be automatically mounted after the system starts.
3.1.2 configure yum source and install required software
Prepare the yum source and install the software required to create the image.
Back up the system repo file and create a custom repo file as follows:
Mkdir/etc/yum. repos. d/bak
Mv/etc/yum. repos. d/*. repo/etc/yum. repos. d/bak/
Touch/etc/yum. repos. d/myrepo. repo
Insert the following content into the myrepo. repo file:
[Base]
Name = CentOS-5.5-x86_64
Baseurl = file: // mnt/CentOS-5.5-x86_64
Gpgcheck = 0
Install the required package createrepo: Create the comps. xml file of the software package of the yum repository; mkisofs: Create the ISO file ):
Yum-yinstallcreaterepomkisofs
3.2 image extraction requires files and rpm package files 3.2.1 create a CD folder and synchronize files
Create a folder "MyCentOS" under the/opt directory to store the generated CD files and synchronize the files from the mounted directory to the CD directory. The operations are as follows:
Rsync-av -- exclude = CentOS/mnt/CentOS-5.5-x86_64 // opt/MyCentOS/
Delete unnecessary files in MyCentOS and create a directory CentOS to store the rpm package. Keep the following seven files or directories ):
# Ll-
Total108
Drwxr-xr-x6rootroot4096Jun2510: 34.
Drwxr-xr-x3rootroot4096Jun2509: 24 ..
Drwxr-xr-x2rootroot36864Jun2509: 23 CentOS
-Rw-r -- 1rootroot1_may42010. discinfo
Drwxr-xr-x4rootroot4096May42010images
Drwxr-xr-x2rootroot4096May42010isolinux
Drwxr-xr-x2rootroot4096May62010repodata
-R -- 1rootroot7048May62010TRANS. TBL
-Rw-r -- 1rootroot417Apr272010. treeinfo
3.2.2 generate a list of installation files based on the install. log File
The install. log file is the installation package log file during system installation. It is obtained in the installed system as needed. The command is as follows:
Cat/root/install. log | grepInstalling | awk '{print $2}' | awk-F': ''{if (NF = 2) {print $2} else {print $1} '>/opt/packages. list
3.2.3 copy the rpm package to the mounted disc based on the file list
Use the for statement to import rpm to the CentOS directory based on the file list. The command is as follows:
Foriin 'cat/opt/packages. list'; docp-pv-f/mnt/CentOS-5.5-x86_64/CentOS/"$ I" */opt/MyCentOS/CentOS/; done
3.3 create an xml file for updating the installation package on the CD 3.3.1
Use the createrepo program to update the comps. xml file under repodata
Createrepo-g/opt/MyCentOS/repodata/comps. xml/opt/MyCentOS/CentOS/
3.3.2 create an automatically installed ks File
Make the ks file. The ks file is created according to the actual installation requirements. Generally, it can be generated using the Kickstartsystem-config-kickstart program, you can also copy the "anaconda-ks.cfg" system from the root directory automatically generated during installation) directly use, this direct use of the root file, copy the file and rename:
Cp/root/anaconda-ks.cfg/opt/MyCentOS/isolinux/ks. cfg
The ks file can be used only after partial partition content is uncommented. The modification is as follows:
# Thefollowingisthepartitioninformationyourequested
# Notethatanypartitionsyoudeletedarenotexpressed
# Heresounlessyouclearallpartitionsfirst, thisis
# Notguaranteedtowork
Clearpart -- linux -- drives = sda
Part/boot -- fstypeext3 -- size = 100 -- ondisk = sda
Partpv.2 -- size = 0 -- grow -- ondisk = sda
VolgroupVolGroup00 -- pesize = 32768pv. 2
Logvol/-- fstypeext3 -- name = LogVol00 -- vgname = VolGroup00 -- size = 1024 -- grow
Logvolswap -- fstypeswap -- name = LogVol01 -- vgname = VolGroup00 -- size = 1000 -- grow -- maxsize = 4000
No partition operation is prompted during installation.Clearpart"The line is changed to the following content:
Clearpart -- all-initlabel
In the actual process of making a CD, modification to the ks file is the key and needs to be studied separately before use, the ks file can use the "ksvalidator" command to check whether the file has obvious syntax errors.
3.3.3 modify the system installation method
Modify the default installation method of the image for automatic installation. Here, modify/opt/MyCentOS/isolinux. cfg file to achieve our goal, it is worth noting that isolinux. the cfg file is read-only. To modify the file, you must grant the write permission to it:
Chmod + w/opt/MyCentOS/isolinux. cfg
Vim/opt/MyCentOS/isolinux. cfg
Modify the following content:
DefaultRow:The default value is linux. Change it to ks to enable linux to start from the ks script and modify the content;
Defaultks
TimeoutRow:The default value is 600, that is, wait for one minute, and change to 6 seconds, that is, 60. The modified content is as follows:
Timeout60
"Labelks"Partial contentAppendLineContent, modified content:
Appendks = cdrom:/isolinux/ks. cfginitrd = initrd. imgtext
Save the file and create a CD later.
3.3.4 generate an ISO file
Make a cd
Mkisofs-R-J-T-r-l-d-allow-multidot-allow-leading-dots-no-bak-o/opt/MyCentOS-0.1-x64.iso-bisolinux/isolinux. bin-cisolinux/boot. cat-no-emul-boot-boot-load-size4-boot-info-table/opt/MyCentOS/
Generate an ISO file in the/opt directory, and then install and test the actual effect.
4. solution results
It is very convenient to create the system disk you need. manual intervention is not required during the system installation process. It is much more convenient to use the system disk in the future.
5. Summary
When using other software on a daily basis, there are usually some new methods or ideas. If you are good at discovering and actively applying them to our daily O & M, it is still very good!
6. Reference:
Customize your own CentOS release:
Http://www.osedu.net/article/linux/2012-05-30/407.html
Custom CentOS6.0 streamlined Automatic Installation version:
Http://kerry.blog.51cto.com/172631/646549/
Custom centos production:
Http://blog.chinaunix.net/uid-9040470-id-1939673.html
Reference: Comparison of the speed of copying files between GUNcp and tar
Http://liuyu.blog.51cto.com/183345/150408
CentOS6.2X86 _ 64
Http://www.osedu.net/article/linux/2012-05-30/411.html
This article is from the "706737" blog and will not be reproduced!