Each physical disk is partitioned into several filesystems. Partitioning a disk into several file systems makes it easier for administrators to manage data.
The kernel deals on logical level with filesystems rather than with physical disks, treating each disk as a logical device identified by logical device number. The conversion between logical device(file system) addresses and physical device(disk) addresses is done by disk driver.
A filesystem has following structure
1) Boot Block :
This occupies the beginning of a file system, typically the first sector, and may contain bootstrap code, which is used for booting(initializing the operating system). Although only one boot block is needed to boot the system, every filesystem has a (possibly empty) boot block.
2) Super Block:
It describes the state of file system, like, how large it is, how many files it can store, where to find free space on the file system, etc.
3) Inode list:
It is a list of inodes in the file system. The kernel references the inodes by index into the inode list. One inode is the root inode of the filesystem: it is the inode by which the directory structure of the file system is accessible after execution of mount system call.
4) Data Block:
The inode list is followed by data blocks. The data block contains the actual file data and administrative data. An allocated data block can belong to one and only one file in the file system.
Layout of ext2/ext3 filesystem
The ext2/ext3 file system organizes formatted disk partition into a series of block groups that have identical structure. The block groups help in reducing file fragmentation. When the kernel allocates data blocks for a file, it will try to allocate blocks from same block group. Also, each block group contains its own inode table - the reason is that keeping an inode table close to the data blocks will reduce seek time.
What each block group contains?
superblock - block group 0 contains the primary superblock, the other groups contain backup superblocks.
group descriptors - information about other structures in the block group.
data block bitmap - set/unset bits for each block in-use/free. The overall size of block group is controlled by this - Eg: With a 4 kb(4096 bytes) block size, the size of a block group is limted to 4096*8 blocks.
inode bitmap - set/unset bits for each inode in-use/free.
inode table - Space for the inodes themselves. Each inode is 128 bytes in sizes, therefore 8 inodes/kb (1024/128) of disk.
What does each block in block group contain?
Each block in a block group contains one of the following pieces of information:
- A copy of the filesystem's superblock
- A copy of the group of block group descriptors
- A data block bitmap
- An inode bitmap
- A table of inodes
- A chunk of data that belongs to a file
If a block does not contain any meaningful information, it is said to be free.
No comments:
Post a Comment