The ext2 File System
Objectives
We would like to :
- Look at an example file system.
Notes
- I am using Kerrisk chapter 14.
- ext2 - the second extended file system
- ext2 was viable from 1993 until 2001
- The design was based on Berkeley Fast File System (ufs),
- It was replaced by ext3 and quickly ext4
- wikipedia claims that it is still the choice for usb, sd cards, ...
- But a fat file system may also be in contention there.
- Disks support physical blocks.
- The smallest unit of storage.
- 512 bytes is the suggested size.
- These are treated as logical blocks at the file system
From Kerrisk.
- The boot block is for the os use
- Kerrisk states that all file systems have one, even if it is unused.
- The superblock
- Holds file system information
- size of the i-node table (in a second)
- Size of a logical block
- Size of the file system in logical blocks.
- And much more
- There are backup superblocks distributed across the disk.
- The i-node table
- The closest thing we have to a list of files.
- i-nodes
- index nodes.
- Each file on the file system has an inode
- This contains
- The file type
- On linux all files are regular files except
- directories
- symbolic links
- character and block special files (hardware interface)
- named pipes
- unix domain sockets.
- The owner (an integer from the /etc/passwd)
- The group (an integer from /etc/group)
- Access permissions (rwx for ugo + s)
- Time stamps
- last access time ls -lu
- last modification time ls -l
- last i-node modification time ls -c
- hard link count
- size in bytes
- the number of blocks, measured in 512 byte blocks.
- Pointers to the data blocks.
- This does not contain the file name!
- The data block pointers
- Blocks 0-11 are direct pointers: they point to a data block
- Block 12 points to a block of pointers.
- Assume each pointer takes 4 bytes (32 bit number)
- A 1K block points to 256 other blocks.
- A 2K block points to 512 other blocks
- And a 4K block points to 1024 other blocks.
- Block 13 is a double indirect pointer
- At 1K, 256 pointers point to 256 blocks for a total of 65K blocks.
- 2K 242K blocks
- 4K 1048K blocks.
- And block 14 is a triple indirect block 1024 pointers to 1024 pointers to 1024 pointers to 4k blocks or 242
-
From Kerrisk.