Archived - Mac OS: Technical overview of disk volume structures

This article provides a technical overview of the elements of a disk volume or partition, including the partition map, boot blocks, master directory block, volume bitmap, B-trees, and more.
This article has been archived and is no longer updated by Apple.
A disk can contain several partitions, which are treated as separate virtual disks by the system. Each partition contains information similar to that shown here:

Layout of a Disk Partition

Note: Floppy disks are not partitioned and do not have all the elements described in this article. The first block on a floppy disk contains the boot block for its single volume.

Driver Descriptor Map
A disk's first block (block 0) contains the driver descriptor map-information on the number and location of the drivers on the disk.

Partition Map
The second block begins the disk's partition map. It specifies the start and length of each partition as well as its type (Macintosh, A/UX, MS-DOS, and so forth). The partition map itself is actually a partition and contains an entry for itself.

Device Driver
The device driver is located after the partition map. It is used for communication with the drive. (Note that if the device driver is updated after the drive is initialized, the driver may be moved to the end, depending on space constraints.)

Boot Blocks
Mac OS Standard format (HFS) volumes begin with two boot blocks. This is where startup instructions are stored along with directions for locating the System and Finder files.

Master Directory Block
The master directory block contains volume information such as the date and time of a volume's creation, the number of files the volume contains, and the allocation block size.

The allocation block size is the minimum number of bytes that can be allocated for a file. With Mac OS Extended format, it is 4K for most volumes regardless of their size. With Mac OS Standard format, the allocation block size is dependent upon the size of the volume. A Mac OS Standard volume can have no more than 64K allocation blocks. Therefore, the larger the volume, the larger the allocation block size. Whenever a file is written to the disk, it is allocated a certain number of logical blocks or "clumps. This slows down the process of fragmentation, but can result in open space being left at the end of each file's allocation.

When the master directory block is read, the volume is mounted and an area is created in memory called the Volume Control Block (VCB).

Volume Bitmap
The volume bitmap is a record of which blocks are allocated to files. It contains one bit for each allocation block on the volume. If the block is taken, the bit is set. If the block is available, the bit is cleared.

Catalog File/Tree
Contains hierarchical information about the relationship and structure of files and folders and their location on a volume.

Specifically, it contains the parent directory for each file. In order to determine the full path, a directory's parent is found, and so on, until the root level is reached. The catalog file and extents file are each in the form of a "B-tree" (and are the source for all B-tree type errors). See below for a discussion of B-trees.

Extents File/Tree
An "extent" is a contiguous range of blocks that are allocated to a file. The extents file (also called Extents Overflow File) keeps track of the location of records that cannot be placed contiguously. This information is used to locate pieces of a file when it is loaded. Some extent information is contained within the MDB and VCB. The first three file extents are always retained in memory with the VCB.

Given this information, it is understandable why optimizing, or "defragmenting," a disk is so effective. Making files contiguous reduces seek time and reduces the number of accesses to the extents file.

All of the items listed before the catalog and extents files are contiguous. The catalog and extents files can be anywhere on the volume and are not contiguous.

The catalog file also stores Finder information for each file. This information consists of:

file type: Identifier of one of several categories.
file creator: Name of the application that created it.
file's location in window: Relative position in the window when it's opened.
directory that contains file: The directory path of the file.
Finder flags: These are information items (bits) that can be set to on or off.

The Finder takes these into account when it reads them. Here is a list of the Finder flags:

Flag Description
isInvisible File won't appear in dialog box listings or windows.
hasBundle File is associated with a custom icon.
nameLocked File can't be renamed or have another icon assigned to it by a user.
isStationery File is a stationery pad.
isShared File has its own customized icon.
hasCustomIcon File has its own customized icon.

The rest of the volume contains application/data files, the catalog file, extents overflow file, and open space.

A Discussion of B-Trees
Catalog and extents files are organized into B-trees, a structure that allows for optimum read speeds.

Both of these files contain only data forks; there are no resource forks. The location of the start of the catalog and extents B-tree is contained at the beginning of the MDB and is stored in memory.

This illustration offers a rough diagram of what the disk structure of the catalog and extents files look like:

Disk structure of the catalog and extents files

A directory, which consists of the catalog B-tree and the extents B-tree, keeps track of file locations (as well as other information). The catalog B-tree contains a unique entry for every file, specifying its name, attributes, location, and other information. It functions as an index or a table of contents for the disk. The extents B-tree contains information about file fragments.

The bottom level of a B-tree structure is occupied exclusively by leaf nodes. A catalog file leaf node can contain four different types of records, one of which is the file thread record. A file thread record provides a link between a file and its parent directory. It enables the File Manager to find the name and directory ID of the parent of a given file.

B-tree structures are complex. If one becomes damaged, erroneous information is read by the File Manager and the referenced files can also become damaged. This is why it is vital to run Disk First Aid or similar utilities on a regular basis.

Related documents

8647: Macintosh: File System Specifications and Terms
30344: Mac OS: About Mac OS Extended Format
24601: Mac OS Extended Format: Volume and File Limits
7565: Disk First Aid: Purpose
13628: Disk First Aid: What to do When It Finds an Error
Last Modified: Feb 20, 2012
Print this page
  • Last Modified: Feb 20, 2012
  • Article: TA21692
  • Views:

  • Rating:
    • 54.0

    (13 Responses)