|
Let me talk about the format: file attributes for each operating system settings / permissions are not the same, in order to store the data required for these files, so you need to format the partition to become the operating system can take advantage of file system format. linux file format Ext2 / Ext3, now seems to have the Ext4.windows operating system vfat or NTFS.
linux file system:
Operating system file data in addition to the actual content of the file, there are a lot of attributes, such as file permissions (rwx) and the file attributes (owner, group, time parameters, etc.).
The two parts of the file system data is typically stored in different blocks. Permissions property into the inode, the actual data into the data block in.
There is also a super block (super block) file system information will be recorded as a whole, including the number and amounts used of the inode and block.
inode: Record file attributes of a file occupies one inode, while recording the data in this file is where the block number;
block: The actual contents of the log file, if the file is too large will take more than one block;
super block: recording information of the file system as a whole, including the total amount of inode / block, the usage, the remaining amount, as well as the format of the file system and related information.
Each inode and block are numbered, and each will be occupied by a file system inode, inode file data in place of block numbers. We can find the inode file, and then find the file number of the data block is placed, after reading data. This data access become indexed file system. Such file systems generally require less frequent disk defragmentation.
The U-such as the FAT file format, each block number recorded in the previous block number, and therefore poor read performance data, with a long terrible defragmented.
the linux Ext2 file system inode and block the outset planned, unless reformatted (or use resize2fs commands to change the file system size), otherwise the inode and block fixed after no longer change.
If the file system is too large, all the inode and block together is difficult to manage, so the Ext2 file system when formatting is basically divided into a plurality of groups of blocks (block group), each group has its own block inode / block / super block system.
data block (data block)
Ext2 file system supports block has 1K, 2K, 4K three. When formatting block it has been fixed, and each block has a number. Note, however, due to the different block sizes can cause the file system can support a maximum disk capacity and the maximum capacity is not the same as a single file.
block used is too small, use a file two more block, inode records will increase, reducing the read and write performance.
If the block is too large, small files when the remaining space will not be used, would be a waste of resources.
inodetable (inode table)
To tell you the file data inode.inode records must contain at least the following:
Access mode of the file;
Owner of the file with all groups;
The size of the file;
Created or the file's status change time (ctime);
Last read time (atime);
Recent modification time (mtime);
The document points to the real content.
There are about inode Features:
Each inode size are fixed 128bytes;
Each file occupies a inode;
When reading the file system you need to find inode, inode and analyze the recorded permissions and user compliance, if they meet to be able to read the contents of the block.
But there is a problem, the file attributes to be recorded particularly large, but a file may have a lot block, and inode is too small (a recording block to use 4byte), how to do? linux solution is: the area defining block inode record number of 12 direct and an indirect, one triple and a double indirection indirect recording area. Number block can record a total of: 12 + 256 + 256 * 256 + 256 * 256 * 256 (K) = 16G only meet the block size is 1K when the case.
Superblock (superblock)
The overall situation there is record of the file system. For example, a file system mount time, the last time data is written, the last test disk (fsck) of the time. There is also a validbit value, if this file system has been mounted, validbit is 0, If it is not mounted, the validbit is 1.
Understand the concept of file system after, of course, is to view the file system, use the following command:
# Dumpe2fs [-bh] device file name
-b lists the reserved portion of bad sectors
-h lists only superblock data, does not list the contents of other sections.
E.g:
# Dumpe2fs / dev / hdc2 |
|
|
|