Topic Overview

File Systems (EXT4, NTFS, FAT32)

Compare file systems: EXT4 (Linux), NTFS (Windows), FAT32 and their characteristics, features, and use cases.

File systems organize and manage data on storage devices. EXT4, NTFS, and FAT32 are common file systems with different features and use cases.


What is a File System?

File system organizes data on storage:

  • File organization: How files are stored
  • Directory structure: How directories are organized
  • Metadata: File attributes, permissions, timestamps
  • Allocation: How disk space is allocated

Functions:

  • File management: Create, read, write, delete files
  • Directory management: Organize files in directories
  • Access control: Permissions, security
  • Data integrity: Journaling, checksums

EXT4 (Fourth Extended File System)

EXT4 is the default file system for Linux.

Features

  • Journaling: Logs changes before writing (faster recovery)
  • Large files: Supports files up to 16TB
  • Large volumes: Supports volumes up to 1EB (exabyte)
  • Extents: Efficient allocation for large files
  • Delayed allocation: Improves performance
  • Backward compatible: Can mount EXT2/EXT3

Characteristics

File size: Up to 16TB
Volume size: Up to 1EB
Block size: 1KB, 2KB, 4KB
Journaling: Yes
Case sensitive: Yes

NTFS (New Technology File System)

NTFS is the default file system for Windows.

Features

  • Journaling: NTFS log for recovery
  • Large files: Supports files up to 16EB
  • Large volumes: Supports volumes up to 16EB
  • Permissions: ACLs (Access Control Lists)
  • Compression: Built-in file compression
  • Encryption: EFS (Encrypting File System)

Characteristics

File size: Up to 16EB
Volume size: Up to 16EB
Block size: 4KB (default)
Journaling: Yes
Case sensitive: No (case preserving)

FAT32 (File Allocation Table 32)

FAT32 is a legacy file system.

Features

  • Simple: Simple structure, widely supported
  • Compatibility: Works on all operating systems
  • No journaling: No recovery mechanism
  • Limited: Small file and volume sizes

Characteristics

File size: Up to 4GB
Volume size: Up to 2TB (theoretical), 32GB (practical)
Block size: Variable
Journaling: No
Case sensitive: No

Comparison

FeatureEXT4NTFSFAT32
OSLinuxWindowsAll
File size16TB16EB4GB
Volume size1EB16EB32GB (practical)
JournalingYesYesNo
PermissionsUnix permissionsACLsLimited
Case sensitiveYesNoNo
CompressionNoYesNo
EncryptionNoYes (EFS)No

Examples

File System Operations

// Create file (EXT4)
int fd = open("/path/to/file", O_CREAT | O_WRONLY, 0644);
write(fd, "Hello", 5);
close(fd);

// Read file
fd = open("/path/to/file", O_RDONLY);
char buffer[100];
read(fd, buffer, 100);
close(fd);

File System Information

import os
import stat

def get_file_info(filepath):
    """Get file system information"""
    stat_info = os.stat(filepath)
    
    return {
        'size': stat_info.st_size,
        'mode': stat(stat_info.st_mode),
        'uid': stat_info.st_uid,
        'gid': stat_info.st_gid,
        'atime': stat_info.st_atime,
        'mtime': stat_info.st_mtime,
        'ctime': stat_info.st_ctime
    }

Common Pitfalls

  • File size limits: FAT32 4GB limit. Fix: Use NTFS or EXT4 for large files
  • Case sensitivity: EXT4 case sensitive, NTFS not. Fix: Be aware of differences
  • Permissions: FAT32 no permissions. Fix: Use NTFS or EXT4 for security
  • Journaling: FAT32 no journaling, data loss risk. Fix: Use journaling file systems

Interview Questions

Beginner

Q: What are the differences between EXT4, NTFS, and FAT32 file systems?

A:

EXT4 (Linux):

  • OS: Linux
  • File size: Up to 16TB
  • Volume size: Up to 1EB
  • Journaling: Yes
  • Permissions: Unix permissions
  • Case sensitive: Yes

NTFS (Windows):

  • OS: Windows
  • File size: Up to 16EB
  • Volume size: Up to 16EB
  • Journaling: Yes
  • Permissions: ACLs
  • Case sensitive: No

