Linux installation file & amp; installation process analysis & amp; kickstart file analysis

Source: Internet
Author: User
Abstract: Although the operating system is often installed, have you ever thought about what you did during the operating system installation? What is the essence of system installation? Before operating system installation, how did the system get up from bare metal? And so on. This article takes Centos linux as an example to describe how

Abstract: Although the operating system is often installed, have you ever thought about what you did during the operating system installation? What is the essence of system installation? Before operating system installation, how did the system get up from bare metal? And so on. This article mainly uses Centos linux as an example to explain in detail the detailed installation process, boot program, system kernel, livecd, installer, and other differences and links of the operating system. This article is mainly for you to answer these questions

1. files included in the release version. First, let's take a look at what files will be included in a traditional release version of linux (a linux release CD, this article is centos ):
[huangyk@huangyk CentosInstall]$ lsCentOS_BuildTag  EULA  images    Packages                  repodata              RPM-GPG-KEY-CentOS-Debug-6     RPM-GPG-KEY-CentOS-Testing-6EFI              GPL   isolinux  RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-6  RPM-GPG-KEY-CentOS-Security-6  TRANS.TBL
Most of the information is related to the software packages to be installed. among them, there are two directories that play a key role in the installation process: images and isolinux. let's take a look at the content in these two directories:

Content of the isolinux Directory:

-R --. 1 root 2048 July 6 2012 boot. cat-r --. 2 root 84 July 6 2012 boot. msg-r --. 2 root 334 July 6 2012 grub. conf-r --. 4 root 31596586 July 6 2012 initrd. img-r --. 2 root 24576 July 6 2012 isolinux. bin-r --. 2 root 936 July 6 2012 isolinux. cfg-r --. 2 root 165080 July 6 2012 memtest-r --. 2 root 151230 July 6 2012 splash.jpg-r --. 1 root 2215 July 6 2012 TRANS. TBL-r --. 2 root 162860 July 6 2012 vesamenu. c32-r-xr-xr-x. 4 root 3986608 July 6 2012 vmlinuz
Among them, the isolinux. bin boot program is responsible for loading the operating system kernel to the memory, and isolinux. cfg is the configuration file that will be read by isolinux. bin.

Grub. conf is the configuration file read by grub, and grub is also the boot program

Mmtest and vmlinuz are system kernels that can be started, such as initrd. img is the disk image used for initialization. it contains a minimal system, including many basic directories such as/dev,/etc,/bin, and key init programs, responsible for driver loading and file system initialization.

Contents of the images Directory:

-R --. 2 root 372736 July 6 2012 efiboot. img-r --. 2 root 35997696 July 6 2012 efidisk. img-r --. 2 root 136585216 July 6 2012 install. imgdr-xr-x. 2 root 2048 July 6 2012 pxeboot-r --. 1 root 888 July 6 2012 TRANS. TBL
Among them, the most important thing is to guide the image file install. img (stage2.img in rhel 5) to be used in the second phase, and the anaconda program is in this image file.

In addition, if you want to learn more about the role of each file in the installation file, you can refer to here: http://blog.csdn.net/trochiluses/article/details/11774165

2. install. img content analysis

Run the file command to view the file system type of install. img. we can see that it is suqashfs, and mount it using mount-o loop-t squashfs install. img./img. The content is as follows:

etc  firmware  lib  lib64  modules  proc  usr  var
It can be seen that this is basically the disk image of important files in the file system:

Except the main execution body/usr/bin/anaconda, other installation script modules are in the/usr/lib/anaconda main directory. Let's take a look at the structure of the entire anaconda home directory:
/Usr/bin/anaconda: main program, which is a python script.
/Usr/lib/anaconda/installclasses: defines the installation types that you can select during the installation process. Each installation type description file provides different solutions for the installation steps, partition policies, and installation packages based on the characteristics of the corresponding installation types. There are two files, fedora. py and rhel. py, respectively for the installation types of fedora and rhel. Other Linux distributions can define their own installation types.
/Usr/lib/anaconda/iw: Graphical installation mode module. Contains the modules where all graphic interfaces are located. each graphic interface corresponds to a class. it is responsible for displaying the specific appearance of the graphic interface and interacting with users. (possible) call the relevant installation behavior module in the main directory of anaconda to complete the installation.
/Usr/lib/anaconda/storage: storage configuration response Directory (such as partition, FCOE, iSCSI, RAID, ZFCP configuration, etc ).
/Usr/lib/anaconda/textw: module in text installation mode. It is consistent with the iw sub-directory meaning. it only contains the module of the front-end character user interface class in the text installation mode. each character user interface corresponds to a class and is responsible for interaction with users, the character interface uses the python snack Library.
/Usr/lib/anaconda-runtime: contains init and loader programs. These are two statically compiled programs. they do not rely on other libraries, that is, they compile the C code under the loader directory under the anaconda Source Code Directory. These two programs will be placed in the Linux initrd image used to start the installation process.
/Usr/anaconda main directory: if the user interface class is used to handle the appearance of the installer, the python modules in the main directory of anaconda execute the specific installation behaviors behind each installation interface, including installation operations without user interface installation steps.
It can be seen that a large number of routines called by the main execution body/usr/bin/anaconda are distributed in the/usr/lib/anaconda directory, and the resource files (such as the background image) to be used during the installation process) the data is distributed in the/usr/share/anaconda directory. Many Python built-in modules are in the directory/usr/lib/pythonXX, where XX indicates the version number.
The above analysis shows the compiled anaconda directory structure. now let's take a look at the structure of the anaconda Source Code package. Anaconda is mainly written in Python, GUI front-end with pyGtk Library (refer to http://www.pygtk.org/) and Glade Interface Description File (refer to http://glade.gnome.org. Loader programs used to start the environment, load modules, and load anaconda subjects are written in C, and some other hardware-related parts are written in C. In addition, bash and python scripts are also used in some administrative tasks.

