Linux Startup Process on CF card

Source: Internet
Author: User

An embedded linux operating system can be abstracted as bootloader, kernel vmlinuz, and file system.

Bootloader is the first code to run after the system is powered on. Generally, it only runs within a short period of time when the system is started. This is a crucial step for linux systems. In the system, the entire bootloader is a piece of code from the bios in the system and the MBR (primary boot sector) in the USB flash disk to complete the boot task. Here we use the grub boot mode. The system first reads the MBR content detected by the BIOS to RAM, and then gives the system control to grub. Finally, grub is responsible for reading the kernel image of the operating system to the system RAM, then jump to the kernel entry point.

Vmlinuz is an image file of the Linux kernel. It can be loaded by the boot program to start the Linux system.

The full name of initrd is boot loader initialized RAM disk, which is the root file system image file used during system startup. This file system contains several driver modules, all must be loaded when the system starts. In addition, when we need to load other modules, we can also put them in.

Recommended reading:

  1. How many mini systems does the Linux Startup Process know?
  2. Linux Startup Process
  3. Linux Startup system and troubleshooting
  4. Linux Startup Process

I. BOOT program Grub

After the machine is powered on, the BIOS starts to detect system parameters, such as memory size, date and time, disk devices, and the sequence in which these disk devices are used for boot, the BIOS is configured to check the drive or optical drive first, and then try to boot from the hard disk. If no bootable media is found on these removable devices, the BIOS usually redirects to the first sector of the first hard disk to find instructions for loading the operating system. The program that loads the operating system is the boot loader.

In linux, the bootloader is usually lilo or grub. Starting from Red Hat Linux 7.2, GRUB replaces LILO as the default start loader. How is grub loaded at startup?

Grub has several important files, stage1 and stage2. Sometimes stage1.5 is required. These files

Usually under the/boot/grub folder. Grub loading usually includes the following steps:

1. Load basic Boot Loader (stage1)

Stage1 is very small and only 512 bytes,

Stage1 is usually located in the Main Boot Sector, and its main function is to load the second boot program (stage2 ). This is mainly because there is not enough space in the primary Boot Sector for other things. The size of the stage2 file in grub is 103.9 K.

2. Load the second bootstrap loader (stage2)

This second bootstrap loader actually introduces more advanced features that allow users to load into a specific operating system. In GRUB, this step allows the user to display a menu or enter a command.

The above mentioned stage1.5 file. What is its role? In the/boot/grub directory, You can see fat_stage_1.5 e2fs_stage_1.5 xfs_stage_1.5 and so on. It is easy to guess that stage1.5 is related to the file system, and sometimes the basic bootstrap loader (stage1) the file system partition where stage2 is located cannot be identified. In this case, stage1.5 is required to connect stage1 and stage2. therefore, stage1.5 is different for different file systems. However, it seems that stage1.5 is not very important for our grub, because I tried it. Without stage1.5, I installed stage1 on the CF card formatted as ext3, it can be properly guided and does not require e2fs_stage_1.5 or fat_stage_1.5.

The specific method is to format the entire CF card into a partition, the file system is in ext3 format, and then stage1, stage2, grub. conf files required for startup are copied to the specified directory of the CF card, and then go to grub and run some commands to install the files on the CF card.

Ii. Kernel configuration

Linux Kernel controls a wide range of things, from File System Format, program opening, power management, user security, and many other projects, and even network bandwidth allocation, we can see the importance of the kernel. But for our current system, we are mainly interested in the following options in Kernel configuration.

1. Loadable module support supports modules. There are three types of support: Enable loadable module support: unless you want to compile all the required content into the kernel, otherwise, this item is required.

Set version information on all module symbols: indicates that this module is not released together with the kernel, which is usually not selected.

Kernel module loader: This option indicates that the Kernel can load modules. The Kernel program can automatically call the module as needed, and unmount the module when the function is not needed.

2. Processor type and features

There are also many options under it, but we only care about Processor family: According to my

Select the CPU type as needed. In our fault diagnostic instruments, the trial proved that 386, 486 or 586/K5/5x86/6x86/6 x86MK can be selected, but the selection of Pentium-3/celon or Pentium-4 does not work.

3. General setup

Here are some of the most common attributes. This part contains a lot of content. Generally, you can use the default settings. But it must be selected because it supports PCI bus and power management mode.

4. Block devices

Under its options, we must select RAM disk support :.

(65536) default ramdisk size Initial ramdisk (initrd) support

Because we are working on ram disks, We must select all of them. If the kernel does not support them, the root file system cannot be loaded after the kernel is started. The 65536K is the root file system space we opened in the memory. Here is 64 mb. We can adjust it as needed.

5. Character devices

Support for character devices, such as the mouse and virtual terminal, by default. 6. Filesystem

Here, we mainly want to select ext3 file support and/proc file system support, which is generally the default value. Because the file system image we made later is in ext3 format, the kernel must support this file format. The/proc file system is a channel provided by linux for users to interact with the system.

In addition, second extended fs support is a standard linux File System. We recommend that you compile it into the kernel. Other file system types can be selected based on your preferences.

7. Console drivers

Because we do not have a desktop system yet, we chose the VGA text console. If this option is not selected, it will stop when the system starts running and the kernel is downloaded.

In addition, the system can start and work normally without selecting the IDE support. However, our system only works in the memory. Even if we put the program to be run in it, nothing will be retained after shutdown. So we need to re-mount the CF card to the system after the system is started, and then save the running results on the CF card, in this way, even if the CF card is shut down, the running results of our program have been saved. Therefore, we must add IDE support to the system. Similarly, if our system needs to support USB devices, we should choose to support USB and SCSI in the configuration options. That is, add the usb driver. The reason for selecting SCSI is that the USB Mass storage support will only appear in the USB configuration option when SCSI is supported.

  • 1
  • 2
  • Next Page

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.