Linux EXT2 File System-How to put ants and elephants into the refrigerator gracefully

Source: Internet
Author: User

This is a very lazy, all the while and his body in the lazy cancer struggle. In the end I was defeated, Sunday two days almost all abandoned the past, in the idle time actually I am also a bit anxious, do not know how to spend this time. Study it and do not want to study, watching TV entertainment it is not in the mood. In this state, I spent the Sunday, to today I was lying in the sash for a while to see Linux. This part has been seen before, but a cursory look, and did not devote energy. Today, I saw that there are still a lot of different Windows file systems and Linux. From the design point of view, the Linux file system seems to be more intelligent, after reading this part, I also prefer Linux.

Before looking at the Linux file system, I suggest that we still understand the file system of Windows. This helps us understand the Linux file system and the reason why the Linux file system is ahead of Windows. Now most of our computers are NTFS file system, this is mainly to solve the FAT32 single file can not exceed 4G of the drawbacks, of course, there are other improvements. Some modern software is particularly huge, downloading a lol online is more than 6G (has been separated for several files out). So in order to adapt to the rapid development of the software industry, now WinDOS system is mainly nfts file system.

Most of our USB flash drives are FAT file systems, so how fat is stored in the file. Typically, a USB drive is divided into chunks of data, a block of data blocks. Suppose a block is 4k and a file is 1M. You need 252 blocks to store this file. So how do you read all 256 blocks in the read? Starting with the first block, the second block is labeled at the end of each block, and so on until the last block is read. If I have a file that has a G, is it necessary to read it one after another and all the blocks are read to make up the files I need to execute? Will this efficiency be low? The following diagram depicts the process by which the FAT32 file system reads files. This process is a bit like the retrace described in the idiom. Not a picture of a hair, or paint the next.

The computer re-installed WIN10 has not installed drawing software, so can only caught dead, but the general meaning has been explained clearly. Each file block is marked with the location of the next file block, followed by a search.

But the Linux EXT2 file system is not looking for files like this, but rather in a very clever way. The Linux file system consists of three parts, super block, Inode,block.

Super block is mainly used to record the overall information of the file system, the equivalent of the total butler, recorded information including the total number of Inode block, the amount of used, the amount of surplus, file system format.

The inode (which I always spell as InnoDB) is used to record the properties of a file, and a file occupies an inode. Also record the block number of the file.

A block is a container that actually records the contents of a file. Many blocks are used to load when the file is very large. As shown:

The situation described is more complex. Because an inode has a fixed size of 128byte. The size of a block may be 1kb 2kb or 4KB depending on the setting.

The Inode records the information in this 128byte:

How this file is accessed: Read/write/excute

The owner of the file belongs to group: Owner/group

The size of the file

Three time for this file: CTime atime mtime

The flag that defines the file: Flag SetUID.

Point to the real content of the file: pointer

In addition, an inode can specify a file number of 12 blocks.

The above diagram summarizes a sentence: 12 Direct, one indirect, one double indirect, one three indirect record area.

If a block is 1kb. So

12 Direct points: * 1 = 12k.

An indirect: a Block records 256 records. * 1k = 256kb

Dual-indirect: a block store stores 256 blocks of location. All 256 blocks are stored in the block data.

Data Volume: 1k

Three indirect: * * * * 1kb.

Total value: 12k + 256kb + 256+ * * * * * *

About this file system. Everyone knows the basics, and know how he works and the subtleties of design.

It's a very subtle way to put ants and elephants into the freezer gracefully.

Linux EXT2 File System-How to put ants and elephants into the refrigerator gracefully

Related Article

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.