0

I have a question about ext2 of file system. I need to know really well about this. And I think I sort of understand everything on it. But there is a thing bothering me. As you can see from the first picture, this file system makes the volume be divided to some "block group". Each of which has a Inode Table Section mutually. what I want to know is if it is same between the Inode Table of Block Group 0 and that of Block Group 1(2, 3 .. whatever except 0). Are they same or not? If they are same, how to find which Inode_table corresponds to a i_node. If they are not, in this case it kind of seems like there are over 1 number of same i_node. If you know the answer exactly, let me know the basis of your thoughts like websites or books that you can prove you're right.

enter image description here enter image description here

1

If you are asking if the inode table is always at the same offset relative to the beginning of a block group, this would mean everything before it must be of fixed size. The block and inode bitmaps are always one block. The block group descriptor table is not fixed. This is what the documentation says:

Depending on how many block groups are defined, this table can require multiple blocks of storage. Always refer to the superblock in case of doubt.

Assuming you want to find the inode table for a given inode you need to know which blockgroup an inode belongs to. If you know the blockgroup number, the block size (s_log_block_size) and the amount of blocks per blockgroup (s_blocks_per_group), you can find the start of a blockgroup, where the block group descriptor table sits. It contains the block id of the first block of the inode table of this block group (bg_inode_table).

Ext filesystem internal layout documentation: http://www.nongnu.org/ext2-doc/ext2.html

  • 1
    thank you for your answer. Actually I know how to find the inode-table of a block group when I have inode number from this formula, block group = (inode – 1) / INODES_PER_GROUP . For me, it seems like each inode table of each block group is in charge of some range of number of inode number. For example , inode table of first block group is in charge of 1~ 100 and that of second block group is in charge of 101~200 because that formula above calculates which block group a inode number belongs to by the operator '/' . – user187324 Aug 31 '16 at 5:55
0

(after posting, I then realize I'm a couple years late, anyways I'll leave this answer here) If I understand your question right, there's confusion over what's in the group descriptor tables vs what the bitmaps refer too.

Each block group contains a superblock, a set of group descriptors, block and inode bitmaps and an inode table. The set of group descriptors is for all the block groups (the super block and group descriptors are backup copies), but the bitmaps and inode table are just for that block group.

So, for example, if you're interested in the 4th block group, you'd read in the 4th entry from a group descriptor table (either the main one towards the beginning of the disk or a backup copy), and from it, you can read the block number for where the block and inode bitmaps are located.

One note: What I wrote above isn't quite correct as the sparse option is normally set by default and not all block groups have a super block (to save space). It's easy enough to read in a block as of it were a superblock, test the superblock's s_magic field to see if it's equal to EXT2_SUPER_MAGIC, it if's not correct, then that block group starts with the bitmaps instead.

The link Hoov posted is a good one and here's another helpful link too http://cs.smith.edu/~nhowe/Teaching/csc262/oldlabs/ext2.html There's a couple confusing aspects to it, but used in conjunction with Hoov's link should get you up and running. https://wiki.osdev.org/Ext2 is also good.

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.