Exploring the reconstruction of the Redhat derivative edition of the network installation Series

Source: Internet
Author: User

GNU/Linux open-source, which has a very wide range of meanings. Currently, the 300 active releases on distrowatch represent the mainstream of GNU/Linux, however, careful Linux enthusiasts will find CentOS-based distribution designed, based on Slackware Linux, a distribution built from source software packages for Red Hat Enterprise Linux, a user-friendly Ubuntu-based distribution, an Debian-based distribution and other key words, most of the current releases are derived from derivative versions such as Redhat, Debian/Ubuntu, Suse, and Slackware. The purpose of building a base Distribution is many, and there are many technical exchanges and functions. These Based Distribution also provides a good reference for Linux enthusiasts to build their own Linux Release versions. This article is a series of proprietary articles that will lead you to explore how to build a Linux release based on Cenotos 5.2, which provides a basis for further in-depth research.
To build a Centos-based Linux release version, you must first understand the Linux Startup Process and the Linux Startup File, at the same time, we need to understand and analyze the CD structure of the Linux release version and the structure of the software package. From host power-up to system service loading and running, Linux Startup (similar to the installation process in Linux) generally requires the following process:

Stage 1:
Load the bios hardware information and obtain the code of the first boot device. Read the boot information of the mbr Boot Loader (lilo or grub) of the first boot device; load the core information of the core operating system, decompress the core, and try to drive all hardware devices;
 

It is very valuable to analyze this phase. Even if a Linux system is installed, it is necessary to load the kernel, decompress the kernel, and load the driver information of various peripherals, build a minimal Linux File System to execute the second-stage process.

Stage 2:
The core executes the init program and obtains the running information. The init executes/etc/rc. d/rc. sysinit file; start the core plug-in Module (/etc/modprobe. conf); each batch file (Scripts) executed and run by init;/etc/rc. d/rc. local file; execute the/bin/login program and wait for the user to log on. After logging on, the host is controlled by shell.
 

In other words, the Linux CD installation is to run anaconda and other installation programs on the minimal Linux file system built by stage2.img in the first stage to complete the installation process of the Linux system. During Linux installation, the second stage is to run anaconda and complete system installation with the system installation preset options.
The Linux release that builds Base Centos Distribution can be divided into two methods, the first is to initialize the software package installed on the Centos system by combining the preconfiguration file of Kickstart and the post and pre script of Kickstart; the second method is to add and modify the Linux File System generated by stage2.img to customize the kernel and add the defined wizard information during the installation process. The compile source code package requires in-depth research on comps in repodata. xml-based yum software package dependency definition, and has the ability to accumulate basic shell scripts, the software package to be installed and settings are implemented through scripts. The disadvantage of the second method is that the Centos system does not explicitly publish or adjust the kernel or other parameters, therefore, the second method is to deeply modify the configurations of stage2.img and anaconda to release a Linux version independent of Base Centos Distribution.
The purpose of Cenotos-based Linux release is to quickly and correctly establish the Linux system environment in the system. The implementation method starts with analyzing the installation CD of Centos. It can master the corresponding skills and methods, and establish the corresponding test environment.
Take the centos 5.2 DVD media as an example. The CD contains the following directories related to customization:

The isolinux directory stores the installation interface information when the CD is started.

The repodata directory is the dependency information related to RPM package installation.

The images Directory includes the necessary startup image files.

The CentOS directory stores installation package information

The. discinfo file is the identification information of the installation media, which is indispensable.
 

The following will focus on the analysis of the files in the images and isolinux directories and their functions, which is much more meaningful than the Centos and repodata directories in deep customization.
The images folder contains the boot image file, which contains the following information:

| ---- Vmlinuz Linux Kernel
| ---- Ldlinux. sys boot Linux System File
| ---- Syslinux. cfg Linux kernel boot parameter configuration file
| ---- Initrd. img memory Virtual File System Image File
| ---- * Various prompt information files during the. msg file boot
Initrd. img is a Linux ext2 file system, which consists of the following:

Initrd. img
| ----/Bin
| ----/Dev
| ----/Etc
| ----/Module
| ----/Sbin ------ loader
Installer
| ----/Tmp
| ----/Var
The executable file/sbin/loader is used to determine the validity of the installation media and execute the installation program.
 

After being executed at system startup, the Linux kernel is established in the memory and is configured according to the configuration file syslinux. cfg loads the Virtual File System to form a complete Linux system and provides the necessary operating system environment for subsequent work. Run the following command to view the files in boot. iso:

# Mount-o loop boot. iso/mnt
# Cd/mnt
# Tree
.
| -- TRANS. TBL
'-- Isolinux
| -- TRANS. TBL
| -- Boot. cat
| -- Boot. msg
| -- General. msg
| -- Initrd. img
| -- Isolinux. bin
| -- Isolinux. cfg
| -- Memtest
| -- Options. msg
| -- Param. msg
| -- Rescue. msg
| -- Splash. lss
'-- Vmlinuz
 

The stage2.img in the images folder is the installer image file when the installation media is CD-ROM.

Here we mainly discuss the content of stage2.img.
Stage2.img
| ----/Etc
| ----/Modules
| ----/Proc
| ----/Usr ----/bin ---- anaconda
Main installer execution File
|
| ------/Lib -----/anaconda
Installation script file directory
| ----/Installclasses
| ----/Iw
| ----/Texttw
| ---- *. Py
|
| ------/Share ---/anaconda
Installer resource file directory
| ----/Help
| ----/Pixmaps
Install the guide graphics Resource Directory, including all the bitmaps and icons used during installation, which can be modified using tools such as GMIP.
 

The main part of the stage2.img image file is the installation program anaconda. Its main execution body is anaconda under/usr/bin, A large number of routine calls are distributed under/usr/lib/anaconda, while the resource files to be used during installation are distributed under/usr/share/anaconda. You can run the following command to view the content in stage2.img:

# Mount-o loop-t squashfs stage2.img/mnt
# Cd/mnt
# Ls
Etc lib modules proc usr var
 

The anaconda installer is mainly written in Python. It is an explanatory and object-oriented scripting language. There are many py files in its source code directory. To fully complete the Centos-based Linux release, it is necessary to use and learn shell and Python,

Anaconda
| -------------------/Bootdisk
Boot Disk directory
| -----------------/Docs
Document directory
| -----------------/Help
Installation process help system directory
| -----------------/Installclasses
The installation category Directory, which is usually composed of four files workstation. py, server. py, laptop. py and custom. to describe the workstation installation type, server Installation type, laptop (laptop) installation type, and custom installation type.
| -------------------/Iw
Install the response directory of each step. The files in the subdirectory define the response functions of each step to Next and Prev when the graphical interface is installed.
| -------------------/Loader
Installer directory
| -------------------/Pixmap
Graphical Resource Directory, including all bitmaps and icons used during installation.
| -----------------/Utils
Installation utility directory
| ------------------- *. Py
Various Python script files
 


Figure: Centos-based Linux release build process
Based on the above content analysis, we will take a practical process of customizing a Centos-based Linux release version and installing openvpn through scripts.
1. Import the verification password information of the Centos yum source and install necessary software packages.

# Rpm -- import/etc/pki/rpm-gpg/RPM-GPG-KEY *
# Yum-y in

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.