The First 1024 Bytes Tell You Everything About the Disk Layout
May 2026
Where It Lives
On an ext4 partition, skip the first 1024 bytes (reserved for boot code). At byte offset 1024 sits a 1024-byte record called the superblock. Every number you need to navigate the rest of the disk is in this record.
Partition start: byte 0
Boot area: bytes [0 .. 1023] (1024 bytes, unused by filesystem)
Superblock: bytes [1024 .. 2047] (1024 bytes, the geometry record)
Critical Fields (With Real Byte Offsets)
The superblock is a C struct. Every field has a fixed byte offset from the start of the record. Here are the ones that matter most:
| Offset | Size | Field | What It Tells You |
|---|---|---|---|
0x00 | 4 | s_inodes_count | Total metadata-record slots on this disk |
0x04 | 4 | s_blocks_count_lo | Total 4096-byte blocks (low 32 bits) |
0x18 | 4 | s_log_block_size | Block size = 2^(10 + this value). Value 2 → 2^12 = 4096 |
0x20 | 4 | s_blocks_per_group | How many blocks in each group (typically 32768) |
0x28 | 4 | s_inodes_per_group | Metadata-record slots per group |
0x38 | 2 | s_magic | Must be 0xEF53 or this isn't ext2/3/4 |
0x58 | 4 | s_inode_size | Bytes per metadata-record (256 for ext4) |
0xFE | 4 | s_log_groups_per_flex | 2^N groups packed into one flex group |
Proving It: Hexdump a Real Superblock
# Skip 1024 bytes, read 256 bytes from the superblock
$ sudo dd if=/dev/sda2 bs=1 skip=1024 count=256 2>/dev/null | xxd | head -20
00000000: c027 0600 004a 1800 0050 0100 8732 1700 .'...J...P...2..
00000010: 4820 0600 0000 0000 0200 0000 0200 0000 H ..............
00000020: 0080 0000 0080 0000 2020 0000 ... ................
Bytes at offset 0x38 (magic): 53 EF → little-endian → 0xEF53 ✓
Bytes at offset 0x18 (log_block_size): 02 00 00 00 → value 2
block_size = 2^(10+2) = 2^12 = 4096 bytes ✓
Bytes at offset 0x20 (blocks_per_group): 00 80 00 00 → 0x8000 = 32768
group_size = 32768 * 4096 = 134217728 = 128 MiB ✓
Block Groups: The Disk Divided Into 128 MiB Chunks
The entire disk is split into groups. Each group manages its own allocation bitmaps and metadata-record table. With 32768 blocks per group at 4096 bytes each:
Group 0: blocks [0 .. 32767] bytes [0 .. 134217727]
Group 1: blocks [32768 .. 65535] bytes [134217728 .. 268435455]
Group 2: blocks [65536 .. 98303] bytes [268435456 .. 402653183]
...
Group N: blocks [N*32768 .. (N+1)*32768 - 1]
Inside each group, the layout is:
[superblock copy?] [group descriptors?] [block bitmap] [metadata-record bitmap] [metadata-record table] [data blocks]
Not every group has a superblock copy — only groups 0, 1, 3, 5, 7, 9, 25, 27, 49, 125, 243, 343, 625, ... (powers of 3, 5, 7 plus groups 0 and 1).
How Many Groups on a 1 TB Disk?
Total bytes: 1,000,000,000,000 (1 TB, marketing)
Total blocks: 1000000000000 / 4096 = 244140625
Blocks/group: 32768
Group count: 244140625 / 32768 = 7450.58... → 7451 groups
The group descriptor table has one 64-byte record per group. For 7451 groups: 7451 * 64 = 476864 bytes = 116.4 blocks. This table lives right after the superblock in group 0, and is replicated in backup groups.
Grill: Given s_log_block_size = 0 and s_blocks_per_group = 8192, what is the block size in bytes? What is the group size in bytes? How many groups fit on a 10 GiB partition?