"Bird Brother-Basic Learning" Summary (8): Linux disk and File System Management Understanding EXT2 System

Source: Internet
Author: User

1 disk composition and partition 1.1 disk physical composition (1) Circular disc-recording data (2) mechanical arm and head-read and write disc data (3) Spindle motor-enables the robot to read and write Data driven 1.2 platters physical composition (1) sector-minimum physical storage unit, 512bytes (2) Cylinder- Sector consists of a circle, the smallest unit of partition (3) The first sector-the most important sector, contains the master boot record mbr446bytes and the partition table PB 64bytes1.3 Disk interface in the Linux Chinese name (1)/dev/sd[a-p][1-15] for SCSI, SATA, USB, Flash, and other interface disk file name (2)/dev/hd[a-d][a-63] is the IDE interface of the disk file name 2 file system features 2.1 File systems used by different operating systems (1) The traditional Windows98 and the previous operating system mainly use the file system for FAT or FAT16 (2) Windows2000 and later operating systems mainly using NTFS for its file system (3) Linux operating system of the formal file system are EXT2 or EXT3 as a storage block for its file system 2.2 file systemGenerally, file systems typically have three storage blocks: (1) Super BLOCK: Super blocks, which are used to store the overall information of the filesystem, including the total amount of the remaining two innode and blocks, the amount of usage, Remaining Amount and file system format and file information (2) Innode: The attribute information of the main record file, a file occupies a innode block, while the actual data of the file is located in the block number (3) Block: The actual data of the main record file, May occupy one or more blocks depending on the actual data access mode for 2.3 different file systems (1) Indexed file systemThe Innode block of such file system stores the number of all blocks in which the actual data of the file resides, at which point the operating system can begin to read all of the block where the file data resides. Linux EXT2, EXT3 are such file systems, the advantages of an indexed file system: It basically does not need to defragment, because its files are written to the block is not too discrete.Structures such as:
(2) FAT file systemSuch a file system does not have a innode block, so there is no block that initially reads the actual data from the file. This filesystem, usually a block, stores the number of the next block to be accessed, which can easily cause the file data block to be too discrete. So the FAT file system needs to be defragmented frequently to ensure its performance. The USB flash drive we usually use is generally the FAT file system used.Structures such as:

3 Linux EXT2 File System 3.1 EXT2 storage block detailedFor Linux EXT2 and EXT3 file systems, there are 3 storage blocks, super block, Innode, and block, and the file system starts with Innode and block planning, unless reformatting or using commands such as resize2fs to change, Otherwise, these two parts will not be changed. (1) Data blockThe data block is the block used to store files, and the size of blocks supported in the EXT2 file system is 1KB, 2KB, and 4KB of three.The size of the data block is initialized at the beginning of the file system and is no longer changed.A block can store at most one file of data, and the data of one file may be stored in multiple blocks depending on the actual amount of content.For files smaller than the block size, the remaining capacity in the block can no longer be used by other files, resulting in a certain amount of wasted disk space. (2) Innode blockInnode the attributes of the primary record file and the number of the actual data stored in the block.Specifically, the contents stored in the Innode block are:The access mode of the file;The file size;The owner and group of the file;The time when the file created a state change;The time of the most recent modification;Define the attributes of the file, such as setuid, etc.;The direction of the real content of the file;Innode block size is also determined when the file system is formatted, each block size is fixed to 128bytes, each file will only occupy a innode block.The number of files the file system can create is related to the number of Innode.When the system reads the file, it first finds the Innode, analyzes the permissions, and reads the contents of the block when it meets the requirements.Innode block is closely related to file size, because Innode size is limited, only 128bytes capacity, record a block number occupies 4bytes, and for large files need a lot of block to store data, The number of blocks is far beyond the capacity that the Innode block can store. To this end, the file system uses a multi-level storage structure, there are 12 direct, 1 indirect, a double indirect, a three-indirect record area, so that the large file to meet the numerous block number records.Innode multistage structures such as:
So, how many blocks can such a storage structure specify? In the smaller 1KB block:12 direct pointing, 12*1k=12k, direct pointing can record 12;Indirect point, 256*1k=256k, each block number of records need 4bytes, so 1K size can record 256;Double indirect, 256*256*1k, the first layer specifies 256 records, each second level specifies 256;Three indirect, 256*256*256*1k, the first layer specifies 256 records, each second level is specified 256, each third layer also specifies 256 records;Total, 12+256+256*256+256*256*256 (K) =16GBAt this point, we know that when the file system divides the block into 1KB, the largest file that can hold is 16GB, which is consistent with the file restriction table results. However, this method is not applicable when the block size is 2KB or 4KB, because the block larger than 2KB will be limited by the EXT2 file system itself, and the calculation results and the restriction table.
(3) Super blockwhere this block records information about the entire file system, the main records are:Block and the total amount of innode;The number of unused and used innode/block;The size of block and innode;File system mount time, the last time the data was written, the last time the disk was checked, and so on;A validbit value, a mount of 0, a non-mounted value of 1;3.2 EXT2 the relationship between the file system and the directory tree 3.3 EXT2 with EXT3 file system access with log file system 3.4 file system operation and mount point 3.5 Other Linux file systems the above sections are highly theoretical and read through the Brother Bird's Linux private dishes-Basic study p204-209 understand.

"Bird Brother-Basic Learning" Summary (8): Linux disk and File System Management Understanding EXT2 System

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.