Linux Innode diagram 2

Source: Internet
Author: User

Http://www.opsers.org/linux-home/base/the-knowledge-that-one-day-learn-linux-file-system.html

The file system is the most important part of the operating system, which defines the methods and data structures for storing files on disk. The file system is an important means for the operating system to organize, access and store information, each operating system has its own file system, such as the file system used by Windows mainly have FAT16, FAT32 and Ntfs,linux file system mainly have ext2, ext3, EXT4 and ReiserFS and so on.

We know that a disk, to partition first, and then format, otherwise it can not be used, and this format is the process of file system creation, it can also be understood that a partition on disk, is a file system. This is like when we use Windows system, the partition can be formatted as FAT32, or formatted as NTFS, this is completely self-mastering, but the format of the file system must be the system you use to recognize. This is why NTFS file systems are not directly recognized by Linux systems. Similarly, Windows does not recognize the same EXT3/EXT4.
With regard to the definition of a file system, there is no standard answer, and if there is a higher interest to study the file system of friends, may find relevant information to consult. This article just takes everyone to understand the file system.

Learn about some of the file system related keywords

Storage media: Hard disk, CD-ROM, floppy disk, flash disk, tape, network storage device, etc.
Partition of disk: This is for large capacity storage devices, mainly refers to the hard disk, for large hard disk, we have to properly plan the partition, so we have to talk about the partition of the hard disk.

File system creation: This process is the process by which a storage device establishes a file system, often referred to as formatting or initialization, through a number of initialization tools.

Mount: The file system is only mounted to use, the Linux operating system is carried through mount, mount the file system to have mount point, for example, we in the process of installing Linux, sometimes prompted us to partition, and then set up the file system, and then ask your mount point is what. We in the use of the Linux system, will also mount other hard disk partitions, but also to select the mount point, the mount point is usually a vacant directory, preferably our own vacant directory built;
File system Visual Geometry: The file system is used to organize and arrange file access, so she is visible, in Linux, we can use LS and other tools to view its structure, in the Linux system, we see the tree structure, such as the operating system installed in a file system, he represented by/ The starting tree structure.

Introduction to common File system formats on Linux systems

EXT1: The first file system supported by Linux is the Minix file system. There is a serious performance problem with this filesystem, so there is another file system for Linux, the extended file system. The 1th Extended file System (EXT1) was designed by Remy card and introduced into Linux in April 1992. The Ext1 file system is the first file system to be exchanged using a virtual file system (VFS). Virtual file system switching is implemented in the 0.96C kernel and supports a maximum file system of 2GB.

EXT2: The 2nd Extended file System (EXT2) was also implemented by Remy Card and introduced to Linux in January 1993. It draws on the advanced ideas of the file system at that time, such as Berkeley Fast file systems [FFS]. The maximum file system supported by the EXT2 is 2TB, but the 2.6 core increases the maximum capacity supported by this filesystem to 32TB.

