File system architecture for Linux and Windows

Source: Internet
Author: User

Yesterday, the new brother asked me the difference between the inode, and said a long time did not speak clearly, their own back hurriedly Baidu a bit

Just move the bricks as usual.

One. File storage

The file is stored on the hard disk, and the minimum storage unit for the hard disk is called sector. 512 bytes per sector, when the operating system reads the hard disk, it does not read from sector to region, so

The efficiency is too low, but a continuous reading of multiple sectors, that is, one time to read a block. This "block", composed of multiple sectors, is the smallest unit of file access. The size of the "block", the most common is

4kn, that is, eight consecutive sector to form a block.

File data is stored in the "block", then obviously, we must also find a place to store the meta-information of the file, such as the creator of the file, the creation date of the file,

The size of the file, and so on. This area of storing file meta information is called Inode, and the Chinese name is "index node"

The inode contains meta information for the file, including the following

1. Number of bytes in the file

2. UserID of the file owner

3. GroupID of documents

4. Read the file. Write. Execute permissions

5. File timestamp CTime refers to the time that the inode was last changed (permissions, attributes)

Mtime refers to the time that the Inode was last modified (content)

Atime refers to the last access time

But in fact, the Mtime (attribute) changes as a result of the modification of the content, which indirectly causes CTime to change.

Two. The size of the Inode

The inode also consumes hard disk space, so when the hard disk is formatted, the operating system automatically divides the hard disk into two zones. One is the data area, the file data is stored, and the other is

Inode area, which holds the information contained in the Inode, the size of each inode node, typically 128 bytes or 256 bytes. The total number of inode nodes,

Given at the time of formatting.

Instead of using file names inside UNIX systems, you use inode numbers to identify files.

The process of opening a file

1. The system finds the inode number corresponding to the file name, and secondly, obtains the inode information through the inode number;

Finally, based on the Inode information, locate the block where the file data resides and read the data

An inode that corresponds to multiple files is called a hard connection, and modifying a file content affects all file names

But deleting a file does not affect access to another file

Two. Windows FAT file structure

Reserved sectors

At the beginning of the position. The first reserved sector is the boot area (partition boot)

Fat Area

It contains two file allocation tables, redundancy considerations, it is the partition information mapping table indicates how the cluster is stored

root directory Zone

It is the directory table in the root directory where file and directory information is stored, and under FAT32 it can exist anywhere in the partition.

Data area

The whole disk should be like this

We get the BPB of each fat table, preserve the sector, and know the starting sector of the FDT

The first cluster number of the file is obtained by FDT, and the starting sector position of the file is obtained by the first cluster number.

Reads the record of the file in the data area.

Personal feeling, through the FDT table to locate the first cluster of files, through the Fat table (it records how the file is scattered in different sectors), forming a cluster chain.

File system architecture for Linux and Windows

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.