Interaction between file system and secondary storage
1. How the file system interacts with secondary storage to organize and
retrieve data:
Organization of Data
o File Structure: The file system provides a hierarchical structure to
organize data in the form of files and directories (or folders). This
structure simplifies data management and access for users and
applications.
o Metadata Management: Each file and directory is associated with
metadata, such as the name, size, creation date, modification date,
permissions and file type, stored in a file allocation table (FAT), inode, or
similar data structure.
Data Storage
o Block Management: Secondary storage is divided into fixed-size blocks
or sectors. The file system determines how these blocks are allocated to
store the data of a file. Contiguous, linked, or indexed allocation methods
are often used.
o Fragmentation Management: Over time, files may become fragmented
as they grow or shrink. The file system ensures that data is stored
efficiently, sometimes employing defragmentation tools.
Retrieval of Data
o Path Resolution: The file system translates file paths into actual locations
on the secondary storage. For example, resolving
/home/user/document.txt into specific storage blocks.
o Index Lookup: Metadata structures like FAT, Master File Table (MFT), or
inodes are consulted to locate where file data resides on the storage
medium.
o Caching: Frequently accessed data may be cached in memory to speed up
retrieval.
2. File allocation methods like FAT, indexing and journaling and Data
management between the storage device and the OS
FAT (File Allocation Table)
FAT is a simple allocation method used in older file systems like FAT16, FAT32.
The storage device is divided into clusters (ground of sectors). A table (the File
Allocation Table) keeps track of which clusters are used by files and which are
free. Hence each entry in FAT corresponds to a cluster. If a file is larger than one
cluster, the FAT links these clusters together in a chain, pointing the next cluster
that contains part of the file.
Indexing (Indexed Allocation)
Instead of chaining clusters like FAT, indexed allocation uses an index block (a
special file) that contains pointers to the data blocks where the file’s content is
stored. A file’s index block stores the addresses of all the blocks used by the file,
whether they are contiguous or scattered throughout the disk.
Journaling (Journal File Systems)
Journaling is not an allocation method per se but rather a technique used in
modern file systems (like ext4, NFTS, or HFS+) to ensure data integrity. Instead
of immediately applying changes to storage device, a journal (or log) records
changes in a separate area. Once the changes are written to the journal, they are
then applied to the actual file system. This approach helps recover the file system
to a consistent state in case of power failures or crashes.
Data management between OS and Storage Device
o File Creation/Modification: The OS allocates storage for a file based on
file system’s method (FAT, indexing, etc.). Data is written to the allocated
storage blocks.
o Accessing Data: The OS uses file system to find where a file is located on
the storage device, based on the allocation method. The file system
translates the file’s logical structure (directories, paths) into physical
storage locations (blocks, clusters).
o File Deletion: When a file is deleted, the OS marks the block as free in the
allocation method (removes entries from the FAT or the index block).
o Error Handling & Recovery: Journaling ensures that if there’s an issue
(e.g., power failure), the OS can recover files and the file system to a
consistent state by replaying the journal but for indexed allocation and
FAT they don’t have such feature hence they can lose data if they
experience a crash.
3. Real Life examples to show efficiency and challenges of the systems &
how NFTS handles large files & maintains security
Real-Life Example (FAT): USB Flash Drives & SD Cards
FAT is widely used on USB flash drives and SD cards because of its simplicity
and broad compatibility across various OS hence making it efficient.
These devices tend to be used for smaller, simple tasks (e.g., transferring
documents, photos), so FAT’s simple structure is sufficient for handling such files.
On the downside as files get larger or are frequently modified, FAT becomes
inefficient. Fragmentation then occurs because files are stored in non-contiguous
blocks, leading to slower read/write operations over time.
Real-Life Example (Indexed Allocation): Linux ext4 File System
The ext4 file system, which uses indexed allocation, is highly efficient at
managing large files and reducing fragmentation making it efficient.
Ext4 can handle large files efficiently because the file’s index block can hold
pointers to a large number of blocks, allowing files to grow without significant
fragmentation. When a file is large and scattered, the file system can handle these
scattered blocks more efficiently than systems like FAT.
Its downside is Index Block Overhead as index allocation is the need
for an index block which itself takes up space. For every small file,
the overhead of maintaining the index can be inefficient.
Real-Life Example (Journaling File Systems): NFTS on Windows
OS
NFTS is the default file system on Windows computers and is known for
handling large files, ensuring security and maintaining data integrity. It supports
large file sizes (up to 16 exabytes) and efficient access to large databases or media
files.
NFTS uses both indexed allocation and journaling, which gives it both high
performance and resilience. The file system can handle a large number of small
files and large files effectively, ensuring that data access is quick and reliable.
A real-life use case can be for example, Professionals dealing with large
multimedia projects, like video editors or engineers, often use NFTS-formatted
drives to manage huge files (e.g., 4K video files, CAD drawings). NFTS allows
them to access and modify these files without fragmentation or performance
degradation.
A challenge that can be faced in NFTS Overheading. While NFTS offer great
benefits in terms of security and large file handling, the journaling feature adds
some overhead. Writing changes to the journal before committing them to disk
can slow down write-heavy operations.
REFERENCES
https://docs.oracle.com/cd/E18752_01/html/817-5093/fsoverview-
51.html#:~:text=A%20file%20system%20is%20a,with%20the
%20root%20(%2F)%20directory
https://www.techtarget.com/searchstorage/definition/file-system