4

In every publication I found about ext2, the structure of a block group is defined as following:

  • Super Block: 1 block
  • Group Descriptor: N blocks
  • Data Bitmap: 1 block
  • Inode Bitmap: 1 block
  • Inode Table: N blocks
  • Data Blocks: remaining blocks

However in the ext2 kernel doc it is stated that versions >0 may not store copies of the super block and group descriptors in every block group.

When I fsstat my ext2 partition, I get following output:

Group: 1:
  Inode Range: 1977 - 3952
  Block Range: 8193 - 16384
  Layout:
    Super Block: 8193 - 8193
    Group Descriptor Table: 8194 - 8194
    Data bitmap: 8451 - 8451
    Inode bitmap: 8452 - 8452
    Inode Table: 8453 - 8699
    Data Blocks: 8700 - 16384
  Free Inodes: 1976 (100%)
  Free Blocks: 0 (0%)
  Total Directories: 0

Group: 2:
  Inode Range: 3953 - 5928
  Block Range: 16385 - 24576
  Layout:
    Data bitmap: 16385 - 16385
    Inode bitmap: 16386 - 16386
    Inode Table: 16387 - 16633
    Data Blocks: 16387 - 16386, 16634 - 24576
  Free Inodes: 1976 (100%)
  Free Blocks: 0 (0%)

There are two things about this output that confuse me:

  1. In groups where the SB and group desc. are stored, there is a gap of 256 blocks between the group desc. and data bitmap. EDIT: Using dumpe2fs I just found out that these are reserved GDT blocks, used for online resizing. So the new question is, how is the size of these reserved GDT blocks determined?

  2. What does Data Blocks: 16387 - 16386 in Group 2 mean?

2
  • It looks like this program is simply buggy. How large of a filesystem is this?
    – psusi
    Commented Apr 2, 2014 at 15:13
  • 1
    It's a 100 MB file mounted as ext2 partition
    – goose999
    Commented Apr 2, 2014 at 16:33

1 Answer 1

3

The resize_inode feature creates a hidden inode (number 7, you can view it in debugfs with stat <7>) to reserve those blocks so that the GDT can be grown. By default it reserves enough space to grow the filesystem to 1024 times its original size. You can disable the feature or adjust the size using options to mke2fs at format time.

What does Data Blocks: 16387 - 16386 in Group 2 mean?

This looks to simply be a bug in the program, as you can't have a negative-sized (ends before it starts) range.

10
  • 1
    OK, but why is the size 256 then?
    – goose999
    Commented Apr 2, 2014 at 16:34
  • @goose999, because that is 1024 times the size of the group descriptor table.
    – psusi
    Commented Apr 2, 2014 at 18:17
  • gdt_blocks = (sizeof(struct ext2_group_desc) * number_of_groups) / block_size for 100MB partition, 1kb blocksize gdt_blocks = (32 * 12.5) / 1024 = 0.39 ~ 1 block so the formula for reserved GDT blocks should be res_gdt_blocks = 32 * 12.5 = 400. What is wrong in my calculation?
    – goose999
    Commented Apr 2, 2014 at 20:13
  • 3
    @goose999, I checked the source and it seems that the number of reserved blocks is capped at how many will fit in a single indirect block, which for 1k block size is 256. I guess they didn't want to be bothered with having to allocate more than a single indirect block.
    – psusi
    Commented Apr 3, 2014 at 14:24
  • 1
    To limit the number of reserved GDT blocks, specify mke2fs -E resize=... with the smallest value it allows.
    – pts
    Commented Dec 17, 2018 at 21:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .