Hierarchical File System: What Is HFS File System

What Is HFS File System

Apple Computer launched the Hierarchical File System (HFS), also known as the Mac OS Standard or HFS Standard, in September 1985 to replace the Macintosh File System (MFS) with a more robust format supporting Macintosh disks of arbitrary sizes and layouts. It stores files on floppy disks, CD-ROM discs, and hard drives.

To learn more about this file system, the following table displays the key features of HFS.

Full name

Hierarchical File System

Developer(s)

Apple Computer

Date released

September 17, 1985 (with System 2.1)

Maximum volume size

2 TB

Maximum file size

2 GB

Maximum number of files

65535

Maximum filename length

31 characters

Supported OSs

Classic Mac OS, macOS, Linux, Microsoft Windows (through MacDrive or Boot CampIFS drivers)

Transparent encryption

No

Structures of an HFS Volume

A storage volume is essentially divided into 512-byte logical blocks. The Hierarchical File System (HFS) organizes these logical blocks into allocation blocks, which can contain one or more logical blocks based on the volume's total size. HFS addresses allocation blocks with a 16-bit value, limiting the number of allocation blocks to 65,535.

An HFS volume is made up of five structures:

the hierarchical file system structure
1.    Logical blocks 0 & 1

The boot blocks of the volume are logical blocks 0 and 1. It contains system startup information, including the system's names and shell files loaded at startup.

boot blocks of the hierarchical file system
2.    Logical block 2

The Master Directory Block (MDB) is located in logical block 2. It specifies a wide range of data about the volume. It includes the volume's creation date and time stamp, the location of other volume structures (the volume bitmap), and the size of logical systems (allocation blocks).

The Alternate Master Directory Block (Alternate MDB) is a duplicate of the MDB located at the opposite end of the volume in the second to last logical block. It is primarily intended for disk utilities and is only updated when the catalog file or the extents overflow file grows in size.

master directory block of the hierarchical file system
3.    Logical block 3

The volume bitmap's starting block is logical block 3, which keeps track of which allocation blocks are in use and free. Every allocation block on the volume is represented by a bit on the map. If the bit is set, the block is in use, while if the bit is clear, the block is available for use. Because each allocation block requires a bit, the size of the Volume Bitmap is determined by the volume.

bitmap of the hierarchical file system
4.    The Extent Overflow File

Once the initial three extents in the Catalog File are used up, the Extent Overflow File is a B-tree that contains different extents that record which allocation blocks are designed for the files. Later versions added the ability for the Extent Overflow File to store extents that record bad blocks to prevent the file system from allocating a bad block to a file.

extent overflow file of the hierarchical file system
5.    Catalog File

The Catalog File is another B-tree containing records for all the files and directories on the volume. It keeps four types of records. Each file has a File Thread Record and a File Record, while each directory has a Directory Thread Record and a Directory Record. The unique Catalog Node ID is used to locate files and directories in the Catalog File (or CNID).

catalog file on the hierarchical file system
  • A File Thread Record only stores the name of the file and the CNID of its parent directory.
  • A File Record contains information about the file, such as its CNID, size, and timestamps (when the file was created, last modified, and last backed up). It also contains the first file extents of the data, resource forks, pointers to the file's first data, and resource extent records in the Extent Overflow File. The File Record also contains two 16-byte fields the Finder uses to store file attributes.
  • A Directory Thread Record only stores the directory's name and the CNID of its parent directory.
  • A Directory Record stores information such as the number of files in the directory, the directory's CNID, and timestamps (when the directory was created, last modified, and last backed up). Like the File Record, the Directory Record stores two 16-byte fields for use by the Finder.

Replacements

HFS stayed Apple's primary file system format until 1998, when HFS+ was released as part of Mac OS 8.1, finally adding 32-bit support for block addresses and the mapping table and switching from Mac OS Roman to Unicode for character representation. Because HFS did not have a transaction journal, mild data corruption caused by interrupted cached writes to disk would necessitate a total rebuild of the B-Tree, resulting in the deletion of files and file data.

Limitations of HFS

HFS Volume Limits

Mac OS 6 and 7 computers can only address HFS volumes up to 2GB, while OS 7.5 increased the capacity to 4GB. All Mac computers can now handle HFS volumes up to 2TB in size as of the OS 7.5.2 revision. Users can work around the maximum volume size limitation by creating multiple HFS volumes on the same storage device.

HFS File Limits

Files on an HFS-formatted drive cannot be larger than 2GB. Furthermore, HFS volumes can only hold 54,536 individual files and 32,767 files within a single folder.

HFS Block Size Limits

HFS can support up to 65.535 allocation blocks on a single storage device volume. HFS partitions storage device space into equal-sized individual blocks that the computer uses to determine where data files begin and end. The block size grows in proportion to the size of the hard drive.

the hierarchical file system server

How To Mount and Access HFS Drive on Linux

To access such filesystems from Linux, use the hfsplus filesystem driver. The following methods are used when mounting an HFS filesystem on Linux.

Step 1. Check that you have hfsplus installed:

sudo apt install hfsplus


Step 2. Find the volume's block device. You can list all connected disks by running:

sudo fdisk -l

Next, type the command:

Apple HFS/HFS+

We'll assume it's /dev/sdd2 for this guide, but yours could be completely different.


Step 3. Ascertain that you have a mounting point:

sudo mkdir /media/myhfsdrive


Step 4. Install the device:

sudo mount -t hfsplus /dev/sdd2 /media/myhfsdrive

You should now be able to read the device at /media/myhfsdrive.

mount and access hfs on linux

Summary

It's essential to have prior knowledge about the Hierarchical File System (HFS) as it has commendable uses and is the previous primary file system of Apple computers. It has a helpful structure but also with limitations. With the help of this step-by-step guide and data recovery tools from Wondershare Recoverit, you can conveniently mount and access HFS on Linux devices without minding data loss, as you can recover it instantly.

You May Also Like