258 Chapter 14
Figure 14-2: Structure of file blocks for a file in an ext2 file system
As an example, the author measured one system containing somewhat more
than 150,000 files. Just over 30% of the files were less than 1000 bytes in size,
and 80% occupied 10,000 bytes or less. Assuming a 1024-byte block size, all of
the latter files could be referenced using just the 12 direct pointers, which can
refer to blocks containing a total of 12,288 bytes. Using a 4096-byte block
size, this limit rises to 49,152 bytes (95% of the files on the system fell under
that limit).
This design also allows for enormous file sizes; for a block size of 4096 bytes, the
theoretical largest file size is slightly more than 1024*1024*1024*4096, or approxi-
mately 4 terabytes (4096 GB). (We say slightly more because of the blocks pointed to
by the direct, indirect, and double indirect pointers. These are insignificant com-
pared to the range that can be pointed to by the triple indirect pointer.)
Key
DB = Data block
IPB = Indirect pointer block
2IPB = Double IBP
3IPB = Triple IPB
(^0) Note: not all blocks are shown
IPB
DB 11 DB 12
2IPB
3IPB
DB 0
DB 13
IPB
IPB
2IPB
IPB
IPB
DB
DB
2IPB
DB
DB 5
i-node entry
Other file
information
1
9
2
8
7
6
5
4
3
12
11
10
14
13
Pointers to indirectly
addressed file blocks
Direct pointers
to file blocks