Operations 11 min read

How Ext3/Ext4 Online Resizing Works: Disk Layout and Meta Block Groups Explained

This article explains the disk layout of ext3 and ext4 filesystems, the mechanisms behind online resizing, and how meta block groups overcome the limitations of reserved descriptor blocks, providing a clear understanding for Linux system administrators.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How Ext3/Ext4 Online Resizing Works: Disk Layout and Meta Block Groups Explained

Disk Layout

To understand online resizing, we first need to grasp the disk layout of ext3 and ext4 filesystems, which share the same structure. Each filesystem divides its managed disk or partition (excluding boot blocks) into equally sized block groups; the last group may contain fewer blocks. For a 4 KB block size, a block group is 168 MB.

Each block group contains essential metadata: a block bitmap, an inode bitmap, one or more blocks for the inode table, and data blocks for file contents. It may also include a superblock and a group descriptor table (GDT) depending on the group number and creation parameters.

The block bitmap tracks allocation status of blocks within the group; an unset bit indicates a free block. The inode bitmap tracks allocation of inodes, each representing a file's metadata. The inode table stores inode information across one or more blocks. The superblock holds global filesystem parameters and dynamic information such as free block and inode counts, located at the 1 KB offset at the start of the filesystem.

Group descriptors (GDT) store the locations of the block bitmap, inode bitmap, and inode table, as well as free block and inode counts. Each descriptor occupies 32 bytes, allowing 128 descriptors per 4 KB block, i.e., 128 block groups per descriptor block.

Online Resizing Mechanism

When expanding a filesystem, new physical blocks must be allocated to appropriate block groups. The process involves three steps:

Append physical blocks to the last block group until it is full.

If the GDT has space for a new group descriptor, add a new block group.

If the GDT cannot accommodate more descriptors, allocate additional blocks for descriptors. The kernel reserves a limited number of such blocks; when exhausted, a new approach called meta block groups is used.

The kernel reserves some blocks and an inode (inode 7) to manage these reserved blocks, preventing other allocations. When a new block group is created, any required superblock or GDT backups are stored, and the reserved blocks are added to the reserved descriptor inode. All operations are atomic, ensured by the JBD transaction mechanism.

Meta Block Group Mechanism

When reserved descriptor blocks are depleted, the filesystem cannot grow without unmounting and using external tools, which is unacceptable for production. The meta block group concept groups several block groups under a single descriptor block, allowing the filesystem to expand without relying on reserved blocks.

A meta block group consists of a series of block groups whose descriptors are stored in one block. In this layout, the superblock (if its group number is a power of 3, 5, or 7) and a descriptor block are placed at the start of the first, second, and last block groups of the meta block group.

Meta block groups are used when creating a filesystem (if the user opts for this layout) or when the filesystem grows and the reserved descriptor blocks are exhausted. The layout is efficient, providing sufficient redundancy; the GDT occupies only one block, and each meta block group can manage up to 16 GB of space with three backups of the descriptor table.

Conclusion

Because future capacity needs are hard to predict at filesystem creation, online resizing is essential. While this article focuses on the kernel mechanisms for ext3/ext4 online growth, users must first enlarge partitions or volumes using tools like LVM before applying ext2resize or similar utilities. The described mechanisms aim to help readers understand and implement online filesystem expansion.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Filesystemext4Ext3meta block grouponline resizing
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.