File System Lab
ext2 file system layout The layout of the system:
Super block: The superblock contains all the pertinent global information for the entire drive. Information such as: the total number of blocks on disk, the size of the blocks, the number of free blocks, and so forth.
GDT: group descriptor table The blocks immediately after the superblock contain a list of group descriptors (essentially an array of group descriptors). This list contains a descriptor for each block group.
Block bitmap and Inode bitmap: ext2 keeps track of free space using bitmaps. The blocks bitmap tracks free blocks (raw space), and the inode bitmap tracks free inodes. These bitmaps are fixed size and are exactly 1 block large. With a block size of 1024, the block bitmap contains = 8192 bits, which means that the block group can have no more than 8K blocks.
Inode table: An inode is 128byte file attributes and data blocking information
Data block: Regular files: Data Directory: name of files and subdirectory Symbolic link: name in either inode or a data block
$ dd if=/dev/zero of=fs count=256 bs=4K if input file of output file mke2fs fs To make a file system out of the fs file Block size; inodes sudo mount –o loop fs /mnt
dumpe2fs fs Inode count 128 Block count 1024 Free blocks: 986 Free inodes:117 First inode:11 Inode size: 128 Primary superblock: 1 Group descriptor: 2 Block bitmap:6 Inode bitmap: 7 Inode table: 8-23
sudo mount –o loop fs /mnt od -tx1 –Ad fs
Super block od -tx1 –Ad fs –N1024
Group descriptor od –tx1 –Ad fs –N1024 –j2048 Group 0: (Blocks ) Primary superblock at 1, Group descriptors at 2-2 Reserved GDT blocks at 3-5 Block bitmap at 6 (+5), Inode bitmap at 7 (+6) Inode table at 8-23 (+7) 986 free blocks, 117 free inodes, 2 directories Free blocks: Free inodes:
Block bitmap od -tx1 -Ad fs -N1024 -j ff ff ff ff 1f * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff *
Inode bitmap od -tx1 -Ad fs -N1024 -j ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff *
Inode table od -tx1 -Ad fs –N2048 –j a 2b a 2b a 2b * ed 41 e c9 4b 2b a 2b a 2b e * a 2b a 2b a 2b * * ed a 2b 50 2a 4c 2b a 2b a b c d e
Data block Block 24: od -tx1 -Ad fs -N1024 -j c e c e 2e b e8 03 0a c 6f b 66 6f 75 6e
Data block Block 24: After mkdir a in /mnt c e c e 2e b a c 6f b 66 6f 75 6e c d
Data block Block 24 After touch a.txt c e c e 2e b a c 6f b 66 6f 75 6e c c d c e *
Inode table od -tx1 -Ad fs -N2048 -j ed d3 51 2b 50 e5 51 2b e5 51 2b a b c d e * fd 41 e e9 51 2b 50 e9 51 2b e9 51 2b e * ef 0c 2d b4 81 e b b b e