# Linux File System (Inode block Superblock)

Source: Internet
Author: User
Tags file permissions

Let's start with the formatting: The file attributes/permissions set by each operating system are not the same, and in order to store the data needed for these files, you need to format the partition to be a file system format that the operating system can take advantage of. The file format for Linux is EXT2/EXT3, and it now seems to have reached the Ext4.windows operating system for VFAT or NTFS.

Linux File system:

The operating system's file data, in addition to the actual contents of the file, there are a lot of attributes, such as file permissions (rwx) and file attributes (owner, group, time parameters, etc.).
The file system usually stores these two pieces of data in different blocks. The permissions attribute is placed in the inode, and the actual data is placed in the database block.
There is also a super block that records the overall information about the file system, including the number of Inode and block, usage, and so on.

  • Inode: Log file attributes, a file occupies an inode, while recording the data of this file block number;
  • Block: The actual record of the contents of the file, if the file is too large to occupy multiple blocks; super
  • Block: Records the overall file system information, including the total amount of inode/block, the amount of use, the amount of surplus, and the format of the file system and related information.

Each inode and block is numbered, and each file system consumes a block number with file data placed in the Inode,inode. We can find the inode of the file, then find the block number of the data placed in the file, and then read the data. This type of data access becomes an indexed file system. Such file systems generally do not require frequent disk defragmentation.
and the U disk, such as the FAT file format, each block number is recorded in the previous block number, so the data read performance is poor, with a long time to defragment.

Linux's Ext2 file system initially planned the inode and block, unless reformatted (or using commands such as RESIZE2FS to change the file system size), the inode and block will no longer change after they are fixed.

If the file system is too large, it is difficult to manage all the inode and block together, so the Ext2 file system is basically differentiated into multiple block groups when it is formatted, and each block group has its own Inode/block/super block system.

Data Block (blocks)

The Ext2 file system supports a block with 1k,2k,4k three types. The block is fixed at the time of formatting, and each block is numbered. Note, however, that due to the size of the block, the maximum disk capacity that the file system can support is different from the maximum single file capacity.
If the block used is too small, a file with more than two Block,inode records will also increase, reducing read and write performance.
If the block is too large, when the file is small, the remaining space will not be used, will waste resources.

Inodetable (inode table)

Say it again. The file data for the Inode.inode record must contain at least the following:
The access mode of the file;
The owner of the file is associated with all groups;
The size of the file;
The creation of the file or the time of the state Change (CTime);
Last read time (atime);
Last modified time (mtime);
The actual content of the file is pointed to.
The Inode also features:
Each inode size is fixed to 128bytes;
Each file will occupy an 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, the contents of the block can be read.
However, there is a problem, need to record the file attributes are particularly large, and a file may have a lot of blocks, and the inode is too small (record a block to use 4byte), how to do? The solution for Linux is to define the area of the Inode record block number as 12 direct, one indirect, one double indirect, and one three indirect record area. The total number of blocks that can be recorded is: 12+256+256256+256256*256 (K) =16g This only happens when the block size is 1K.

Superblock (Super Block)

This records the overall situation of the file system. such as the mount time of the file system, the last time the data was written, the time of the last Test disk (fsck), and so on. There is also a validbit value, if the file system has been mounted, the value of Validbit is 0, if not mounted, the Validbit value is 1.

After understanding the concept of the file system, of course, to view the file system, with the following command:

DUMPE2FS [-BH] Device file name
-B lists the sections reserved for bad lanes
-h lists only superblock data and does not list other sections.
For example:
Dumpe2fs/dev/hdc2 '

# Linux File System (Inode block Superblock)

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.