filing_systems.htmlTEXTGoMkQeµ0¸(µ7F5 Macintosh Filing Systems

HFS (HFS Standard)

Hierarchical File System (HFS) Specifications
Before discussing hard drive block allocation, and the intricacies of determining allocation block sizes and such, let's first review the Hierarchical File System, better known as HFS.
Below are some specifications and associated terminology used to describe the Macintosh HFS structure. The following numbers apply to both System 6 and System 7, and are current as of this writing.

A Macintosh Volume
A volume is either a full disk, or a section of a disk, partitioned into separate parts. If you partition a single drive then each partition is considered a volume.

What's a Logical block?
A logical block is a unit of drive space composed of up to 512 bytes. A logical block is numbered from 0 to n, n being the last block on the volume - not necessarily the hard disk. Take the volume size, divide it by 512 bytes, and you have the number of logical blocks.

What's an Allocation Block?
An allocation block is a unit of storage on a volume, composed of one or more logical blocks. The larger the volume, the more logical blocks comprise one allocation block. The maximum number of allocation blocks per volume is 65,536; most volumes have slightly less.

In both the Macintosh and DOS environment, the maximum number of blocks on a driver is 65,536 because both Operating Systems address the allocation blocks with a 16-bit address. Drives larger than 512mb cannot use a block size of 8K or less because there just aren't enough addresses. Thus, if a 2gig drive is one Macintosh partition, the smallest file size allowed is 32K. (If you save a TeachText file with one character in it, it would take up 32K of disk space.) This means that the size of your hard drive determines the minimum size of each file.

A non-empty file fork always occupies at least one allocation block, no matter how many bytes of data the file fork contains. If the data fork and resource fork of a file contain data, the file uses two allocation blocks. If all the files are only one allocation block long, then there can be as many files on the volume as there are allocation blocks for the volume. However, when a file is longer than one allocation block, the total number of possible files decreases. For example, on a volume with 65,535 allocations block, you can have:
* 65,536 files, each 1 allocation block long.
* 32,768 files, each 2 allocation blocks long.
* 2048 files, each 32 allocation blocks long.
* 1024 files, each 64 allocation blocks long.

All of the numbers above refer to the System's record structures. Other elements place tighter restrictions on the actual number of usable files in the root directory. The Standard File dialog uses the List Manager. The List Manager has a limit of 32K of data, which is somewhere between 800 and 900 files. Though more files can be handled in a directory, the List Manager will not display the first 32K.

A second element concerns the performance of the Finder when approaching 800 to 900 files per directory. Even simple operations, such as moving the icon of a file, tend to slow down considerably when this number of files exists in a directory. This limitation changes depending on the speed of the individual Macintosh model.

Determining the Allocation Block Size
Follow these steps to calculate the allocation block size:
1) Take the size of the drive in megabytes and multiply it by 2000 (there are 2000 disk blocks in 1mb of disk space).
2) Divide that number by 65,536, since the Macintosh cannot have more than 65,536 allocation blocks.
3) Round this number up and multiply it by 512.
The result is the number of bytes in the allocation block. Here is an example using a 230mb drive:
230 x 2000 / 65536 = 7.019
7.019 rounded up = 8
8 x 512 = 4096 bytes

So what does this mean to you? The larger the hard drive, the larger the allocation block size, and the more space that is wasted on small files. If you have a large drive with a lot of small files, the hard drive space is being used less efficiently than if most of your files average 32K in size.

Note: Since drives come from different manufacturers, it is possible to get different values. This is because a 500 MB drive is not exactly 500 MB but is usually somewhat larger. This could result in different logical block sizes than those listed in the chart (see Allocation Block Size Table below), but the difference should not be more than +/- 512 bytes. This difference is most noticeable on the larger drives. For example, the 500 MB drive actually calculates to 8192 bytes but the 500 MB drive in some Macintosh computers is actually 540 MB, which has a logical block size of 8704, as listed in the chart.

Allocation Block Size Table
Here is a complete list of allocation block sizes for the various volume sizes, based on the formula described above.