FAT32 (Legacy):

  • OS: All (universal)
  • File size: Up to 4GB
  • Volume size: Up to 32GB (practical)
  • Journaling: No
  • Permissions: Limited
  • Case sensitive: No

Key Differences:

FeatureEXT4NTFSFAT32
File size16TB16EB4GB
JournalingYesYesNo
PermissionsUnixACLsLimited

When to use:

  • EXT4: Linux systems
  • NTFS: Windows systems, large files
  • FAT32: USB drives, compatibility

Intermediate

Q: Explain journaling in file systems. How does it improve reliability?

A:

Journaling logs changes before writing to disk.

How it works:

  1. Write to journal

    Transaction: Write file A
    Journal: Log "Write file A" (metadata + data)
    
  2. Write to disk

    Apply changes to actual file system
    
  3. Commit

    Mark transaction as complete in journal
    

Benefits:

  • Faster recovery: Replay journal instead of full fsck
  • Data integrity: Know what was being written
  • Atomic operations: Transactions all-or-nothing

Example:

Without journaling:
  Crash during write → File system inconsistent
  Recovery: Full fsck (slow, may lose data)

With journaling:
  Crash during write → Journal has record
  Recovery: Replay journal (fast, consistent)

EXT4 Journaling:

  • Metadata journaling: Logs metadata changes
  • Full journaling: Logs data + metadata (slower, safer)

NTFS Journaling:

  • NTFS log: Transaction log for recovery
  • MFT (Master File Table): Tracks all files

Senior

Q: Design a file system that handles millions of files efficiently. How do you optimize directory structure, metadata storage, and file allocation?

A:

class HighPerformanceFileSystem {
  private inodeTable: InodeTable;
  private directoryIndex: DirectoryIndex;
  private allocationManager: AllocationManager;
  
  constructor() {
    this.inodeTable = new InodeTable();
    this.directoryIndex = new DirectoryIndex();
    this.allocationManager = new AllocationManager();
  }
  
  // 1. Inode Structure
  class Inode {
    // Compact metadata
    private metadata: {
      mode: number;        // Permissions
      uid: number;         // User ID
      gid: number;         // Group ID
      size: bigint;        // File size
      blocks: number;      // Number of blocks
      atime: number;       // Access time
      mtime: number;       // Modify time
      ctime: number;       // Change time
    };
    
    // Extents for large files
    private extents: Extent[];
  }
  
  // 2. Directory Indexing
  class DirectoryIndex {
    // B-tree for fast lookup
    private index: BTree;
    
    async lookup(filename: string): Promise<Inode> {
      // O(log n) lookup instead of O(n)
      return await this.index.search(filename);
    }
    
    async createEntry(filename: string, inode: number): Promise<void> {
      await this.index.insert(filename, inode);
    }
  }
  
  // 3. Extent-Based Allocation
  class AllocationManager {
    // Extents: (start_block, length) instead of individual blocks
    allocate(size: number): Extent[] {
      // Find contiguous blocks
      const extent = this.findContiguousBlocks(size);
      return [extent];
    }
  }
  
  // 4. Performance Optimization
  optimizePerformance(): void {
    // Delayed allocation: Allocate on write
    // Prefetch: Read ahead
    // Caching: Cache frequently accessed files
  }
}

Features:

  1. Inode table: Efficient metadata storage
  2. Directory indexing: B-tree for fast lookup
  3. Extent allocation: Efficient for large files
  4. Performance: Delayed allocation, prefetch, caching

Key Takeaways

  • File systems: Organize data on storage devices
  • EXT4: Linux default, journaling, large files (16TB)
  • NTFS: Windows default, journaling, very large files (16EB), ACLs
  • FAT32: Legacy, universal compatibility, limited (4GB files, 32GB volumes)
  • Journaling: Logs changes for faster recovery and data integrity
  • Best practices: Use journaling file systems, consider file size limits, understand permissions

About the author

InterviewCrafted helps you master system design with patience. We believe in curiosity-led engineering, reflective writing, and designing systems that make future changes feel calm.