Ext2: Difference between revisions

769 bytes added ,  1 year ago
→‎Base Superblock Fields: clarify the superblock block number field is also the starting block number
[unchecked revision][unchecked revision]
(→‎Base Superblock Fields: clarify the superblock block number field is also the starting block number)
 
(11 intermediate revisions by 9 users not shown)
Line 11:
 
=== What is a Block Group? ===
Blocks, along with inodes, are divvieddivided up into "block groups." These are nothing more than contiguous groups of blocks.
 
Each block group reserves a few of its blocks for special purposes such as:
Line 55:
| 16 || 19 || 4 || Total number of unallocated inodes
|-
| 20 || 23 || 4 || Block number of the block containing the superblock (also the starting block number, NOT always zero.)
|-
| 24 || 27 || 4 || ''log''<sub>2</sub> (block size) - 10. (In other words, the number to shift 1,024 to the left by to obtain the block size)
Line 263:
Like blocks, each inode has a numerical address. It is extremely important to note that unlike block addresses, '''inode addresses start at 1'''.
 
With Ext2 versions prior to Major version 1, inodes 1 to 10 are reserved and should be in an allocated state. Starting with version 1, the first non-reserved inode is indicated via a field in the Superblock. Of the reserved inodes, number 2 has subjectively has the most significance as it is used for the root directory.
 
Inodes have a fixed size of either 128 for version 0 Ext2 file systems, or as dictated by the field in the Superblock for version 1 file systems. All inodes reside in inode tables that belong to block groups. Therefore, looking up an inode is simply a matter of determining which block group it belongs to and indexing that block group's inode table.
Line 300:
'''Triply Indirect Block Pointer''': Lastly, if a file needs still more space, it can use a triple indirect block. Again, this is an extension of the double indirect block. So, a triple indirect block contains addresses of double indirect blocks, which contain addresses of single indirect blocks, which contain address of data blocks. The inode structure has a "Triply Indirect Block Pointer" field that points to this block if present.
 
[http://en.wikipedia.org/wiki/File:Ext2-inode.gif This image from Wikipedia] illustrates what is described above pretty well.
 
=== Inode Data Structure ===
Line 321:
| 8 || 11 || 4 || Last Access Time (in [http://en.wikipedia.org/wiki/Unix_time POSIX time])
|-
| 12 || 15 || 4 || Last ChangeCreation Time (in [http://en.wikipedia.org/wiki/Unix_time POSIX time])
|-
| 16 || 19 || 4 || Last Modification time (in [http://en.wikipedia.org/wiki/Unix_time POSIX time])
Line 543:
|}
|}
 
=== Directories ===
Directories are inodes which contain some number of "entries" as their contents. These entries are nothing more than a name/inode pair. For instance the inode corresponding to the root directory might have an entry with the name of "etc" and an inode value of 50. A directory inode stores these entries in a linked-list fashion in its contents blocks.
 
The root directory is Inode 2.
 
The total size of a directory entry may be longer then the length of the name would imply (The name may not span to the end of the record), and records have to be aligned to 4-byte boundaries. Directory entries are also not allowed to span multiple blocks on the file-system, so there may be empty space in-between directory entries. Empty space is however not allowed in-between directory entries, so any possible empty space will be used as part of the preceding record by increasing its record length to include the empty space. Empty space may also be equivalently marked by a separate directory entry with an inode number of zero, indicating that directory entry should be skipped.
 
=== Directory Entry ===
 
Line 608 ⟶ 612:
The root directory's inode is defined to always be 2. Read/parse the contents of inode 2.
 
==See Links Also==
===External Links===
* [http://www.nongnu.org/ext2-doc/ ext2-doc project: Second Extended File System] - implementation-oriented documentation, describes internal structure in human language.
* [http://web.mit.edu/tytso/www/linux/ext2intro.html Design and Implementation of the Second Extended Filesystem] (overview)
Line 614 ⟶ 619:
 
[[Category:Filesystems]]
[[de:Ext2]]
Anonymous user