Boot process + File system notes

Source: Internet
Author: User

1.BIOS: The boot active firmware will recognize the first bootable device, such as a hard drive.

2.MBR: The primary boot partition block in the first sector of the first bootable device, which contains the boot loader.

3.Bootloader: A software that can read kernel files to execute.

4.kernel: Start operating the OS function.

Both the BIOS and MBR are features supported by the hardware itself, and Bootloader is a set of software installed on the MBR by the operating system. MBR is only 446

Byte, so this bootloader is small and perfect.

The following features are mainly available:

Menu available: The user can select different boot options.

Load kernel: Direct point to the bootable program section to start the operating system.

Transferred to other bootloader.

In addition to being installed in the MBR, the bootstrapper can be installed on each partition's boot sector.

Bootloader provides two menus, the first menu can directly load the Windose kernel file to boot;

The second menu can hand boot loading to the boot sector of the second partition. When the user starts the selection menu two o'clock, the entire boot load will be given to the second partition's bootloader.

After the second bootloader is started, there is only one menu, so you can use Linuxkernel to boot.

Summary: Each partition has its own boot sector bootsector. The actual bootable kernel files are placed in each partition. Loader only knows the bootable kernel files within the partition, as well as other loader. Loader can direct or indirectly give management authority to another management program.

Each partition can be formatted as a different file system.

The file system usually stores the two parts of the data in separate blocks, with permissions and attributes placed in the inode, and the actual data is placed in the block of data block. There is also a super block to record overall information about the entire file system, including the total number of inode and block, usage, and amount remaining.

Superblock: Records The overall information of this file system, including the total amount of inode/block, usage, amount remaining, and file system format and related information.

Inode: Record file attributes, one file with an inode, and record the block number where the file's data resides;

Block: The actual record of the contents of the file, if the file is too large, will occupy more than block.

The file system size supported by the data block in ext2 1,2,4kb corresponds to this different single file limit and maximum file system total capacity.

In principle, the size and quantity of blocks cannot be changed after all kinds of patterns (unless reformatted);

You can place up to one file per block of data.

If the file is larger than the block size, a file occupies more than one block.

If the file is less than block, the remaining space of the block can no longer be used.

For example 10,000 small files per 50bytes All file capacity 50*10000=488.3kb, but actually occupy 4046*10000=38.6MB.

Inodetable (inode table)

The contents of the Inode mainly record the attributes of the file and the block in which the actual file data is placed. Basically, the file data for the Inode record is at least:

File access mode (Read/write/excute);

The owner and group of the file (Owner/group);

File size;

The file creation or state change time (CTime);

The last Read time (atime);

Time of Last modification (mtime);

A flag that defines the attributes of a file, such as setuid;

The true content of the file points to (pointer);

The size and number of inode files are already determined when they are formatted.

Each inode file has a fixed size of 128byte;

Each file is Jinhui-occupied by an inode;

So the number of files the file system can create is related to the number of inode;

When the system reads the file, it finds the Inode and analyzes the permissions of the Inode record and whether the user is compliant, and if so, it can begin to actually read the block content.

Each inode has a number, and the operating system uses Inode numbers to identify different files.

It is worth repeating that theunix/linux system does not use file names, and inode numbers are used to identify files. For the system, the file name is just an alias or nickname for the inode number to easily identify.

On the surface, the user opens the file by file name. In fact, this process within the system is divided into three steps:

First, the system finds the inode number corresponding to the file name, and secondly, obtains the inode information through the inode number, and finally, according to the Inode information, finds the block where the file data resides and reads the data.

Ls-i Displays the inode number of the file.

Each block group may contain super block, each filesystem has only one superblock, and if the subsequent block group contains Super block, the primary is to complete a backup of the first block group.

File System Description Description System Description This section can describe the block number of each block group starting and ending, as well as the description of each segment (Super Block,bitmap,inodemap,data block) Between which block numbers are located.

Block Bitmap If you want to add a file, you always use block. Select blocks in the bitmap that are marked as empty.

Inode Bitmap Records unused inode numbers.

When we build a directory on the Linux ext2 system, ext2 allocates an inode and at least one block to the directory. Where Inode records the permissions and attributes of the directory, and can record the block number assigned to it, and block is the inode number that records the file name in this directory and the filename. The number of files under the directory is too large, and Linux gives the directory more than one block to store file-related records.

When we create a new file in Ext2, a block creates a 100kb file for 4KB, it requires 25 + 1 = 26 blocks to store the file, and since the Inode has only 12 direct points, there is one more block to be used as block number record.

If I want to read/etc/passwd then the reading order is like this,/the inode/block etc of the inode etc of the block passwd of the inode passwd.

Operation of the Linux file system

If you are editing a very large file, all the data must be loaded into memory, the CPU can read, the editing process needs to be written back to disk frequently, because the disk write speed is much slower than memory, so you need to wait for the hard disk to write/read frequently. So Linux uses asynchronous reads to solve this problem:

When a file is loaded into memory, if the file has not been altered, the in-memory file data is set to clean. If it changes, it is set to dirty. At this point all data is still in memory and is not written to disk. Dirty data is periodically written back to disk to keep the disk and memory data consistent. Use sync to write to disk manually. The normal shutdown system actively calls sync to manually force the disk to be written.

The file system must be mounted to one of the directories in the directory tree to be able to use the file system.

Boot process + File system notes

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.