AICollection Help

HFS+ (Hierarchical File System Plus)

HFS+, or the Hierarchical File System Plus, was developed by Apple as an improvement over the original HFS. Introduced in 1998 with Mac OS 8.1, it was designed to support larger storage volumes and offer enhanced performance and reliability. HFS+ remained the default file system for macOS until the introduction of APFS in 2017. Here's a detailed look at HFS+ and its features:

Structure of the HFS+ File System

1. Volume Header:

The volume header contains metadata about the file system, including:

  • Volume Name:

    • The name of the volume as displayed to the user.

  • Total Sectors:

    • Total number of sectors in the file system.

  • Block Size:

    • Typically 4096 bytes, allowing support for larger volumes.

  • Catalog File Pointer:

    • Points to the catalog file that organizes the file system’s hierarchy.

  • Allocation Bitmap:

    • Tracks the allocation status of blocks.

2. Catalog File:

The catalog file is a B-tree structure that organizes metadata for files and directories:

  • Nodes:

    • Each node in the B-tree contains file or directory records.

  • File Records:

    • Store metadata such as file size, timestamps, and pointers to data blocks.

  • Directory Records:

    • Contain pointers to child directories and files, enabling a hierarchical structure.

3. Resource Forks and Data Forks:

HFS+ retains support for the two forks introduced in HFS:

  • Data Fork:

    • Contains the file’s main data.

  • Resource Fork:

    • Stores additional structured data, such as icons or application resources.

4. Allocation Strategy:

HFS+ uses an allocation bitmap to manage storage efficiently:

  • Extent-Based Allocation:

    • Tracks contiguous ranges of blocks to minimize fragmentation.

  • Optimized Placement:

    • Places related files close together to improve access times.

5. Journaling:

Starting with macOS 10.2.2, HFS+ introduced journaling to improve data integrity:

  • Write-Ahead Logging:

    • Records changes before they are committed to the file system.

  • Fast Recovery:

    • Allows quick recovery after crashes or power failures.

Features of HFS+

  • Support for Large Volumes:

    • Handles volumes up to 8 exabytes and files up to 8 EB (with practical limits based on block size).

  • Unicode File Names:

    • Supports international character sets.

  • Journaling:

    • Ensures file system integrity and faster recovery.

  • Efficient Storage Management:

    • Extent-based allocation reduces fragmentation.

  • Metadata Support:

    • Tracks creation, modification, access, and backup timestamps for files.

Limitations of HFS+

  • Performance on Large Volumes:

    • Slower performance compared to modern file systems like APFS.

  • Fragmentation:

    • Can still experience fragmentation over time, requiring optimization.

  • Legacy Support:

    • Superseded by APFS, with limited support on modern macOS systems.

  • File System Overhead:

    • Resource forks increase complexity and storage overhead.

Tools and Commands for HFS+

  • fsck_hfs:

    • Checks and repairs HFS+ file systems.

  • newfs_hfs:

    • Creates an HFS+ file system.

  • hfs.util:

    • Manages HFS+ volumes and displays file system information.

Example

# Create an HFS+ file system newfs_hfs -J /dev/diskX # Check and repair an HFS+ file system fsck_hfs /dev/diskX # Display information about an HFS+ volume hfs.util -p /dev/diskX

HFS+ provided significant improvements over its predecessor, HFS, and was a reliable file system for macOS for nearly two decades. Although it has been replaced by APFS, HFS+ played a key role in the evolution of Apple’s storage technology.

Last modified: 19 January 2025