1

I am trying to find the association between block groups and superblocks in an ext4 filesystem

I was unable to find much of documentation online, except this link that hints that

Because of the importance of the superblock and because damage to it (for example, from physical damage to the magnetic recording medium on the disk) could erase crucial data, backup copies are created automatically at intervals on the filesystem (e.g., at the beginning of each block group)

However, the dumpe2fs command seems to indicate that there are a lot less superblock copies than the number of block groups:

$ sudo dumpe2fs /dev/sda5 | grep -i group | wc -l
dumpe2fs 1.44.1 (24-Mar-2018)
2690


$ sudo dumpe2fs /dev/sda5 | grep -i superblock
dumpe2fs 1.44.1 (24-Mar-2018)
  Primary superblock at 0, Group descriptors at 1-21
  Backup superblock at 32768, Group descriptors at 32769-32789
  Backup superblock at 98304, Group descriptors at 98305-98325
  Backup superblock at 163840, Group descriptors at 163841-163861
  Backup superblock at 229376, Group descriptors at 229377-229397
  Backup superblock at 294912, Group descriptors at 294913-294933
  Backup superblock at 819200, Group descriptors at 819201-819221
  Backup superblock at 884736, Group descriptors at 884737-884757
  Backup superblock at 1605632, Group descriptors at 1605633-1605653
  Backup superblock at 2654208, Group descriptors at 2654209-2654229
  Backup superblock at 4096000, Group descriptors at 4096001-4096021
  Backup superblock at 7962624, Group descriptors at 7962625-7962645
  Backup superblock at 11239424, Group descriptors at 11239425-11239445
  Backup superblock at 20480000, Group descriptors at 20480001-20480021
  Backup superblock at 23887872, Group descriptors at 23887873-23887893
  Backup superblock at 71663616, Group descriptors at 71663617-71663637
  Backup superblock at 78675968, Group descriptors at 78675969-78675989
/home/pkaramol
$ sudo dumpe2fs /dev/sda5 | grep -i superblock | wc -l
dumpe2fs 1.44.1 (24-Mar-2018)
17

How many copies are there actually and how (when) is that number (and superblock location placement) decided?

3

Here's what the official documentation has to say about that:

If the sparse_super feature flag is set, redundant copies of the superblock and group descriptors are kept only in the groups whose group number is either 0 or a power of 3, 5, or 7. If the flag is not set, redundant copies are kept in all groups.

The sparse_super feature (this is one of the filesystem features, you can list them all via tune2fs or dumpe2fs) is documented in the ext2/3/4 manual/info page:

sparse_super
This file system feature is set on all modern ext2, ext3, and ext4 file systems. It indicates that backup copies of the superblock and block group descriptors are present only in a few block groups, not all of them.


The same information is available via the old ext2 official documentation:

The first version of ext2 (revision 0) stores a copy at the start of every block group, along with backups of the group descriptor block(s). Because this can consume a considerable amount of space for large filesystems, later revisions can optionally reduce the number of backup copies by only putting backups in specific groups (this is the sparse superblock feature). The groups chosen are 0, 1 and powers of 3, 5 and 7.... IOW superblock groups are 0, 1, 3, 5, 7, 9, 25, 27, 49, 81, 125, 243, 343 etc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.