Information about files(data) are sometimes called metadata.
Whenever a user or a program needs access to a file, the operating system first searches for the exact and unique inode (inode number), in a table called as an inode table.
the directory /var/log on my system.
Now lets note down inode numbers of .(dot) and ..(dot dot).
command "cd ." will change the directory to the current directory itself.the command "cd .." will take you to the previous directory.
the directory listing of /var/ directory and see the inodes there.
Inode Structure of a File
Mode:
This keeps information about two things, one is the permission information, the other is the type of inode, for example an inode can be of a file, directory or a block device etc.
Owner Info: Access details like owner of the file, group of the file etc.
Size: This location store the size of the file in terms of bytes.
Time Stamps: it stores the inode creation time, modification time, etc.
Now comes the important thing to understand about how a file is saved in a partition with the help of an inode.
Block Size: Whenever a partition is formatted with a file system.It normally gets formatted with a default block size. Now block size is the size of chunks in which data
will be spread. So if the block size is 4K, then for a file of 15K it will take 4 blocks(because 4K*4 16), and technically speaking you waste 1 K.
Direct Block Pointers:
In an ext2 file system an inode consists of only 15 block pointers. The first 12 block pointers are called as Direct Block pointers. Which means that these pointers point to the address of the blocks containing the data of the file. 12 Block pointers can point to 12 data blocks. So in total the Direct Block pointers can address only 48K(12 * 4K) of data
Indirect Block Pointers:
whenever the size of the data goes above 48k(by considering the block size as 4k), the 13th pointer in the inode will point to the very next block after the dataNow as we have took our block size as 4K, the indirect block pointer, can point to 1024 blocks containing data. which means an indirect block pointer can address, upto 4MB of data
Double indirect Block Pointers:
Now if the size of the file is above 4MB + 48K then the inode will start using Double Indirect Block Pointers, to address data blocks
so Double indirect block pointer can address 1024 Indirect Block pointers(which means 1024 * 4M =4G).So with the help of a double indirect Block Pointer the size of the data can go upto 4G.
No comments:
Post a Comment