Question

I am reading about EXT2 file system, and have a lot of questions.

Primarily relying on the following resources:
http://e2fsprogs.sourceforge.net/ext2intro.html
http://www.virtualblueness.net/Ext2fs-overview/Ext2fs-overview-0.1.html#toc7
http://www.nongnu.org/ext2-doc/ext2.html
http://www.tldp.org/LDP/tlk/fs/filesystem.html

  1. Block groups have the following structures: |Super Block(backup)|Group Descriptors(backups)|Block Bitmap|Inode Bitmap|Inode Table|Data Blocks| (As described in the first link) Does it mean that inodes can't claim more that data than what is available in Data Block ?
  2. Do Super Block(backup) and Group Descriptors(backups) get updated during operations on the Block Group ? http://www.virtualblueness.net/Ext2fs-overview/Ext2fs-overview-0.1-7.html notes that

Each blocks group contains the entire table of group descriptors in its second block, right after the superblock.(???)However, only the first copy (in group 0) is actually used by the kernel. The other copies are there for backup purposes and can be of use if the main copy gets corrupted.

If you have looked at the source of Group Descriptor it has no entire table of group descriptors as the first sentence is trying to imply.(Maybe I missed it) ??

Entire backup system does not make any sense. Proper backup has to keep in sink all the copies, I don't see how this happens.
3. What would be the purpose of Inode Table ?
4. How Directories create sub-directories ? Each entry in directory table points to entry in Inode Table.

Thanks ! (I might have other questions.)

Was it helpful?

Solution

There are two types of block groups: the backup type, and the normal type:

The backup type: contains superblock and block group descriptor table PLUS everything in the normal type (below).

The normal type: Block bitmap, Inode Bitmap, Inode table, and Data blocks.

The backup block groups are groups 0 and 1, and all groups that are powers of 3, 5, and 7.

Each block group descriptor table contains several block group descriptors. There is one block group descriptor per block group. So, if there are 450 block groups, then there will be 450 block group descriptors, right next to each other in ONE block group descriptor TABLE.

The purpose of the the inode table is to create several free inodes that can be used later by the file system. You CAN NOT create new inodes after the ext2/3 file system has been created. It is a FIXED number set when creating the file system.

This is how a directory is created: A free inode is picked, and chosen to hold the directory information. Next, a free data block is picked to hold directory entries information. Even an empty directory contains two directory entries in the data block; a directory entry for its own directory, and one for its parent directory. So, for a new directory, an inode will be picked, and a data block will be picked to hold the first two directory entries. As the new files or directories are created, more directory entries will be added to its data block.

OTHER TIPS

Unix compliant filesystems need to have inodes, which is the central thing in such filesystems.

Recall that Unix filesystems may have hard links added by the link(2) syscall. Some files can have several names and all these names are equivalents. And a file still exist on the disk when it open(2)-ed by some process, even if alll the names of that file have been later unlink(2)-ed. In particular, this is the way to make a temporary file.

So in fact, the inode is the real file (in the filesystem), and directory entries contain names for them (associated to the inode number on the disk).

Actually, Ext2 is obsolete and has evolved to Ext4. Read both these wikipedia pages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top