Ext4 filesystem: data blocks, super blocks, inode structure

Photo by Mr Cup / Fabien Barral on Unsplash
Sector size types
Discarding device blocks: done

What are blocks and inodes?

Creating filesystem with 16777216 4k blocks and 4194304 inodes

What are blocks?

Each disk has a partition or partitions. The file system has to divide the partition(s) into block groups. Block groups are divided into blocks. A block is the maximum contiguous disk space that can be assigned/allocated to a file.

Why are 8 blocks allocated to the file?

In Linux Kernel, there is a structure called stat

How do the blocks look?

Image source: https://www.sciencedirect.com/science/article/pii/S1742287612000357

What is Block Group?

In a simple term, a block group consists of contiguous blocks combined. The number of blocks per group can be calculated as follows:

What are inodes?

In a simple term, inode is the identity card of the file. In Linux, every file must have an inode. Because inodes map the blocks to physical sectors. I would like to remind you that the data in the file is actually stored in blocks.

the first column is the inode number, the third column is the number of hard links

What are special inodes?

Inodes starts from 1. The inode of the root path / is 2. 1 is reserved for bad blocks. Some of the special paths (/proc, /sys, /dev) also have inode 1. Because those paths have pseudo file systems not real file systems (see; procfs, sysfs, devfs). Linux must show an inode for each path. That’s why Linux assumes their inode numbers as 1. You can find the other special inodes here.

the first column is the inode numbers
tree view with inodes

What is the Super Block?

You may have seen the Super Block in the mkfs.ext4 output. The Super block stores various information about the file system: block size, location of inode tables, size of block groups, and such (see the structure).

What is Inode Table and Inode Bitmap?

“mkfs.ext4 created inodes. Where are they stored in?” you may ask.

Part of dumpe2fs /dev/sdb output

What is the Group Descriptor Table?

Block groups have a special table, called: Group Descriptor Table.

What is the Data Block?

There are three types of data blocks; plain data block, directory data block, and symbolic-link data block.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store