Initial customization of Linux system--automatic installation of CentOS system image production

Source: Internet
Author: User
Tags gpg rsync

Recently encountered a demand: To install the centos6.5 system in the intranet environment and build services, but because the automatic deployment script installs the dependency package uses the Yum installation, and the server cannot connect the network, the implementation personnel will not be local Yum source build O__o "...

The original idea is to find the need to rely on the package to be packaged to the implementation personnel to install themselves, and later, considering the installation of the system installation of inconsistent, partition and installation package of the non-uniform will be a burden on subsequent maintenance, simply decided to do an automated installation of the image, and the need for business-dependent package in full packaging

OK, first let's look at the environment preparation:

1, a newly installed, in line with the business requirements of the system (Bo Master selected is the minimal minimal installation, this look at personal needs)

2, the/root directory of the newly installed system Install.log and anaconda-ks.cfg files, then will use

3. Installation packages that need to be added

4. CentOS 6.5 image file or CD

5. Installation Kit

1 Yum Install Anaconda repodata Createrepo mkisofs rsync

One, insert the disc, mount the DVD image, create the relevant directory

1 Mount /dev/cdrom/mnt            #挂载光盘镜像 2mkdir -p/root/iso/Packages      # Store installed packages in the current system 3mkdir -p/root/iso/mypackages    #存放自定义安装包

Second, the CentOS system in the installation package, the package name is recorded in the root directory Install.log file, we can extract from it

1 awk ' /installing/{print $} ' /root/installsed's/^[0-9]*://g' >/root/package.txt

Iii. Extract the required installation package from the mounted disc image and put it in the/root/iso/packages directory

1[Email protected] ~]#CatTest.SH 2#!/bin/Bash3packages='/mnt/packages'#挂载的光盘镜像中存放安装包的路径4I='/root/iso/packages/'#新镜像存放安装包的路径5  whileRead Line6  Do7 CP${packages}/${line}*.rpm/${i} | |Echo "$line don ' t CP ...."8  Done</root/Package.txt9 Ten[Email protected] ~]#SHTest.SH 

Iv. copy other files needed for the image to the ISO directory

[Email protected] ~]# rsync-a--exclude=packages--exclude=repodata/mnt//root/Iso[[email protected]~]# ll iso/ Total the-RW-------.1Root root1539May -  on: -anaconda-ks.cfg-r--r--r--.1Root root -Nov in   -CENTOS_BUILDTAGDR-xr-xr-x.3Root root4096Nov in   -EFI-r--r--r--.1Root root212Nov -   -EULA-r--r--r--.1Root root18009Nov -   -Gpldr-xr-xr-x.3Root root4096Nov in   -IMAGESDR-xr-xr-x.2Root root4096May in  at: -ISOLINUXDRWXR-xr-x.2Root root4096May -  on: -MYPACKAGESDRWXR-xr-x.2Root root36864May -  +: -Packages-r--r--r--.1Root root1354Nov -   -release-notes-en-us.html-r--r--r--.1Root root1706Nov -   -rpm-gpg-key-centos-6-r--r--r--.1Root root1730Nov -   -rpm-gpg-key-centos-debug-6-r--r--r--.1Root root1730Nov -   -rpm-gpg-key-centos-security-6-r--r--r--.1Root root1734Nov -   -rpm-gpg-key-centos-testing-6-r--r--r--.1Root root4060May -  on: -TRANS. TBL

V. Execute the CREATEREPO program to generate the Comps.xml file under Repodata (important), the Comps.xml file contains all of the RPM-related content that the user sees during installation, and it checks the dependencies of the RPM packages under packages, If a dependent package is missing during installation, it will indicate which RPM package requires which dependent libraries