Volume Organisation of HFS
The first two logical blocks (labelled 0 and 1) of a volume are the boot blocks. This is where the information for mounting the volume is stored.

The third logical block (labelled 2) is the Master Directory Block, or MDB for short. This block contains part of the data structure of a flat directory volume. It contains the volume information and the volume allocation block map. This block is where the information for the hard disk, such as number of files in the directory and the last time the drive was initialized, is stored.

Logical blocks 3 to x (see the following table) contain the volume bitmap. This block is a data structure containing a sequence of bits, one bit for each allocation block. The volume bitmap stores a reference to every piece of data that is in the allocation blocks and indicates whether the block is allocated or free for use. Volume bitmaps exist both on hierarchical directory volumes and in memory.

Volumes may have as few as 32,768 allocation blocks and as many as 65,536 allocation blocks. This table defines what logical block the volume bitmap ends on based on the number of allocation blocks:
Allocation Blocks Last Volume Bitmap Logical Block
> 61,440 18
> 57,344 17
> 53,248 16
> 49,152 15
> 45,056 14
> 40,960 13
> 36,864 12
> 32,768 11

Allocation blocks begin after the volume bitmap. Contained in the allocation blocks are the catalogue, extents and data files.

The catalogue file is a list of all files and folders stored in a volume. The catalogue file maintains the relationships between the files and directories on a hierarchical directory volume. It corresponds to the file directory on a flat directory volume. The catalogue file is organised and accessed using a B-tree structure. The files are arranged in alphabetical order evenly balanced on the tree so that finding a 'Z' doesn't take any longer than finding an 'A'. This structure is the glue that keeps the catalogue file together.

The extents tree file contains the locations of all the files on a volume (An extent is a series of contiguous allocation blocks). The extents tree file is where the information (such as where to find file, and how many extents a file is divided into) about the data files you have created is stored. Any given file you create may be broken up into multiple extents. When extents are linked together, behind the scenes, with information from the extents tree file, the appearance is of one data file.

The next, and largest, section of the volume contains all the actual data files and applications which are referenced using the above files.

The next to last block on the hard disk contains the alternate master directory. This alternate is a backup to the MDB kept on logical block 2. It is used when the file manager determines that the MDB is corrupt and needs to be rewritten with the correct information.

The very last block is empty. It is used to check for bad sections of the hard disk.

What You Can Do
So, can you do anything to decrease the file size on a large hard drive? One solution is to partition larger drives into smaller partitions, or logical drives, each with a maximum of 65,536 blocks.
Apple's Drive Setup can be used to partition qualified Apple hard drives and some removable devices as listed in the Drive Setup Guide file. Unsupported hard drives will show up in the device list by name, however, if you select an unsupported hard drive you will get the message, "Cannot modify a disk in an unsupported drive".

Drive Setup is supported on all of the Power Macintosh computers. This includes the original Power Macintosh computers and the new PCI-based Power Macintosh computers. Drive Setup is also supported on 68LC040 processor-based systems that have IDE drives installed. Drive Setup is not supported with the Power Macintosh Upgrade Card. The latest version of Drive Setup is available from Apple's web site.

HFS+ (HFS Extended)

What's the difference between HFS and HFS+ filing systems? Can I use HFS+?
Hierarchical Filing System (HFS) is a 12 year old filing system, it allows only a limited number of blocks (65,536) you can have on a partition. I suggest you create multiple partitions from any hard disk above 1 gigabyte, because you will only be wasting valuable disk space, due to large block sizes. See the table below.

Estimated Block Sizes in Relation to the Size of HFS Standard Partitions
(In increments of 0.5k for every 31mb, and +16k for every gigabyte.)
Partition Size = Block Size Partition Size = Block Size
0mb - 31mb = 0.5k 1 1.0gig - 1.5gig = 16-24k
32mb - 64mb = 1k 1.5gig - 2.0gig = 24-32k
65mb - 95mb = 1.5k 2.0gig - 3.0gig = 32-48k
96mb - 255mb = 2-4k 3.0gig - 4.0gig = 48-64k
256mb - 511mb = 4.5-8k 4.0gig - 9.0gig = 64-144k
512mb -1023mb = 8.5-16k 9.0gig - 18.0gig = 144-288k

