0

during testing the Linux ext4 filesystem I notice that it assigned a regular data file an inode and multiple data blocks. But the inode is located in block group 0 and the data blocks in block group

The data file was created by following command:

sudo dd if=/dev/zero of=output_file bs=1M count=10

The ext4 filesystem has a 4k block size and a 256B inode size.

The change on the block group as follows:

Group 0: (Blocks 0-32767) [ITABLE_ZEROED]
...
  24285 free blocks, 8182 free inodes, 1 directories, 8177 unused inodes
  Free blocks: 8482-8485, 8487-32767
  Free inodes: 11-8192
Group 1: (Blocks 32768-65535) [INODE_UNINIT, ITABLE_ZEROED]
...
  32511 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes
  Free blocks: 33025-65535
  Free inodes: 8193-16384

After creating the data file change on block groups as follows:

Group 0: (Blocks 0-32767) [ITABLE_ZEROED]
...
  24285 free blocks, 8181 free inodes, 1 directories, 8177 unused inodes
  Free blocks: 8482-8485, 8487-32767
  Free inodes: 12-8192
Group 1: (Blocks 32768-65535) [INODE_UNINIT, ITABLE_ZEROED]
...
  29951 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes
  Free blocks: 33025-34815, 37376-65535
  Free inodes: 8193-16384

1 Answer 1

0

You did not actually specify a question; I assume you want to ask something like "Is this normal?"

With a bit of thinking, you should quickly see that the assignment of data blocks must be independent of the location of the inode.

First, consider a freshly-created filesystem with just a few large files placed in it. Even the first large file could consume all free blocks of the first block group, so there must be a way for a file to span multiple block groups.

Second, if inodes would have to be placed on the same block group that the file (or maybe the file's first block) is in, that would mean that any file larger than 2 block groups would effectively consume all the inodes in at least one block group, possibly two if things align perfectly. This would seem nonsensically inefficient.

So, even without further information about the internal workings of the ext4 filesystem, I would suggest that yes, this is normal.

1
  • Good answer and clear logic!
    – joe
    Jul 1, 2023 at 21:15

You must log in to answer this question.

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