3. linux installation process analysis:

You need to know that the installer is only a common user program. before the installer can run, you must start the operating system. at this time, there is no operating system on the physical hard disk.

Therefore, a boot program (responsible for loading the operating system kernel and initrd. img to the memory), operating system kernel, and initrd (responsible for building the program running environment) is required in an installation CD ). In addition, if it is an installation disc, there must be an installer; if it is livecd, there must be a live disk image. That is to say, you need to have an installed operating system disk image, which is the imgfile. Theoretically, the installation and startup processes of the operating system are identical in the first few steps.

The system installation process is as follows:

Start the operating system kernel -- load initrd. img -- run the initialization program -- determines whether to start livecd or ananconda to run the installation program based on the init Program content in initrd initialization. if it is livecd, if there is an installer program in it, you can manually enable the installer program to install the operating system. Note that calling ananconda and other programs to install the operating system is a user action, not a spontaneous action of the system, there is no operating system boot process (because the operating system is up ).

POST power-on self-check --> BIOS (Boot Sequence) --> load the MBR on the corresponding Boot (bootloader) --> boot loader --> Kernel initialization --> initrd->/etc/init process loading/etc/inittab.

Because the traditional installation process is controlled by ananconda and ananconda executes the kickstart configuration file, it is necessary to understand the configuration file syntax and the large body framework of kickstart:

Line1 ~ Line6: basic configuration:

Line 1 lang en_US.UTF-82 keyboard us3 timezone US/Eastern4 auth --useshadow --enablemd55 selinux --enforcing6 firewall --disabled
Line8 ~ 11 software source configuration:
Line 8 repo --name=a-base    --baseurl=http://mirror.centos.org/centos/5/os/$basearch9 repo --name=a-updates --baseurl=http://mirror.centos.org/centos/5/updates/$basearch10 #repo --name=a-extras  --baseurl=http://mirror.centos.org/centos/5/extras/$basearch11 repo --name=a-live    --baseurl=http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live
Software Package List:
%packagessyslinuxkernel@admin-tools#packages removed from @admin-tools-sabayon-system-config-kdump#@admin-tools 
 
  @base#package added to @basesquashfs-tools#packages removed from @base-amtu-bind-utils
 
Note: Here, admin-tools is some column software, and "minus sign" indicates what software needs to be removed from some column software.

[Shell script to be executed after installation]

241% post
242
243 #! /Bin/bash
244 #
245
246 # FIXME: it 'd be better to get this installed from a package
247 cat>/etc/rc. d/init. d/centos-live <EOF_initscript
248 #! /Bin/bash
249 #
250 # live: Init script for live image
251 #
252 # chkconfig: 345 00 99
253 # description: Init script for live image.
254
255./etc/init. d/functions

Note: You can find the script in/root/post-install. the logs after this script is executed are placed in/root/post-install.log. after you start livecd, you can review these script files. 4. Questions About System guidance: We have 4.1 questions about kernel, that is, vmlinuz:

The following is a brief summary of the work to be done during kernel initialization:

Test hardware-> load the driver (in initrd)-> mount the root file system (the init script in the initrd image is complete)-> rootfs (/sbin/init)

Vmlinux is very small and only contains some of the most basic things, excluding the driver, which is about 4 M

The driver program is in initrd, and we can also sit the driver in vmlinuz. However, because there are many vmlinuz storage devices, there are also many drivers to be compiled into the kernel, which may cause the kernel to be bloated, therefore, the initrd file is generated, and the boot program initializes ramdisk to solve various driver problems.

4.2what are the differences between initrd and initramfs?

Ramfs is a very simple file system that uses the existing high-speed caching mechanism of the Linux kernel directly (so its implementation code is very small. For this reason, ramfs features cannot be blocked by kernel configuration parameters, it is a natural attribute of the kernel. it uses the physical memory of the system to create a memory-based file system that can dynamically change the size. The size is about 16 MB.

In early linux systems, hard disks or floppy disks were generally used as storage devices for linux root file systems. Therefore, it is easy to integrate drivers of these devices into the kernel. However, in the current embedded system, the root file system may be stored on a variety of storage devices, including scsi, sata, and u-disk. Therefore, it is obviously not convenient to compile all the driver code of these devices into the kernel. The size is about 4 MB.

4.3 In the installer, how are various disk image files mounted under the images directory?

Unsolved

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.