CentOS basics: File System

Source: Internet
Author: User

CentOS basics: File System

We know that different operating systems use different file systems. For example, before Windows 98, the file system was FAT, and later versions of Windows 2000 were called NTFS file systems. For Linux, the regular file system is Ext2 (Linux second extended file system, Ext2fs ). Later, the Ext3 and Ext4 versions of the ultimate version appeared, but the overall change was not great.

Comparison of file systems

We often hear that Windows requires disk fragmentation, but Linux does not. Why?

First, let's look at the data access method of the FAT file system, as shown in.



Assume that the attributes and permissions of a file are stored in inode 3, and the actual data of the file is stored in four blocks: 1, 4, 6, and 11, then, when the operating system accesses the file, it can sort the reading order of the disk accordingly, and read the four blocks at one scan. This access method is called indexed allocation ). In addition, ext leaves a considerable amount of free space between every two files. When files are modified and their volume increases, they usually have enough space to expand. Therefore, to a certain extent, it ensures that the block access range does not have a large span and reduces the moving distance of the head.

What is Windows's file system like? Let's take FAT as an example.

When you store a file in the FAT file system, the system tries its best to store it near the start of the disk. When you store the second file, it is placed next to the first file. After frequent deletion and modification, the blocks will be extremely scattered. The FAT file system does not have inode, so you cannot read all the blocks of the file from the beginning. Each block number is recorded in the previous block to form a block chain. When we need to read a file, we must read the block one by one. For example, the reading sequence is 1, 6, 3, and 12. This will cause the head to be unable to get all the data in a circle on the disk. Sometimes it is necessary to rotate several circles to read the file, resulting in poor file reading performance. This is the reason Windows often needs to fragment-bringing discrete data together

Although the NTFS file system is smart, it allocates some buffer space around the file, but after a period of use, the NTFS file system will still form fragments. As ext is an indexed file system, disk fragmentation is not frequently required.

Ext2/ext3 File System

We know that in addition to the actual content of a file, file data usually includes many attributes, such as file permission (rwx) in Linux) and file attributes (owner, user group, time, size, etc ). The ext file system stores these two parts in different blocks, and the permissions and attributes are stored in inode. The actual data of the file is stored in the block. Another super block will record the overall system of the entire file system. Each inode and block has its own ID.

The ext file system is basically divided into multiple block groups during formatting. Each block group has an independent inode/block/super block system. The overall display is as follows:

The meanings of each block are as follows:

  • Super block: records the overall system of the file system, including the total inode and block quantity, usage, remaining amount, and file system type.
  • File system description: description of the file system. Describes the start and end block numbers of each block group.
  • Block bitmap: block table. It is used to quickly find available block blocks.
  • Inode bitmap: inode table. It is used to quickly find available inode blocks.
  • Inode table: the place where inode blocks are stored. They are the key to a file system. Records the attributes of a file. A file occupies one inode and contains multiple pointers pointing to each data block of the file.
  • Data block: the place where data is actually stored. Too many files occupy multiple blocks.
Summary

This section describes the differences between ext2/ext3 and other file systems, as well as the principle of eliminating disk fragmentation. Then, the system structure of the ext file system is analyzed to explain the significance of each data block. It focuses on understanding the different roles and significance of inode and block in Linux.

Linux is a file kingdom, and everything exists as a file. Understanding the Linux File System is an important step in understanding the operating system Linux principles.

References
  • Laruence's Linux private dish. Basic Learning

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.