File System
A file system is the method and data structure used by an operating system to organize, store, name, access, and manage files and directories on a storage device.
In simple words:
A file system tells the OS how data is stored on a disk and how files and folders can be found and managed.
Examples:
- Windows → NTFS, exFAT, FAT32
- Linux → ext4, XFS, Btrfs
- macOS → APFS
- Optical media → ISO 9660
1. Why Do We Need a File System?
Consider a 1 TB SSD.
The SSD contains millions or billions of bytes:
SSD ──────────────────────────── 010101010101010101010101... ────────────────────────────
Without a file system, the OS would have no convenient way to know:
Which data belongs to which file? Where does a file start? Where does it end? Which space is free? What is the file name? Who owns the file? What permissions does it have?
A file system provides this organization.
File System │ ┌─────────────────┼─────────────────┐ ↓ ↓ ↓ Files Directories Metadata │ │ │ ↓ ↓ ↓ file.txt Documents size, owner, photo.jpg Downloads permissions
2. File System vs Storage Device
These are different things.
Storage device
The physical hardware:
HDD SSD USB Drive SD Card
File system
The logical structure used to organize data on that device.
For example:
SSD │ └── NTFS ├── Users ├── Program Files └── Windows
So:
SSD/HDD = where data is physically stored
File system = how the OS organizes that data
3. Basic File System Structure
A simplified file system can be represented as:
Storage Device │ ├── File System Metadata │ ├── Directory Structure │ ├── File Metadata │ ├── File Data │ └── Free Space
More conceptually:
File System │ ┌──────────────┼──────────────┐ ↓ ↓ ↓ Directories Metadata File Data │ │ │ ↓ ↓ ↓ names size/owner actual content paths permissions
4. What Is a File?
A file is a named collection of data stored by the operating system.
Examples:
notes.txt photo.jpg program.exe video.mp4 database.db report.pdf
A file normally has:
- Name
- Type
- Size
- Location
- Owner
- Permissions
- Creation/modification information
- File data
5. What Is a Directory?
A directory is a structure used to organize and locate files and other directories.
Example:
Home │ ├── Documents │ ├── notes.txt │ └── report.pdf │ ├── Pictures │ ├── photo1.jpg │ └── photo2.jpg │ └── Videos └── video.mp4
Directories create a hierarchical structure.
6. File System Hierarchy
Most modern operating systems organize files in a tree-like structure.
Example:
/ ├── home │ └── uday │ ├── Documents │ ├── Downloads │ └── Pictures │ ├── etc ├── var ├── usr └── tmp
The top-level directory is often called the root directory in Unix/Linux systems.
7. File Path
A path tells the OS where a file is located.
Linux
/home/uday/Documents/notes.txt
Windows
C:\Users\Uday\Documents\notes.txt
A path can be:
Absolute path
Starts from the root or drive.
Linux:
/home/uday/file.txt
Windows:
C:\Users\Uday\file.txt
Relative path
Starts from the current directory.
Documents/file.txt
8. File System Components
A file system generally maintains several important structures.
1. Boot Block / Boot Sector
Contains information needed for booting or filesystem-specific boot information.
Not every filesystem uses it in exactly the same way.
2. Superblock / File System Metadata
In filesystems such as ext4, the superblock contains important filesystem information.
It can include information such as:
- File system type
- Size
- Block size
- Number of blocks
- Number of free blocks
- Number of inodes
- Filesystem state
Conceptually:
Superblock │ ├── File system size ├── Block size ├── Free blocks ├── Inode information └── Filesystem state
3. File Metadata
Metadata describes a file rather than being the actual contents.
Example:
notes.txt Size: 20 KB Owner: uday Permission: rw-r--r-- Modified: 5 Oct 2026
4. File Data
This is the actual content.
For:
hello.txt
the data could be:
Hello World!
5. Free-Space Information
The filesystem needs to know which storage blocks are available.
For example:
Block 1 → Used Block 2 → Used Block 3 → Free Block 4 → Used Block 5 → Free
The OS can then use free blocks when creating new files.
9. Blocks
Storage is generally managed in units called blocks by the filesystem.
Suppose:
Block size = 4 KB
A file of:
10 KB
might require:
Block 1 → 4 KB Block 2 → 4 KB Block 3 → 2 KB
So:
File ↓ Multiple blocks ↓ Storage
The blocks don't necessarily have to be physically adjacent.
10. Fragmentation
A file can become divided into multiple areas on storage.
Example:
File A: Block 1 → Block 8 → Block 20 → Block 25
This is related to fragmentation.
External fragmentation
Free space exists but is scattered into separate regions.
File fragmentation
Parts of the same file are spread across different locations.
Traditional HDDs can be significantly affected by file fragmentation because moving the disk head between locations takes time.
SSDs have different physical characteristics, so fragmentation behaves differently from HDDs.
11. File Allocation
The filesystem needs a way to determine which blocks belong to each file.
Common approaches include:
Contiguous allocation
File A: [10][11][12][13][14]
Advantages:
- Fast sequential access
- Simple
Disadvantages:
- External fragmentation
- Difficult for files to grow
Linked allocation
Blocks can be scattered:
[10] → [25] → [7] → [31]
Each block points toward the next block.
Advantages:
- Easy file growth
- No need for contiguous blocks
Disadvantages:
- Random access is slower
- Pointer overhead
Indexed allocation
An index structure contains the addresses of the file's blocks.
Index │ ├── Block 10 ├── Block 25 ├── Block 7 └── Block 31
This allows the filesystem to find file blocks through the index.
12. Inodes
In Unix/Linux filesystems such as ext4, an inode is a data structure containing important metadata about a file and information needed to locate its data.
An inode can contain information such as:
inode │ ├── File type ├── Permissions ├── Owner ├── Group ├── Size ├── Timestamps ├── Link count └── Data block references
Important:
The inode normally does not store the filename itself.
The directory maps a filename to an inode.
Conceptually:
Directory "notes.txt" ─────→ inode 1234 │ ↓ file metadata │ ↓ file data blocks
13. Filename vs Inode
This is a very important Linux filesystem concept.
Suppose:
notes.txt
The directory contains something conceptually like:
notes.txt → inode 1234
The inode contains:
inode 1234 │ ├── permissions ├── owner ├── size ├── timestamps └── data locations
So:
Directory → filename → inode → file data
14. File Descriptor
When a program opens a file, the OS can provide the process with a file descriptor.
Example in Linux:
fd = open("notes.txt", ...)
The process may receive:
fd = 3
Then:
read(3, ...) write(3, ...) close(3)
Common standard file descriptors:
0 → stdin 1 → stdout 2 → stderr
File descriptors are especially important in Unix/Linux.
15. File Operations
A filesystem supports operations such as:
Create
create()
Open
open()
Read
read()
Write
write()
Seek
Move to a particular position in a file.
Close
close()
Delete
unlink()
Rename
rename()
Conceptual flow:
Application ↓ System Call ↓ File System ↓ Storage Driver ↓ Disk / SSD
16. File Access Methods
There are several ways to access file data.
Sequential Access
Data is accessed in order.
1 → 2 → 3 → 4 → 5
Example:
Reading a video/audio stream
Direct / Random Access
Jump directly to a location.
1 → 5 → 20 → 100
Useful for:
- Databases
- Large files
- Random record access
Indexed Access
An index helps locate the required data.
Index ↓ Required block ↓ Data
17. File Attributes
A filesystem stores information about files.
Typical attributes include:
| Attribute | Meaning |
|---|---|
| Name | File name |
| Type | File type |
| Size | Number of bytes |
| Owner | File owner |
| Permissions | Allowed operations |
| Timestamps | Creation/modification/access information |
| Location | Where file data is stored |
| Links | Number/type of references |
18. File Permissions
Operating systems need to control who can access files.
Linux commonly uses:
r = read w = write x = execute
Example:
-rwxr-xr--
Conceptually:
Owner → rwx Group → r-x Others → r--
Meaning:
Owner: read + write + execute Group: read + execute Others: read
Permissions are a major part of filesystem security.
19. Mounting
In Unix/Linux, a filesystem can be mounted at a directory.
Example:
/dev/sdb1 ↓ mount ↓ /mnt/data
After mounting:
/mnt/data
provides access to that filesystem.
Conceptually:
Storage device ↓ Filesystem ↓ Mount point ↓ Directory tree
Linux example:
mount /dev/sdb1 /mnt/data
Unmount:
umount /mnt/data
20. Windows Drive Letters
Windows commonly represents volumes using drive letters:
C: D: E:
Example:
C:\Users\Uday\Documents
Linux generally uses a unified directory tree:
/ ├── home ├── etc ├── var └── mnt
A filesystem can be mounted somewhere within that tree.
21. Journaling
Modern filesystems may use journaling.
The idea is to record filesystem changes in a journal before or around applying them to the main filesystem structures.
Why?
Suppose:
File operation starts ↓ Power failure
Without appropriate recovery mechanisms, filesystem metadata can become inconsistent.
With journaling:
Operation ↓ Journal ↓ Filesystem update
After a crash, the filesystem can use the journal to help recover to a consistent state.
Examples of journaling filesystems include:
- NTFS
- ext4
- XFS
22. File System Caching
Operating systems often use RAM to cache filesystem data.
Example:
Application ↓ Filesystem cache ↓ Storage
If frequently accessed data is already cached:
Application ↓ RAM cache ↓ Fast response
This reduces expensive storage operations.
23. Buffering
Buffering temporarily stores data in memory while transferring it.
Example:
Application ↓ Buffer ↓ Disk
This can help handle differences between application and device speeds.
24. File System Protection
The filesystem works with OS security mechanisms to control:
- Authentication
- Authorization
- File permissions
- Ownership
- Access control
- Encryption
- Auditing
For example:
User ↓ Permission Check ↓ Allowed? / \ Yes No ↓ ↓ Access Denied
25. Common File Systems
FAT32
Older and widely compatible.
Used in:
- USB drives
- Memory cards
- Older systems
Limitation:
Maximum individual file size is approximately 4 GiB.
exFAT
Designed for flash storage and removable devices.
Advantages:
- Supports very large files
- Broad compatibility
- Suitable for USB drives/SD cards
NTFS
Common Windows filesystem.
Features include:
- Permissions
- Journaling
- Large files/volumes
- Security features
- Metadata structures
ext4
A widely used Linux filesystem.
Features:
- Journaling
- Large files
- Extents
- Unix/Linux permissions
- Good general-purpose performance
XFS
A high-performance filesystem commonly used in Linux environments.
Particularly useful for large files and large filesystems.
Btrfs
A modern Linux filesystem supporting features such as:
- Copy-on-write
- Snapshots
- Checksums
- Subvolumes
- Advanced storage management
APFS
Apple's modern filesystem used by current macOS and other Apple platforms.
Features include:
- Copy-on-write metadata
- Encryption support
- Space sharing
- Snapshots
26. File System Comparison
| File System | Common Platform | Important Feature |
|---|---|---|
| FAT32 | Windows/removable | Very compatible |
| exFAT | USB/SD/removable | Large files |
| NTFS | Windows | Security + journaling |
| ext4 | Linux | General-purpose Linux FS |
| XFS | Linux | Large/high-performance workloads |
| Btrfs | Linux | Snapshots + CoW |
| APFS | Apple | Modern Apple storage |
27. File System Architecture
A simplified architecture:
Applications ↓ System Calls ↓ Virtual File System ↓ Specific File System ┌────────────┼────────────┐ ↓ ↓ ↓ ext4 NTFS XFS │ ↓ Block Layer ↓ Device Driver ↓ Storage Device
On Linux, the VFS (Virtual File System) provides a common interface so applications can interact with different filesystems using common operations.
For example:
Application ↓ open() ↓ VFS ↓ ext4 / XFS / Btrfs ↓ Block layer ↓ Driver ↓ SSD/HDD
28. File System vs File Management
These terms are related but not identical.
File System
The complete mechanism for organizing and storing files.
Filesystem ├── files ├── directories ├── metadata ├── allocation ├── free space └── access mechanisms
File Management
The OS activities involved in managing files.
Examples:
Create Open Read Write Rename Delete Protect
29. File System vs Directory Management
File System
Overall storage organization.
Directory Management
Specifically handles:
- Creating directories
- Deleting directories
- Naming
- Paths
- Directory hierarchy
- Searching for files
We'll cover directory management separately in the next related topic.
30. Important File System Concepts
Remember these terms:
File Directory Path Block Metadata Inode Superblock File Descriptor Mount Journaling Free Space Allocation Permissions VFS
31. Complete File System Flow
When you open a file:
User ↓ Application ↓ open("notes.txt") ↓ System Call ↓ VFS / File System ↓ Search directory ↓ Find filename ↓ Find inode / metadata ↓ Find data blocks ↓ Block layer ↓ Device driver ↓ SSD/HDD ↓ Data ↓ Application
This is the overall idea of how the OS connects a human-readable filename to actual storage.
🧠 Exam Revision
Definition
A file system is an operating-system-supported method of organizing, storing, naming, accessing, protecting, and managing files and directories on a storage device.
Main responsibilities
File System │ ├── File organization ├── Directory management ├── Metadata management ├── Block allocation ├── Free-space management ├── File access ├── Permissions ├── Protection ├── Caching └── Recovery / journaling
Important structure
Filename ↓ Directory Entry ↓ Inode / File Metadata ↓ Data Blocks ↓ Storage Device
Memory trick
“File system = Name + Organize + Locate + Store + Protect + Recover.”
And remember:
Storage device is the hardware; filesystem is the organization method used on that storage.