HFS+ or HFS Extended was made to extend the number of blocks, particularly for very large hard disks (1gig+). It now allows for hundreds of millions of blocks to be used. The default System block allocation is as follows:
* 10-250 megabyte partitions will have a 0.5k block size.
* 250-999 megabyte partitions will have either a 1k or 2k block size.
* 1 gigabyte up to 2 terrabyte (2000gig) partitions will have a 4k block size.

The Limitations of HFS
* The maximum volume size under System 6 and System 7 is 2 gigabytes. System 7.5 increased that limit to 4 GB and System 7.5.2 (and later) increases that limit to 2 terrabytes on some computers, including; any system that shipped with System 7.5.2 or newer, and any Macintosh system with PCI slots.
* The maximum number of volumes is theoretically limited to 173 due to the maximum number of open files in Mac OS. Since there are other files which are opened when the computer boots up, the actual maximum will vary depending upon how many other files are open by the operating system.
* The maximum file size is 2 gigabytes.
* The maximum number of files on a volume is 65,536.
* The maximum number of files in a folder is 32,767.
* The maximum size of the data fork in a file is 2 gigabytes.
* The maximum size of the resource fork in a file is 16 megabytes.
Note that AppleShare, including Personal File Sharing, has its own volume size limitations.

The Limitations of HFS+
* Maximum number of volumes: 21.
At system boot, the event queue for the Finder can accept 20 volumes plus the startup volume. Once the computer has completed the boot process, you may use a disk utility to mount as many additional volumes as there are available file control blocks. This number is variable depending upon how many applications are running, files open, or other operating system processes which require file control blocks.
* Maximum volume size: 2 terrabytes
* Maximum file size: 2 gigabytes
* Maximum data fork size: 2 gigabytes
* Maximum resource fork size: 16 megabytes
* Maximum number of files: more than 2 billion.
* Maximum number of files/folders in a folder: 32,767.
The advantage of using HFS+ is obvious, quite a lot of disk space will be reclaimed. This depends on the size of the hard disk, 1 gigabyte drive and above will see the most gains in saved space. Apple have added other advanced features to the new filing system, that are not accessible via System 8.1 at the moment, but should be in later revisions of the operating system.

The Advantages of HFS+
* 68040/060 Macs can read/write to HFS+ disks.
* A server with a large capacity HFS+ formatted disk can be accessed by any Mac, with any System version.
* The user can define the allocation block size, but only with some commercial formatting software, eg. 0.5-2k (under 500mb only), 4k, 8k or even 16k if you want.
* The maximum partition size is at least 2 terrabytes, or 2000 gigabytes.
* It uses disk space much more efficiently, especially with small files.
* Additional, built-in features of HFS+ will come available with later versions of PPC System software, eg. MacOS 8.5.

The Disadvantages of HFS+
* Only PowerPC and 68040/060 Amigas and Macs can use HFS+.
* You will have to reformat/optimise&format your hard disk.
* 68k Macs cannot startup from a HFS+ volume, it will fail to boot.
* HFS+ will not format any partition below 32mb.
* It requires the Text Encoding Convertor system Extension, and the Text Encoding data folder.
* There are only a few repair packages which can repair and optimise HFS+ formatted disks.
* Only System 8.1 is capable of recognising HFS+ disks.

HFS+ Compatible Programs
* TechTool Pro2 (commercial).
* Disk First Aid v8.2 (on System 8.1 CD, or via the 8.1 updater).
* Norton Utilities v4.0 (commercial) - for PowerPC Macs only.
* Look at commercial software for HFS+ formatting & optimisation programs.
Don't use...
* Any version of Norton Utilities from v1 to v3.52, they will damage a HFS+ disk. Norton Fix - repairs any damage caused by Norton Disk Doctor 3.5. Free from any Mac internet site.

ÿÿ