Linux storage superblock

Linux system has called a super block"hard disk MAP".

Linux is not the content of the document is written directly to the "hard disk map" inside, but super blockwhich records information about the entire file system. Because if all the contents of the file are written to the inside, its volume will become very large, and query and write speed file content will become very slow.

Linux is the authority attribute of each file recorded inodein the file and each occupies a separate inode tables, default size of this table is 128 bytes, which records the following information:

  • Access the file (read, write, execute);
  • The owner of the file with the belonging group (owner, group);
  • The file size (size);
  • Create or contents of the file modification time (ctime);
  • Last access time (atime) for the file;
  • The file modification time (the mtime);
  • Special file permissions (SUID, SGID, SBIT);
  • The real address of the data file (point).

The actual contents of the file is stored in the block blocks (size may be 1KB, 2KB or 4KB), only the default size of an inode 128B (Ext3), a block record is consumed 4B.

When the inode file is filled, Linux system automatically assigns a block block, dedicated to recording as other information like block inode blocks, each block so that the block content to string together, it is possible to allow the user to read the complete the contents of the file. Block for block storage file content, the following two cases of common (to 4KB block size as an example)

  • ➢ Case 1: The file is very small (1KB), but still occupies one block, thus potentially wasting 3KB.
  • ➢ Case 2: very large file (5KB), it will take two block (after 5KB-4KB remaining 1KB have occupied a block).

PS: Tips

Create a hard link in Linux system when a pointer is created with a inodepointer, because in use ls -lwhen the instruction, will be able to view the created hard links to the file inodenumber is greater than 1!

Therefore, when you delete a file, if the inode number points to greater than one, in fact, does not delete the file, but will delete the current pointer, the other pointing to the inode file can still be accessed!

Released two original articles · won praise 0 · Views 50

Guess you like

Origin blog.csdn.net/qq_45976844/article/details/104408660