ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCC-311File Systems
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    CC-211

    Operating Systems

    Progress0 / 34 done
    Topics34
    1Operating Systems Basics2System Calls3Process Concept and Scheduling4Interprocess Communication5Multithreaded Programming6Multithreading Models7Threading Issues8Process Scheduling Algorithms9Thread Scheduling10Multiple-Processor Scheduling11Synchronization12Critical Section13Synchronization Hardware14Synchronization Problems15Deadlocks16Detecting and Recovering from Deadlocks17Memory Management18Swapping19Contiguous Memory Allocation20Segmentation and Paging21Virtual Memory Management22Demand Paging23Thrashing24Memory-Mapped Files25File Systems26File Concept27Directory and Disk Structure28Directory Implementation29Free Space Management30Disk Structure and Scheduling31Swap Space Management32System Protection33Virtual Machines34Operating System Security
    8 min read
    Topic 25 of 34
    Topic Study Note Illustration
    25

    File Systems

    A file system is a method and data structure that an operating system uses to manage files on a storage device such as a hard disk, SSD,...

    File Systems in Operating Systems

    A file system is a method and data structure that an operating system uses to manage files on a storage device such as a hard disk, SSD, or optical disk. It defines how data is stored, organized, retrieved, and accessed. File systems provide an abstraction layer between the data stored in the storage media and the user applications, offering a way to organize data efficiently and effectively.

    Key Functions of a File System

    1. File Organization:

      • A file system organizes data into files and directories (or folders) in a hierarchical structure. Each file can hold data, and directories allow grouping of files in an organized manner.
    2. File Naming and Metadata:

      • Each file is assigned a name for identification, and additional metadata such as the file size, creation time, permissions, last modified time, and location on the disk are maintained.
    3. Access Control:

      • File systems handle file access permissions, ensuring that only authorized users or processes can read, write, or execute a file. This is typically done through access control lists (ACLs) or other permission mechanisms.
    4. Data Integrity:

      • File systems manage the integrity of data by handling journaling (recording metadata changes before they are applied) or checksums to prevent data corruption.
    5. Storage Allocation:

      • File systems allocate space on a storage device to store files. They manage free space, file fragmentation, and the placement of files on physical storage.
    6. File I/O:

      • File systems are responsible for providing mechanisms to open, read, write, and close files. They also handle buffering and caching to improve I/O performance.

    Types of File Systems

    1. FAT (File Allocation Table):

      • FAT is one of the oldest and simplest file systems, widely used in floppy disks, flash drives, and memory cards. Variants include FAT12, FAT16, and FAT32.
      • Advantages: Simple, widely compatible, minimal overhead.
      • Disadvantages: Poor scalability for large files and directories, limited security features, inefficient disk space management.
    2. NTFS (New Technology File System):

      • Developed by Microsoft for Windows, NTFS is a high-performance, feature-rich file system that supports large files, large volumes, file compression, encryption, disk quotas, and more.
      • Advantages: Supports journaling, file permissions, and security features.
      • Disadvantages: Not as portable across operating systems as FAT.
    3. ext (Extended File System):

      • ext is the default file system for most Linux distributions, with versions such as ext2, ext3, and ext4. ext4 is the most modern version, offering improvements in performance, scalability, and data integrity.
      • Advantages: Journaling support (ext3 and later), reliable, efficient space allocation.
      • Disadvantages: Not as advanced as NTFS in some areas like file compression and encryption.
    4. HFS+ (Mac OS Extended):

      • Used by older versions of macOS, HFS+ (also known as Mac OS Extended) provides features like journaling, hard link support, and efficient handling of large files.
      • Advantages: Optimized for macOS, supports journaling.
      • Disadvantages: Less efficient on non-Apple platforms.
    5. APFS (Apple File System):

      • APFS is the modern file system for macOS, iOS, and other Apple devices. It is designed for flash storage and offers improved performance, encryption, and file system integrity.
      • Advantages: Supports strong encryption, fast performance for SSDs, space sharing.
      • Disadvantages: Only supported on Apple devices.
    6. exFAT (Extended File Allocation Table):

      • exFAT is a lightweight file system developed by Microsoft to be used in portable storage devices such as flash drives, SD cards, and external hard drives.
      • Advantages: Larger file size support than FAT32, cross-platform compatibility.
      • Disadvantages: No built-in file security, lack of journaling.
    7. ZFS (Zettabyte File System):

      • ZFS is a high-performance file system originally developed by Sun Microsystems (now owned by Oracle). It offers features like data integrity verification, automatic repair, snapshots, and a high degree of scalability.
      • Advantages: Data integrity, support for large storage pools, snapshots, and replication.
      • Disadvantages: More complex to set up and manage, limited support on non-Solaris platforms.

    Components of a File System

    1. File Control Block (FCB):

      • The FCB is a data structure used by the operating system to store metadata about a file, such as the file's name, location on the disk, size, and permissions. The FCB is used by the file system to perform I/O operations on the file.
    2. Inodes:

      • In UNIX-like file systems (e.g., ext3, ext4), an inode is a data structure that stores metadata about a file. Each file is identified by a unique inode number, which contains details like the file's ownership, permissions, size, and disk blocks where the file’s data is stored.
    3. Directory Structure:

      • The directory is a logical collection of files and subdirectories. It maintains a mapping between file names and their corresponding inodes (or File Control Blocks).
      • The root directory is the top-level directory in a file system. Directories may be organized in a tree structure, allowing hierarchical organization of files.
    4. File Allocation Table (FAT):

      • In FAT file systems, the File Allocation Table is a table used to track the allocation of disk blocks for files. It stores the starting address of each file and the sequence of blocks that belong to the file.
    5. Block Allocation:

      • Files are stored in blocks, which are the smallest units of data storage in a file system. The block size can vary depending on the file system but is usually between 512 bytes and 4 KB. Larger block sizes lead to more efficient storage for large files but increase internal fragmentation.
    6. Journal (Journaling):

      • Many modern file systems, like ext3, NTFS, and ZFS, use journaling to protect the file system from corruption in case of system crashes. Journaling involves logging changes to metadata (and sometimes data) before committing them to disk, allowing the system to recover to a consistent state after a failure.

    File System Operations

    1. File Creation:

      • When a file is created, the file system allocates space for it on the disk and creates an entry in the directory structure.
    2. File Reading and Writing:

      • The operating system provides system calls such as read() and write() that allow programs to access files. The file system ensures that the data is read or written from the correct disk blocks.
    3. File Deletion:

      • When a file is deleted, the file system removes its entry from the directory and deallocates the disk blocks that were used to store the file's data.
    4. File Renaming:

      • The file system allows files to be renamed, which involves modifying the directory structure to reflect the new file name.
    5. File Locking:

      • File systems may provide mechanisms for file locking to ensure that multiple processes can safely access or modify a file without conflict.

    File System Performance Considerations

    1. Disk Caching:

      • Most modern file systems use disk caching to improve performance by temporarily storing data in RAM. When a file is read or written, the operating system first checks if the data is in the cache, avoiding the need for slow disk access.
    2. Fragmentation:

      • File fragmentation occurs when files are not stored in contiguous blocks, leading to inefficient disk usage and slower performance. File systems typically perform defragmentation to reorganize files and free space into contiguous blocks.
    3. Compression:

      • Some file systems support file compression, which reduces the amount of space used by files. This can be beneficial for storage but may incur some CPU overhead when accessing the files.
    4. Encryption:

      • File systems such as APFS or NTFS support encryption for securing files. Files are automatically encrypted and decrypted as they are read from or written to the disk.
    5. Snapshots:

      • Snapshots are a feature in advanced file systems like ZFS or Btrfs. A snapshot is a read-only copy of the file system at a specific point in time. This is useful for backup and recovery purposes.

    Conclusion

    The file system is a critical component of the operating system responsible for organizing, storing, and managing files on storage devices. Different file systems are designed with specific features, such as performance optimizations, data integrity, scalability, and security. Understanding file system concepts, operations, and performance characteristics is crucial for system administrators and developers to ensure efficient file handling, reliable data storage, and optimal system performance.

    ← Previous topic 24
    Memory-Mapped Files
    Next topic 26 →
    File Concept

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    8mremaining
    1.4kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Operating Systems