1[Email protected] ~]#mkdir-p/root/iso/Repodata2 3[Email protected] ~]#CatXml.SH 4#!/bin/Bash5 6iso_dir=/root/ISO7 CD ${iso_dir}8Declare-x discinfo=$ (Head-1. Discinfo)9 CP/mnt/repodata/*-comps.xml ${iso_dir}/repodata/Ten createrepo-g ${iso_dir}/repodata/*-comps.xml ${iso_dir} One createrepo-u "media://$discinfo"-G ${iso_dir}/repodata/*-comps.xml ${iso_dir} A  - [email protected] ~]# sh xml.sh - spawning worker 0 with 502 pkgs the Workers finished - Gathering worker Results -  - Saving Primary metadata + Saving file lists metadata - Saving Other metadata + Generating SQLite DBs A Sqlite DBs complete at spawning worker 0 with 502 pkgs - Workers finished - Gathering worker Results -  - Saving Primary metadata - Saving file lists metadata in Saving Other metadata - Generating SQLite DBs to Sqlite DBs complete

Vi. Production of anaconda-ks.cfg scripts

Anaconda-ks.cfg records the parameters and options that are filled in when the system is installed, that is, when you install the system, select the partition, time zone, set the user password and other operations, stored in the/root directory, we directly to the system installation created by the Anaconda-ks.cfg to make changes, of course, can also be made with System-config-kickstart tools

1 CP anaconda-ks.cfg  /root/iso

Here is a copy of the KS file I'm using, where the new place has comments

1[Email protected] mnt]#Catanaconda-ks.cfg2# Kickstartfileautomatically generated by Anaconda.3 4#version =DEVEL5 Install6 CDROM7Lang en_US. utf-88 keyboard US9Network--onboot no--device eth0--bootproto DHCP--Noipv6TenROOTPW--iscrypted $6$ecJ 0iyoglgrm0msv$hmdexhngkguilcrp.lvqe8jw49izaxha2fokanm6cydbwnn5rz2mn0akoyd5al.loklhvrrgt7xc8hq1  OneFirewall--service=SSH AAuthconfig--enableshadow--passalgo=sha512 -SELinux--Enforcing - reboot #安装完成后自动重启 theTimeZone--UTC asia/Shanghai #时区选择上海 -Bootloader--location=mbr--DRIVEORDER=SDA--append="Crashkernel=auto RHGB Quiet" - zerombr #清除mbr -Clearpart--all--Initlabel #删除所有分区 Initialize the volume label +Part/boot--asprimary--fstype="Ext4"--ONDISK=SDA--size= $#系统分区 -Part swap--asprimary--fstype="Swap"--ONDISK=SDA--size=8192  +Part/--asprimary--fstype="Ext4"--grow--ONDISK=SDA--size=1#博主这里只分了三个分区,/boot 200m,swap 8192M, remaining full root directory A#repo--name= "CentOS"--baseurl=cdrom:sr0--cost=100 #需要注释掉, or the installation system will be error, Bo Master has not yet figured out why, interested in the Welcome to study together at%Post #这里是系统安装完后执行的脚本命令, bloggers here also customize the dependency package placed in the new image of the Mypackages directory, after installation, in fact, the directory can also be placed similar to Redis installation package, JDK installation package, etc., installation commands can be written here  - mkdir-p/mnt/CDROM - Mount-O loop/dev/cdrom/mnt/CDROM - CP-rf/mnt/cdrom/mypackages/*. Rpm/tmp - cd/tmp && RPM-IVH *.rpm -  in Eject #安装完弹出光盘 - reboot-f #系统重启 to %end +  - %packages #这些是安装包信息, no modification required the @base * @chinese-support $ @corePanax Notoginseng @british-support - @server-policy the @workstation-policy + Sgpio A Device-mapper-persistent-data the %end

Vii. Modify the Isolinux.cfg configuration file and specify the anaconda-ks.cfg path

1 cat /root/iso/isolinux/isolinux.cfg  2 default Linux  ks=cdrom:/anaconda-ks.cfg             #修改第一行

Eight, make ISO image, and generate MD5 check code

1 [[email protected] ~]# mkisofs-o Centos.iso-b isolinux/isolinux.bin-c isolinux/boot. Cat 4  -boot-Info-table-r-j-v-t/root/iso/2 [[email protected] ~]# implantisomd5  centos.iso

The freshly baked auto-install image is done, then the engraving, the installation of the system only need to put the disc on the line, simple bar

Initial customization of Linux system--automatic installation of CentOS system image production

Related Article

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.