Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the concept of Inodes

I am referring to the link about concepts of Inodes

I am confused on parts:

  1. 12 direct block pointers
  2. 1 single indirect block pointer
  3. 1 double indirect block pointer
  4. 1 triple indirect block pointer

Now the diagram says that each pointer is 32/64 bits.

  • [Query]: Why and how are these values inferred? I mean why specifically have only 32 or 64 bit pointers?

The diagram says, One data block {8 KB} for each pointer {4 bytes/8 bytes}

  • [Query]: How does this actually work out? i.e. 8*1024 bytes / 8 bytes = 1024 bytes? What is the logic behind having a 8 bytes pointer for 8KB block?
like image 274
name_masked Avatar asked May 02 '10 21:05

name_masked


People also ask

How would you explain what an inode is?

What is an inode? By definition, an inode is an index node. It serves as a unique identifier for a specific piece of metadata on a given filesystem. Each piece of metadata describes what we think of as a file. That's right, inodes operate on each filesystem, independent of the others.

What is inode used for?

Inode is a Linux (and other Unix-like) data structure used to keep information about the files, folders, emails, code, and everything else on your server. The number of inodes corresponds the number of files and folders you have.

Why is it called inode?

The entry found thereby (the file's i-node) contains the description of the file. Additionally, Maurice J. Bach wrote that an inode "is a contraction of the term index node and is commonly used in literature on the UNIX system".

What are the contents of inode?

The Inode contains the following information: Size of the file. Date and Time of Last modification of the file data. Date and Time of Last access of file data. Date and Time of Last change of the I-node.


1 Answers

Sample calculation of maximum file size

* Assume that there are 10 direct pointers to data blocks, 1 indirect pointer, 1 double indirect pointer, and 1 triple indirect pointer
* Assume that the size of the data blocks is 1024 bytes = 1Kb, i.e., BlockSize = 1Kb
* Assume that the block numbers are represented as 4 byte unsigned integers, i.e., BlockNumberSize = 4b
* Some data blocks are used as index blocks. They store 1024 bytes / 4 bytes/entry = 256 entries
* Maximum number of bytes addressed by 10 direct pointers is

    = Number of direct pointers * Blocksize 
    = 10 * 1Kb
    = 10Kb


* Maximum number of bytes addressed by single indirect pointer is

    = NumberOfEntries * BlockSize
    = (Blocksize / BlockNumberSize) * BlockSize
    = (1Kb / 4b) * 1Kb
    = 256 * 1Kb
    = 256Kb


* Maximum number of bytes addressed by double indirect pointer is

    = NumberOfEntries^2 * BlockSize
    = (Blocksize / BlockNumberSize)^2 * BlockSize
    = (1Kb / 4b)^2 * 1Kb
    = (2^10 / 2^2)^2 * (2^10b)
    = (2^8)^2 * (2^10)b
    = (2^16) * (2^10)b
    = 2^6 * 2^20 b
    = 64 Mb


* Maximum number of bytes addressed by triple indirect pointer is

    = NumberOfEntries^3 * BlockSize
    = (Blocksize / BlockNumberSize)^3 * BlockSize
    = (1Kb / 4b)^3 * 1Kb
    = (2^10 / 2^2)^3 * (2^10b)
    = (2^8)^3 * (2^10)b
    = (2^24) * (2^10)b
    = 2^4 * 2^30 b
    = 16 Gb


* Maximum file size is 16Gb + 64Mb + 266Kb 
like image 128
swapnil akolkar Avatar answered Oct 09 '22 00:10

swapnil akolkar