The relationship between the Linux kernel and the root file system

Source: Internet
Author: User


The beginning of the topic: For Linux beginners, this is a very tangled problem, but this is also a very important issue!
"Although the kernel is the core of Linux, the file is the primary tool used by users to interact with the operating system," he said. This is especially true for Linux, because in UNIX tradition it uses the file I/O mechanism to manage hardware devices and data files. ”

I. What is a file system
The file system refers to the physical space in which a file exists, and each partition in a Linux system is a file system with its own directory hierarchy.
A file in a Linux file system is a collection of data that contains not only the data in the file but also the structure of the file system, where all Linux users and programs see files, directories, soft links, and File Protection information. This mechanism facilitates interaction between the user and the operating system.
Each actual file system is separated from the operating system and the system service, communicating between them through an interface layer: a virtual file system or a VFS. VFS allows Linux to support multiple different file systems, each representing a common interface for VFS. Since the software transforms all the details of the Linux file system, the other parts of the Linux core and the programs running in the system will see the unified file system. The Linux virtual file system allows users to install many different file systems transparently at the same time.
In the Linux file system, the EXT2 file system, the virtual file system, and the/proc file system are three representative file systems.

Two. What is the root file system
The root filesystem is a file system, which not only has the function of storing the data file of the ordinary file system, but it is special to the normal file system, it is the first file system mounted on the kernel boot (mount), and the kernel code image file is saved in the root file system. The system boot launcher will load some initialization scripts (such as Rcs,inittab) and services into memory after the root file system is mounted. We need to understand that the file system and the kernel are completely separate two parts. The kernel that is ported in the embedded is downloaded to the Development Board, there is no way to really start the Linux operating system, there will be unable to load the file system error.
So when is the root filesystem mounted in the system boot? Mount the/DEV/RAM0 first, and then execute the/LINUXRC. When it's done. Switch the root directory, and then mount the specific root file system. After the root filesystem executes, that is, at the end of the Start_kernel () function, the init process is executed, and the first user process. Perform various initialization operations on the system.
The root filesystem is preceded by a "root", indicating that it is loading other filesystem "root", since it is the root, then if there is no such root, the other file system will not be able to load. It contains the files necessary to boot the system and make the other file system mount (Mount). The root file system includes the directories and critical files that are necessary for Linux startup, such as when Linux starts up with relevant files from the Init directory, and Linux is sure to find/etc/fstab this mount file when Linux mounts the partition. The root file system also includes a number of application bin directories, and any files that are necessary to boot the Linux system can become the root file system. When Linux starts, the first file system that must be mounted is the root filesystem, and if the system cannot mount the root file system from the specified device, the system exits startup with an error. After success, you can mount additional file systems automatically or manually. Therefore, different file systems can exist in a system at the same time. The process of associating a file system with a storage device in Linux is called mounting (mount). Use the Mount command to attach a file system to the current file system hierarchy (root). When performing a mount, provide the file system type, file system, and a hanging decoration. The root file system is mounted to the root directory "/" on the root directory under the root file system of the various directories, files:/bin/sbin/mnt, and then the other partitions to the/MNT directory,/mnt directory has this partition of the various directories, files.

Three. What is a kernel
The Linux kernel is like a human heart, Soul, command center. The kernel is the core of an operating system, which is responsible for managing the system's processes, memory, device drivers, files and network systems, which determine the performance and stability of the system. The kernel performs the most underlying tasks in an exclusive manner, ensuring that the system is functioning properly. Coordinate multiple concurrent processes to manage the memory used by the process so that they do not conflict with each other, meet requests for the process to access the disk, and so on.
An operating system is a low-level support software that deals with hardware and provides a limited set of services for user programs. A computer system is a kind of hardware and software symbiosis, they depend on each other, inseparable. A computer's hardware that contains peripherals, processors, memory, hard disks, and other electronic devices that compose a computer's engine. But there is no software to operate and control it, itself is not working. The software that completes this control is called the operating system, which is called the "kernel" in the terminology of Linux, and can also be called "core". The main modules (or components) of the Linux kernel are divided into the following sections: storage management, CPU and process management, file systems, device management and drivers, network communication, and system initialization (booting), system invocation, and so on.

Four. The relationship between the kernel and the file system
Technically, Linux is a kernel. "Kernel" refers to a hardware abstraction layer, disk and file system control, multi-tasking and other functions of the system software. A kernel is not a complete set of operating systems. A complete operating system based on the Linux kernel is called the Linux operating system, or Gnu/linux.
The file system is part of the kernel. The file system enables the interaction of storage media and other resources on the system. The FS directory in the kernel tree is about the filesystem, which can be said to be a large subsystem of the kernel.
The embedded system allocates the area of the kernel and root file system in Flash. Bootloader loads the kernel, the kernel starts, loads the file system, and enters the Linux system.
The entire embedded system, can be divided into three parts 1.uboot 2.kernel 3. File system. Kernel in which the VFS to support a variety of file systems, such as YAFFS,EXT3,CRAMFS and so on. YAFFS/YAFFS2 is a journaled file system designed for use with NAND flash memory for embedded systems. In the kernel, the VFS to block the various file system interfaces are different, with VFS to kernel provide a unified interface. Use open when opening a file, write using write instead of the file system, or consider how the file system writes data to physical media. One of the configurations in kernel, just let VFS support this interface.

The relationship between the Linux kernel and the root file system

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.