Comprehensive parsing of file file systems

Source: Internet
Author: User

Objective:

file system as Linux is the most basic hope. Understanding and understanding the file system is important for Linux learning. We introduce the relevant concepts of the file system from the file system creation, composition and workflow aspects.

Briefly:

Once a complete disk has been partitioned, we can format it and build the file system format that the file system can use according to our needs. In a traditional document system, a partition can only be formatted as a file system. So we can say that a file system is a partition. But because of the new technology reference, we are no longer said to be formatted for the partition in the format, usually we can refer to a data can be mounted as a file system.

file system files in addition to the contents of the file itself, Typically, there are many properties that are not related to the contents of the file itself, such as permissions on the file, time parameters, owner, etc. We refer to the properties of this file itself as Meta data (metadata), The contents of the file are called data ( data. reference node ) data Block region. There is also a Super block ( superblock inode block

The basic unit of a disk is a sector, each sector size is a number of bytes, if the file system to sector as the basic storage units, and then to each sector numbering, then the number of the sector alone is a large amount of storage space, so the file system is block For the smallest storage unit, a block typically has a size of either a 4096 byte or a minimum of bytes, which must be set in disk format and cannot be modified thereafter. A block can place a maximum of one file, even if the file is only 1 bytes.

Both the Inode and The block are numbered. Each file occupies an inode, and the metadata stored in the inode contains the block number where the file data is placed . Because if you can find the Inode , you will naturally know the block number of the data placed in the file . Of course, you can read the actual data of the file.

we'll Inode blocks are illustrated by illustrations, as shown in the file system first formatted Inode and block inode4< Span style= "font-family: ' The song Body '; The position of the number, and this inode recorded the file data actually stored in 2 7 13 15 number corresponding to block 4 block (indexed allocation)

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161020/1476961846180863.jpg "title= "1476961846180863.jpg" alt= "Filesystem-1.jpg"/>


Detailed Description:

through the previous brief, We have probably learned about the linux filesystem-related concepts: inode block superblock Inode block Well, plan it, Unless the file system size is changed from a new format (or by using the resize2fs inode block no changes after fixed. For the convenience of management, Inode and block block Group inode/ Block/superblock system. linux The file system is formatted a bit like this:

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161020/1476961879155614.jpg "title= "1476961879155614.jpg" alt= "Block Group.jpg"/>

The contents of each block are described below:

    • Data Block


the data block is the place where you store your files. In the Linux file system , the size of the block has 1k,2k and 4K three kinds. the size of the block is fixed when formatting, and each block is numbered to facilitate the inode record.

    • Inode table (inode table )


The Inode primarily holds metadata for the following files:

file type, permissions, Uid,gid

Number of links (that is, number of hard links)

the size of the file and the different timestamps

data block pointer to file on disk

defines the markup for file attributes, such as SetUID.

eachInodethe size is fixed tobytes(The newExt4with theXfscan be set to256bytes), each file occupies only oneInode. ABlockthe size is just a fewK, while a file is much larger, andInoderecord an articleBlockThe numbers are going to take away4bytes, then how do we use128bytes ofInodeto record thousands ofBlockWhat about the number records? For this reason our system is smart enough toInodeRecordBlockthe area of the number is defined as12A direct, an indirect, a double indirect, a triple indirect. What is this? We putInodestructure to draw out:

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161020/1476961910728136.jpg "title= "1476961910728136.jpg" alt= "Inode.jpg"/>

left forInodeitself( +bytes), there are Aa direct pointBlocknumber of the control, which AA record can be obtained directly .Blocknumber. Then the so-called introduction is to take aBlockas a record.Blocknumber of loggers, if the file is too large it will use the introBlockto record the number. Similarly, if the file continues to grow, then it will take advantage of the so-called double-indirect, firstBlockonly the next record number is indicated.Blockwhere the actual record in the secondBlockamong them. And so on, three is the use of the third layerBlockto record the number.


    • Superblock ( Super block )


Superblock is a place to record information about the entire file system, without superblock, there isno entire file system, the information mainly includes:block and inode Total, The number of unused,block and inode sizes, file system various time, and the status of the file system are mounted or not identified.

there is only one superblock in a file system , except that the first block group contains fragments and blocks , and the subsequent block group does not necessarily contain Superblock, even if it is, is just a backup of the Surperblock within the first block group .


    • Filesystem Description(File system description)


This section describes the start and end block numbers for each block group and describes each section (Superblock,bitmap,inodemap,data block) Between the two block numbers, respectively .


    • Block bitmap(block table) and inode bitmap(inode table)


Used and unused block numbers and inode numbers are recorded separately . When we use or release blocks or inode, we can view these two tables.


Directory

A special file in a Linux file is a directory file, first of all, do not be disturbed by the idea of folders in Windows. The contents of a directory file are the table of filenames and inode numbers for all files in a directory.

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161020/1476963569550612.jpg "title= "1476963569550612.jpg" alt= "directory. jpg"/>

When we open a directory named file 1 file, the system through the table of contents to find the file inode number, through the inode number to obtain the inode information, and finally based on the Inode information to find the location of the file data, read out the data. So the directory is not a box to put files in the inside, but a list of files, and then through this list to find files.

Summarize:

About the basic concept of file system here, and then the permissions of the file, but also a chunk of content, scoring a separate blog to explain. The file system is the foundation of Linux, and understanding its various basic concepts is essential to learning Linux.



This article is from the "mechanism of small Wind" blog, please be sure to keep this source http://xiaofengfeng.blog.51cto.com/8193303/1870406

Comprehensive parsing of file file systems

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.