EXT3: The 3rd Extended file System (EXT3) is a major improvement on the Linux file system, even though it is inferior to some competitors in terms of performance. The Ext3 file system introduces a log concept to improve file system reliability when the system suddenly stops. Although some file systems perform better (such as Silicon Graphics's XFS and ibm®journaled file system [JFS]), EXT3 supports in-place (In-place) upgrades from systems using EXT2. Ext3 was implemented by Stephen Tweedie and introduced in November 2001.

The ext4:2.6.28 kernel is the first stable EXT4 file system. A number of improvements have been made in performance, scalability, and reliability. Most notably, EXT4 supports the 1 EB file system. EXT4 is implemented by a development team led by Theodore Tso (ext3 maintainer) and introduced into the 2.6.19 kernel. Currently, it is already stable in the 2.6.28 kernel (until December 2008).
EXT4 has borrowed a lot of useful ideas from rivals. For example, the use of extents (extent) has been implemented in a JFS to manage blocks. Another feature associated with block management (deferred allocation) has been implemented in XFS and Sun Microsystems ZFS.
In the Ext4 file system, you can discover a variety of improvements and innovations. These improvements include new features (new features), scalability (breaking the limits of current file systems) and reliability (coping with failures), and, of course, performance improvements.

Swap: It is a swap file system dedicated to swapping partitions in Linux. Linux is using this entire partition as a swap space. The swap partition in this swap format is typically twice times the main memory. When there is not enough memory, Linux writes some of the data to the swap partition.

How file Systems work

The work of the file system is related to the operating system's file data. The current operating system's file data, in addition to the actual contents of the file, usually contains a lot of attributes, such as file permissions (rwx) and file attributes (owner, user group, time parameters, etc.). The file system typically stores the two parts of the data in separate chunks, with permissions and attributes in the inode, and data in the block block. In addition, there is a super block that records the overall file system information, including the total number of inode and block, usage, amount of surplus, etc.

Each inode and block is numbered, and the meaning of these three data can be described briefly as follows:
? Superblock: Record The overall information of this filesystem, including the total amount of inode/block, the amount of use, the amount of surplus, and the format and related information of the file system;
? Inode: Records the properties of a file, a file occupies an inode, while recording the block number of the file's data;
? Block: The actual record of the contents of the file, if the file is too large, will occupy more than block.

Since each inode and block are numbered, each file occupies an inode and the inode number where the file data is placed. So, what we can know is that if we can find the inode of the file, then naturally we will know the block number of the data placed in the file, and of course it will be able to read the actual data of the file. This is a more efficient approach, because our disk will be able to read all the data in a short period of time, reading and writing performance is better.

We illustrate the inode and block blocks graphically, as shown in the file system first format the Inode and block blocks, assuming that the attribute and permission data of a file is placed in the Inode 4th (smaller box), and this inode records the actual placement of the file data points for 2, 7, 13, 15 of these four block numbers, at this time our operating system can arrange the reading order of the disk, can be a breath of four block content read out! Then the reading of the data is like the arrows specified in the shape.

Figure Inode/block Data Access

This method of data access is called an indexed file system (indexed allocation). Let's look at the fat in the Windows system, the file system in this format does not have an inode, so FAT has no way to read all blocks of the file at the beginning. Each block number is recorded in the previous block, and he reads a bit like this:

Figure FAT file system data access

We assume that the data in the file is written sequentially to the four block numbers of the 1->7->4->15 number, but this filesystem has no way of knowing the number of four blocks in one breath, and he will have to read the block in a single time before he knows where the next block is. If the block that writes the same file data is too fragmented, our disk read head will not be able to read all the data on the disk, so the disk will be more than a few laps to complete the contents of the file.

This is why defragmentation is often required in Windows systems, and the reason for defragmentation is that the block of file writes is too discrete, and the performance of the file reads becomes poor. This can be done by defragmenting the blocks that belong to the same file, so that the data is read more easily.

If the FAT file system needs to be defragmented on a regular basis, does EXT need disk grooming?
Since EXT is an indexed file system, there is basically no need for defragmentation. However, if the file system is used too long, often delete/edit/Add files, then it is possible to cause the file data is too discrete problem, this time may need to be restructured. However, it does not seem that many people are going to fragment the Linux disk!

As mentioned above, the contents of the inode are recorded in the file permissions and related attributes, as for the block block is the actual content of the record file. And the file system initially planned the inode and block, unless reformatting (or changing the file system size with instructions such as RESIZE2FS), the inode and block will no longer change after they are fixed. But if you think about it, if my document system is up to hundreds of GB, it would be unwise to put all the inode together with the block because the number of inode and block is too large to manage. Therefore, the Ext2 file system is basically differentiated into multiple block groups (block group) when formatted, and each chunk group has its own inode/block/superblock system.

EXT2 file System Structure detailed

As a whole, the Ext2 is a bit like the bottom of the following format:

Ext2 File System

In the overall planning, the filesystem has a boot sector (boot sector), this boot sector can install the Boot manager, this is a very important design, so we can install different boot management program to the front of the individual file system, without overwriting the entire hard disk unique MBR , so that you can create a multi-boot environment Ah! The six main elements of each block group are described below:

Data block (data block)
The data block is used to place the contents of the file, the block size supported in the Ext2 file system is 1 K, 2K and 4K three kinds. The size of the block is fixed at the time of formatting, and each block is numbered to facilitate the inode record. However, it is important to note that due to the block size difference, the maximum disk capacity that the file system can support is not the same as the maximum single file capacity. The Ext2 file system limitations resulting from block size are as follows:

You should be aware that although EXT2 has been able to support a single file size greater than 2GB, some applications still use the old restrictions, that is, some programs can only catch files less than 2GB, which is not related to the file system!

Note:
In principle, the size and number of blocks cannot be changed after formatting (unless reformatted);
A maximum of one file can be placed within each block;
If the file is larger than the block size, then a file will occupy multiple blocks of block;
If the file is less than block, then the remaining capacity of the block can no longer be used (disk space will be wasted);
If the file is large, it will take up more blocks, which will reduce the read and write performance of the filesystem.

Inode table (inode table)
Let's talk about the inode again! As mentioned above, the contents of the inode are recorded in the properties of the file and the actual data of the file is placed in which number of blocks inside! Basically, the file data for the Inode record has at least the following:
? The file's access mode (Read/write/excute);
? The owner and group of the file (Owner/group);
? The capacity of the file;
? The time the file was established or changed (CTime);
? Last read time (atime);
? Time of Last modification (mtime);
? Defines flags (flag) for file attributes, such as SetUID ... ;
? The point of the real content of the file (pointer);
The number and size of the inode is also fixed at the time of formatting, in addition to the Inode has the following features
? Each inode size is fixed to bytes;
? Each file will only occupy one inode;
? The number of documents the file system can establish is related to the number of inode;
? When the system reads the file, it needs to find the inode and analyze whether the permissions recorded by the inode are consistent with the user, and if so, it can begin to actually read the contents of the block.

Superblock (Super Block)
Superblock is a place to record information about the entire filesystem, there is no superblock, there is no such filesystem. The main information he has recorded are:
? Block and Inode Total;
? Number of unused and used inode/block;
? Block and Inode size (block is 1, 2, 4k,inode is bytes);
? Information about the file system such as the mount time of the filesystem, the last time the data was written, the time of the last Test disk (fsck), and so on;
? A valid bit value, if the file system is mounted, the valid bit is 0, and if not mounted, the valid bit is 1.
Superblock is very important because the basic information of our filesystem is written here. In general, the size of the superblock is 1024bytes.

Filesystem Description (File system description)
This section describes the start and end block numbers for each block group, and the number of blocks between each block (Superblock, Bitmap, Inodemap, and data block).

Block Bitmap (block table)
If you want to add a file and always use block, which block to use to record it? Of course, choose an empty block to record the data for the new file. So how do you know which block is empty? This would have to be aided by the block bitmap. From the block bitmap, you can tell which blocks are empty, so our system can quickly find the space available to use in the file. Similarly, if you delete certain files, then the block number that the file originally occupies must be released, at this time in block bitmap the corresponding to the block number of the flag to be modified to become unused, this is the function of bitmap.

Inode Bitmap (inode table)
This is actually similar to block bitmap, except that the block bitmap record is used with unused block numbers, as for Inode bitmap is the record used with unused inode numbers.

Finally give a EXT3 file system structure diagram, we can explain the Ext file system in detail.

Note: There is a point in this figure that needs to be fixed, that is, the MBR is not on the partition, but at the beginning of the disk, thank Netizens ice360 reminder, please refer to the comments section.

This article keywords: one day, learn linux,rhel6,ext4, file system

Linux Innode diagram 2

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.