File System in OS: File Concept, Organization, Access Methods & Directories
Whenever you save a photo, create a document, install an application, download a PDF or open a folder, the operating system must know where that data is stored and how to find it again.
The part of an Operating System that manages files, directories, names, locations, permissions and storage organization is called the File System.
A File System is the method used by an operating system to create, store, organize, locate, access, protect and manage files on storage devices.
A file is a named collection of related data.
Files can be accessed using Sequential Access, Direct Access and Indexed Access.
Directories organize files into structures such as Single-Level, Two-Level, Tree-Structured, Acyclic-Graph and General-Graph directories.
Why Do We Need a File System?
A storage device contains a huge number of bytes. Without a file system, those bytes would simply look like a large collection of raw storage blocks.
The operating system needs a proper structure so that users can say:
instead of saying:
Go to storage block 48520, read the next 64 blocks, combine them and show my document.
The file system hides this low-level complexity.
Simple File System View
What Is a File System in Operating System?
A File System is the operating-system mechanism used to organize, store, name, locate, access, protect and manage files and directories on secondary storage.
Common storage devices include:
- Hard Disk Drives
- SSDs
- USB drives
- Memory cards
- Optical media
What Is a File?
The operating system treats the file as one logical unit.
A file may contain:
- Text
- Program code
- Images
- Audio
- Video
- Database records
- Executable instructions
Logical File vs Physical Storage
When a user opens:
The user sees one normal file.
But internally, the operating system may store that file in one or many storage blocks.
Operating System sees → Metadata + Directory Entry + Storage Blocks
File Attributes in Operating System
A file contains data, but the operating system also stores information about the file.
This information is called File Metadata or file attributes.
File Operations in Operating System
The operating system provides several operations that programs can perform on files.
What Happens When a File Is Opened?
- Program requests the file by name or path.
- Operating system searches the directory.
- File permissions are checked.
- File metadata is located.
- Information about the open file is placed in an open-file table.
- The process receives a file descriptor or file handle.
- Future read or write operations use that open-file reference.
Types of Files in Operating System
What Is a File Extension?
A file extension is a suffix added after the file name.
| File | Extension | Common Meaning |
|---|---|---|
| notes.txt | .txt | Text file |
| report.pdf | PDF document | |
| photo.jpg | .jpg | Image |
| program.c | .c | C source file |
| app.exe | .exe | Windows executable |
File Structure
A file can be viewed in different logical forms.
File Access Methods in Operating System
File Access Method means: How does a program reach the required data inside a file?
Sequential Access
Records or bytes are processed one after another in order.
Best idea: Start → Next → Next → NextDirect Access
Program can move directly to a required position or block.
Best idea: Jump directly to needed location.Indexed Access
An index helps locate the required record or block.
Best idea: Search index → find location.1. Sequential Access Method
Sequential access reads or writes data in a fixed order.
To reach Record 5, the program usually processes the earlier records in sequence.
Text processing
Log files
Audio/video streams
Batch processing
2. Direct or Random Access Method
Direct access allows a program to move directly to a particular block, byte offset or record location.
Direct Access → Go directly to Record 5.
Direct access is useful for applications where information must be reached quickly, such as databases and large random-access files.
3. Indexed Access Method
Indexed access maintains an index containing keys or entries that point to the location of data.
Sequential vs Direct vs Indexed Access
| Basis | Sequential | Direct | Indexed |
|---|---|---|---|
| Access Pattern | One after another | Jump directly to location | Use index to locate data |
| Speed for Random Record | Usually slower | Fast | Fast when index is efficient |
| Extra Structure | Minimal | Requires addressable positions | Requires index |
| Example | Log file | Database file block | Indexed database record |
What Is a Directory in Operating System?
A directory helps users arrange data logically.
├── Documents
│ ├── notes.pdf
│ └── assignment.docx
├── Pictures
│ └── photo.jpg
└── Projects
└── OS
└── filesystem.html
Common Directory Operations
- Search for a file
- Create a file
- Delete a file
- List directory contents
- Rename a file
- Create a subdirectory
- Delete a directory
- Traverse the file system
Types of Directory Structures
Single-Level Directory
All files exist inside one directory.
├── a.txt
├── b.txt
├── photo.jpg
└── program.c
File-name conflicts
Poor organization
Difficult for many users
Two-Level Directory
Every user has a separate user directory.
├── User A
│ ├── notes.txt
│ └── photo.jpg
└── User B
├── notes.txt
└── data.csv
Tree-Structured Directory
Tree structure is one of the most common directory models.
It has a root directory at the top. Every directory can contain files and more subdirectories.
Good organization
Easy grouping
Supports hierarchical paths
Easy navigation
Acyclic-Graph Directory
An acyclic-graph directory allows a file or subdirectory to be shared by more than one directory.
However, cycles are not allowed.
The system must carefully manage links and deletion.
General-Graph Directory
General-graph directories allow links that may create cycles.
For example:
Path Names in File System
A path describes where a file or directory is located.
Absolute Path
An absolute path starts from the root of the file system.
Relative Path
A relative path is interpreted from the current working directory.
Current Working Directory
The current working directory is the directory from which relative paths are interpreted.
/home/student
Relative Path:
Documents/report.pdf
Final Location:
/home/student/Documents/report.pdf
Links in File Systems
Some file systems allow multiple names or references to point to the same file.
| Link Type | Main Idea |
|---|---|
| Hard Link | Another directory entry referring to the same underlying file object in supported file systems. |
| Symbolic Link | A separate file-like object that stores a path to another file or directory. |
What Is File Organization?
File organization describes how information is logically arranged and physically placed so that it can be stored and accessed efficiently.
Two important views are:
File Allocation Methods
File allocation tells the operating system how the blocks belonging to a file are placed on storage.
Contiguous Allocation
In contiguous allocation, all blocks of a file are placed in consecutive storage locations.
Block 20 → 21 → 22 → 23
Simple
Fast sequential access
Fast direct access
External fragmentation
Difficulty growing a file when the next blocks are already occupied
Linked Allocation
In linked allocation, file blocks can exist anywhere on the disk. Each block contains a link to the next block.
No need for contiguous free space
Easy file growth
Poor direct access
Pointer overhead
Damage to a pointer can affect the chain
File Allocation Table (FAT) Idea
FAT improves the linked-allocation idea by keeping block-link information in a table.
| Block | Next Block |
|---|---|
| 7 | 31 |
| 31 | 14 |
| 14 | 52 |
| 52 | EOF |
Indexed Allocation
Indexed allocation gives each file an index structure containing addresses of its data blocks.
8
26
41
67
These entries point to file data blocks.
What Is an Inode?
In Unix-like file systems, an inode stores metadata about a file and information needed to locate its data.
File Type
Permissions
Owner
Size
Timestamps
Data Block References
Free-Space Management
The operating system must know which disk blocks are free and which blocks are already in use.
This is called Free-Space Management.
Bitmap Example
Suppose:
In this example, Blocks 2, 4, 5 and 7 are marked free, if indexing begins from Block 0.
What Is File System Mounting?
Mounting means attaching a file system to the operating system's directory structure so that its files become accessible.
In Unix-like systems, a file system may be mounted at a directory such as:
Partition vs File System
| Basis | Partition | File System |
|---|---|---|
| Meaning | Logical division of a storage device | Method used to organize files within storage |
| Purpose | Separate storage regions | Manage files and directories |
| Example | Disk partition | NTFS, ext4, FAT32 |
Examples of File Systems
| File System | Common Association | General Note |
|---|---|---|
| NTFS | Windows | Supports permissions, journaling and large files. |
| FAT32 | USB / compatibility | Simple and widely supported, but has important size limitations. |
| exFAT | Flash storage | Designed for large files and removable media compatibility. |
| ext4 | Linux | Widely used journaling file system. |
| APFS | Apple platforms | Modern Apple file system. |
What Is Journaling in a File System?
Journaling helps a file system recover more reliably from unexpected shutdowns or crashes.
Before certain metadata changes are fully committed, information about the intended changes may be recorded in a journal.
File Protection in Operating System
Not every user should be allowed to perform every operation on every file.
Access Control List (ACL)
An Access Control List stores information about which users or groups are allowed to perform specific operations on a file or directory.
| User | Read | Write | Execute |
|---|---|---|---|
| Owner | Yes | Yes | Yes |
| Student Group | Yes | No | No |
| Others | No | No | No |
File Sharing
Modern operating systems may allow multiple users or processes to access the same file.
The file system must handle:
- Permissions
- Concurrent access
- File locking
- Sharing rules
- Consistency
What Is File Locking?
File locking helps coordinate access when multiple processes want to use the same file.
Process B may need to wait, depending on the locking mechanism.
Locks may apply to the entire file or only a region of a file.
File System Layers in Operating System
File management can be understood as a set of layers.
How File System Layers Work
1. Logical File System
Manages file names, directories, metadata, protection and logical file operations.
2. File-Organization Module
Maps logical file blocks to physical storage blocks and manages allocation.
3. Basic File System
Sends general block read/write requests.
4. I/O Control
Uses device drivers and interrupt handling to communicate with storage hardware.
What Happens When You Read a File?
Simple Path Builder
Use this small example to understand absolute and relative paths.
Common Student Confusions
File vs Directory
A file mainly stores data. A directory organizes names and references to files and subdirectories.
File System vs File
A file is one data object. A file system is the complete method used to manage many files and directories.
Sequential Access vs Sequential Allocation
These are different concepts.
Contiguous Allocation = How file blocks are placed on storage.
Directory vs Folder
In everyday usage, folder is the graphical user-interface term commonly used for a directory.
Absolute Path vs Relative Path
Absolute path begins from a root or drive. Relative path starts from the current working directory.
File Extension vs File Type
An extension is part of the file name. Actual file type may also depend on internal format and operating-system interpretation.
Advantages of a File System
- Easy storage organization
- Meaningful file names
- Directory-based grouping
- Access control and permissions
- Efficient storage allocation
- Free-space tracking
- File sharing
- Data persistence after program termination
- Recovery support in modern journaling file systems
Quick File System Comparison Table
| Concept | Meaning |
|---|---|
| File | Named collection of related information |
| Directory | Structure used to organize files and subdirectories |
| Metadata | Information about a file |
| Sequential Access | Read data in order |
| Direct Access | Jump directly to a required location |
| Indexed Access | Use an index to locate data |
| Contiguous Allocation | File blocks are consecutive |
| Linked Allocation | Each block links to the next |
| Indexed Allocation | Index stores block addresses |
| Mounting | Attach a file system to the directory namespace |
One-Minute File System Revision
File System in OS Exam Preparation
2-Mark File Definition
A file is a named collection of related information stored on secondary storage.
2-Mark File System Definition
A File System is the operating-system mechanism used to organize, store, access and manage files and directories on storage devices.
File Attributes
Name, identifier, type, location, size, protection, owner, timestamps.
File Operations
Create, open, read, write, reposition, close, delete and truncate.
Access Methods
Sequential Access, Direct Access and Indexed Access.
Directory Structures
Single-Level, Two-Level, Tree-Structured, Acyclic-Graph and General-Graph directory.
Allocation Methods
Contiguous Allocation, Linked Allocation and Indexed Allocation.
For a 5-Mark Answer
- Define file and file system.
- Explain file attributes.
- Explain file operations.
- Explain access methods.
- Mention directory structure.
For a 10-Mark Answer
- Define File System.
- Explain need of File System.
- Define file.
- File attributes.
- File operations.
- File types.
- Sequential, Direct and Indexed access.
- Directory definition.
- Directory operations.
- Single-Level Directory.
- Two-Level Directory.
- Tree-Structured Directory.
- Acyclic and General Graph directories.
- Absolute and Relative paths.
- File Allocation Methods.
- Free-Space Management.
- File Protection.
- File-System Layers.
Frequently Asked Questions
What is a File System in Operating System?
A File System is the operating-system mechanism used to organize, store, locate, access, protect and manage files and directories on storage devices.
What is a file in OS?
A file is a named collection of related information stored on secondary storage.
What are file attributes?
File attributes include information such as name, identifier, file type, location, size, owner, permissions and timestamps.
What are the common file operations?
Common file operations include create, open, read, write, reposition, close, delete and truncate.
What are the main file access methods?
The main access methods are Sequential Access, Direct Access and Indexed Access.
What is Sequential Access?
Sequential Access processes data in order from one record or byte sequence to the next.
What is Direct Access?
Direct Access allows a program to move directly to a required record, block or byte position.
What is Indexed Access?
Indexed Access uses an index to locate the required record or data block.
What is a directory?
A directory is a file-system structure used to organize file names and references to files and subdirectories.
What is a Tree-Structured Directory?
A Tree-Structured Directory has a root directory and allows directories to contain files and subdirectories.
What is an absolute path?
An absolute path gives the complete location of a file starting from the root directory or storage drive.
What is a relative path?
A relative path specifies a location starting from the current working directory.
What are the file allocation methods?
The classic file allocation methods are Contiguous Allocation, Linked Allocation and Indexed Allocation.
What is an inode?
An inode is a Unix-like file-system structure that stores file metadata and information used to locate file data blocks.
What is file-system mounting?
Mounting means attaching a file system to a directory location so that its files can be accessed.
What is journaling in a file system?
Journaling records information about file-system changes so the system can recover more reliably after crashes or unexpected shutdowns.
Conclusion
The File System is one of the most important parts of an Operating System.
It converts raw storage blocks into a structure that users can understand as files, folders and paths.
A file is a named collection of related information. File attributes store metadata such as size, location, permissions and timestamps.
The operating system provides operations such as create, open, read, write, close, delete and truncate.
Files can be accessed using Sequential, Direct or Indexed access.
Directories organize files using structures such as Single-Level, Two-Level, Tree, Acyclic-Graph and General-Graph directories.
Internally, files are stored using allocation methods such as Contiguous, Linked and Indexed allocation.
File = Data
Directory = Organization
Metadata = Information About File
Sequential Access = One by One
Direct Access = Jump Directly
Indexed Access = Use Index
Absolute Path = Full Path
Relative Path = From Current Directory
Contiguous Allocation = Consecutive Blocks
Linked Allocation = Block-to-Block Links
Indexed Allocation = Index Stores Block Addresses
