Linux OS-init in initrd

Source: Internet
Author: User
Article Title: Linux OS-init in initrd. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

4.3 create a file system required for Device Files

After collecting all the information about the system, you have to start busy with device files. Before a device file is created, you must first establish the required environment for all the device files, that is, the file system that stores the device files. -16 is the section related to the init file and the establishment of the file system. It is the same as Part C in-1, mainly focusing on the operations in advance of the device file, the required Device File environment includes the tmpfs and devfs File System pointed by the arrow in-16. Although the mount command only shows that tmpfs is a category (-t parameter) And/dev is a directory, the/dev directory actually stores files in the devfs system architecture by the tmpfs file system.

For the remaining "/dev/pts", "/dev/shm", and "/dev/mapper", the directories of related hardware devices are created first, you can use this directory as a special-purpose device file to store the directory at any time.


-The main process for creating a file system for a device file is as follows:

? Create a virtual space.

? Create a console display interface directory in the virtual space.

? The directory used to create the file corresponding to the disk.

 4.3.1 tmpfs

The device file environment tmpfs is similar to proc and sys, and is a virtual file system. Because no physical device is loaded when the device is started, A large number of virtual file systems are used during startup or rescue mode to create and store relevant information. Tmpfs is very convenient for users who use memory as hard disks. Even after the Linux system is started, a tmpfs directory has been created by default for users to use, however, the available size is limited by the memory size, because the space used by tmpfs comes from the physical memory space.

In rescue mode, tmpfs is also used to create a directory for device files (4-17 ). You can use this space for an experiment to see the impact of tmpfs on memory. The figure shows that the memory size is 256 MB and the available space is about 60 MB. At this time, create a file of about 20 mb in the/dev directory to see how the memory changes.

Use dd to create a 20 MB testfile (4-18) in the/dev directory, and then run the free command to check the memory size again, although the file is created in the/dev directory, the memory size drops from 60 MB to 40 MB in real time. This shows that tmpfs is fully used by users with memory space.

This is the reason why initrd chose to establish the environment with tmpfs when being loaded. It is simple and easy to use. You only need to mount the directory to be used in tmpfs format to direct the directory to memory resources, the key point is that the speed is much faster than the general hard disk. If you need a hard disk speed, you can use tmpfs to create a temporary space. After all, which kind of hard drive speed can make the access speed higher than the memory speed.

[1] [2] [3] [4] [5] [6] [7] [8] [9] 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.