CentOS6 startup flowchart anatomy (1)

Source: Internet
Author: User

CentOS6 startup flowchart anatomy (1)

When using the Linux operating system, we only need to press the power key, wait, and enter the account and password to use the Linux operating system. So what does the operating system do before you press the power to enter your account and password? The following describes the actions that occurred during this period.

The following uses the CentOS6 series as an example to explain the Linux Startup Process.

I. Linux Startup Process

Is the general process of starting the process:

Ii. POST power-on self-check

POST (PowerOnSelfTest) first checks Each device. After completing the process, you will find the device that has a boot record. After finding the device, read the Boot Record of the operating system, and then hand over the control of the system to the Boot Record. Then, the boot record is used to start the system smoothly.

Iii. MBR Guidance

MBR (Master Boot Record) MBR records are generally in the disk 0 track 1 sector, a total of 512 bytes. The first 446 bytes are BootLoder, And the last 64 bytes in the last 4*16 are used to store the partition information. The last two bytes are the verification information, which is generally 55AA.

Iv. GRUBGRand uniied Bootloader), loading the kernel

It is the first 446 bytes in MBR and one type of BooTLoader. It is used to select the kernel to be started.

1. Composition of GRUB program:

It is mainly composed of device. map, menulst, stage1, stage2, and a series of stage1_5. I understand these parts as follows:

  • Device. map: stores the root partition of the kernel file.
  • Menu. lis: it is the link file of grub. conf, but this name is more similar to its function, that is, the menu list. You can select the kernel menu for the middleware. Stored in stage2.
  • Stage: the grub boot program is too large. Therefore, the grub boot program is divided into two sections. The first section is stored in MBR, and the second section is stored in the kernel file system. After the first section is completed, the second section can be found. However, the second part is stored in the kernel file system. At this time, the file system has not been formatted. How can I access the menu. lst in the second part ?? You need to use the middle layer stage1_5 to assist stage1 to access stage2. Stage1_5 is usually located in the 63 sectors behind the stage1 field. Because stage2 can be used in memory, the file system is not sure, so this is why there are multiple stage1_5.

2. Significance of parameters in the grub. conf file

 
 
  1. Default = 1 # default kernel title, 0 indicates the first Kernel
  2. Timeout = 5 # default wait time
  3. Splashimage = (hd0, 0)/grub/splash.xpm.gz # specifies the path of the background image of the menu. It is in xpm format and adopts gzip compression. It can only be 14bits color.
  4. Hiddenmenu # Hide a menu
  5. Title CentOS (2.6.32-358. el6.x86 _ 64) # title name, which can be customized by the user
  6. Root (hd0, 0) # specify the root location of grub
  7. # Specify the location of the kernel file and specify the location after the root system is started. This is critical for mounting mode ro.
  8. # The init process will be started after loading.
  9. Kernel/vmlinuz-2.6.32-358.el6.x86_64 ro root =/dev/mapper/vg0-root rd_NO_LUKS rd_NO_DM LANG = en_US.UTF-8 ready = vg0/swap rd_NO_MD SYSFONT = latarcyrheb-sun16 crashkernel = auto ready = vg0/root KEYBOARDTYPE = pc KEYTABLE = us rhgb crashkernel = auto quiet rhgb quiet
  10. # Useful when loading the root file system during kernel startup
  11. Initrd/initramfs-2.6.32-358.el6.x86_64.img
What is the essence of initramfs-2.6.32-358.el6.x86_64.img ????
 
 
  1. # Initramfs is a gzip compressed cpio file. The kernel acts as a temporary root file system at startup.
  2. # The stage2 of grub loads initrd into the memory and releases the content to the content,
  3. # The kernel executes the init script, and the kernel gives control to the init file for processing.
  4. # Init it is mainly used to load device drivers related to various storage media. After the required driver is loaded,
  5. # A root device is created, and the root file system rootfs is mounted as read-only.
  6. # After this step is completed, release unused memory, convert it to the real root file system, and run the/sbin/init program at the same time,
  7. # Execute Process 1 of the System. After that, the control of the system will be handed over to the/sbin/init process.

How to Create initramfs?

 
 
  1. # The dircut command can be used as follows:
  2. # Used only when the initramfs file is damaged
  3. [Root @ server ~] # Dracut/mnt/initramfs-'uname-R'. img 'uname-R'
  4. [Root @ server ~] # Du-sh/mnt/initramfs-2.6.32-358.el6.x86_64.img
  5. 16 mnt/initramfs-2.6.32-358.el6.x86_64.img
  6. [Root @ server ~] # Du-sh/boot/initramfs-2.6.32-358.el6.x86_64.img
  7. 16 M/boot/initramfs-2.6.32-358.el6.x86_64.img
  8. # For details, you can use this link: https://zh.opensuse.org/index.php? Title = SDB: Dracut & variant = zh-cn #. E5.90.AF. E7.94.A8 _ dracut _. E7.94.9F. E6.88.90.E7.9A. 84_initramfs

3. grub Functions

1) provides menus and interactive interfaces

E: Enter the editing mode.

2) Select the kernel or system to be started.

Pass pilot parameters to the kernel

Select to hide

 
 
  1. # Parameters can be passed through grub image kernel for Automatic startup.
  2. # One of the applications is: Modify the root password and forget the password), use the e Option to pass a single user command.

3) provides a protection mechanism for the editing function

Enable kernel files

To run the specified kernel, enter the password first.

PASS Parameters

You must enter the password before using the e command.

 
 
  1. [Root @ server root] # grub-md5-crypt
  2. Password:
  3. Retype password:
  4. $1 $ Mp7Rp1 $ l2wzOILNUqpUhAR7zXvQb0
  5. # The above is the generated encrypted string
  6. # Add the information to the grub. conf file. The format is as follows:
  7. Password -- md5 $1 $ Mp7Rp1 $ l2wzOILNUqpUhAR7zXvQb0
  8. # Of course, the encryption effect varies depending on the location of the grub. conf file.
  9. # The entire menu is encrypted before the title is added.
  10. # If it is added to the title, the corresponding operating system entry will be encrypted.


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.