Goes into details about the prior knowledge required to design a file system. Concludes with a demo that explains how these concepts are used by Second Extended File System (ext2fs) A demo is also provided.
Presented at Florence, Italy on 6th December 2017
3. Who are you?
● Curious about File Systems
● Interested in low level systems
● Building an OS from scratch is hard!
● Not sure how to approach such a task
● C/C++ is not your forte
4. Who are you?
What we really want
● Feasible
● Practical
● Yet involves complexity of low level system design
23. Investigating the Hard Disk
Conclusion:
1. Linux/Unix-like OSes view all hard disks as files.
2. A Hard Disk can be opened with standard “Open
File” commands!
3. A Hard Disk contains a stream of bytes.
26. File System Constructs
Block
The smallest unit of bytes available to the OS & FS.
It is a multiple of disk’s block size.
Block Size = n * 512 Bytes
Block Group
Boot Block
Contiguous set of blocks that form a logical group.
A Block Group consists of FS metadata & file data.
Used by the computer to bootstrap kernel loading process.
(Irrelevant for our purposes)
28. File System Constructs: Block Group
Superblock Consists of all the metadata required by
the OS to load the File System
Inode
Consists of all the metadata required by File System
to load a File or a Directory.
Metadata Bitmap
Provides a minimap for the state of Blocks or other things.
29. File System Constructs: Block Group
Boot Block Block Group 0 Block Group N
Superblock
Inode
map
Inodes Bitmap
Data Bitmap
Data Blocks
Inodes
37. Root Directory
● Where is the Root Directory?
● How does the OS know about it.
● How is it represented?
38. Root Directory
Inode
Consists of all the metadata required by File System
to load a File or a Directory.
Inode
map
Look Up table to quickly reach Inodes
based on their Inode#
Root Directory is at a predefined position
on the File System.
39. Root Directory
● Root Directory is at a predefined position on the
File System.
● It can be looked up in the Inode map.
● An Inode can be interpreted differently based on
whether it is a Directory or a File.
52. File System Constructs
Block
The smallest unit of bytes available to the OS & FS.
It is a multiple of disk’s block size.
Block Size = n * 512 Bytes
Block Group
Boot Block
Contiguous set of blocks that form a logical group.
A Block Group consists of FS metadata & file data.
Used by the computer to bootstrap kernel loading process.
(Irrelevant for our purposes)
53. File System Constructs: Block Group
Superblock Consists of all the metadata required by
the OS to load the File System
Inode
Consists of all the metadata required by File System
to load a File or a Directory.
Metadata Bitmap
Provides a minimap for the state of Blocks or other things.
54. ext2 File System: Layout
Boot Block Block Group 0 Block Group N
Superblock
Inode
map
Inodes Bitmap
Data Bitmap
Data Blocks
Inodes
$FS
Group Descriptor
55. ext2 File System: Layout
● Magic Signature: 0xEF53
● Root Folder Inode# 1
● Number of Inodes: Size in Bytes ➗ Block Size
59. Operating System & FS Operations
OS
(in-memory)
ext4
Open
Close
Dentries
Inode
... btrfs
Virtual File System - Used in Kernel Space
FUSE - Used in User Space
60. Summary
● File System is just a program.
● It is well structured and there is no magic.
● Easy to implement a practical low level System.
61. References
Understanding the Linux Kernel, Third Edition 3rd Edition
Practical File System Design
Demo Project - https://github.com/last-ent/ext2-explorer