HFS Plus

From Wikipedia, the free encyclopedia
  (Redirected from HFS+)
Jump to: navigation, search
HFS+
Developer Apple Inc.
Full name Hierarchical File System Plus
Introduced January 19, 1998 (Mac OS 8.1)
Partition identifier Apple_HFS (Apple Partition Map)
0xAF (MBR)
Apple_HFSX (Apple Partition Map) when HFSX
48465300-0000-11AA-
AA11-00306543ECAC
(GPT)
Structures
Directory contents B-tree
File allocation Bitmap
Bad blocks B-tree
Limits
Max. file size 8 exabyte[1]
Max. number of files 4,294,967,295 (232-1)
Max. filename length 255 characters (255 UTF-16 encoding units, normalized to Apple-modified variant of Unicode Normalization Format D)
Max. volume size exabyte [2]
Allowed characters in filenames Unicode, any character, including NUL. OS APIs may limit some characters for legacy reasons
Features
Dates recorded access, attributes modified, backed up, contents modified, created
Date range January 1, 1904 – February 6, 2040
Date resolution 1 s
Forks Yes
Attributes Color (3 bits, all other flags 1 bit), locked, custom icon, bundle, invisible, alias, system, stationery, inited, no INIT resources, shared, desktop
File system permissions Unix permissions, NFSv4 ACLs (OS X v10.4 onward)
Transparent compression Yes (on OS X 10.6 and higher)[3]
Transparent encryption Yes (on OS X 10.7 and up). Per-home directory encryption is available with AES[clarification needed] using HFS+ formatted .dmg volumes on OS X versions prior to 10.7 but later than OS X 10.3
Supported operating systems Mac OS 8.1, Mac OS 9, OS X, & Darwin, Linux, Microsoft Windows (through Boot Camp[4] IFS drivers)

HFS Plus or HFS+ is a file system developed by Apple Inc. to replace their Hierarchical File System (HFS) as the primary file system used in Macintosh computers (or other systems running Mac OS). It is also one of the formats used by the iPod digital music player. HFS Plus is also referred to as Mac OS Extended (or, erroneously, “HFS Extended”), where its predecessor, HFS, is also referred to as Mac OS Standard (or, erroneously, as “HFS Standard”). During development, Apple referred to this filesystem with the codename Sequoia.[5]

HFS Plus is an improved version of HFS, supporting much larger files (block addresses are 32-bit length instead of 16-bit) and using Unicode (instead of Mac OS Roman or any of several other character sets) for naming the items (files, folders) – names which are also character encoded in UTF-16[verification needed] and normalized to a form very nearly the same as Unicode Normalization Form D (NFD)[6] (which means that precomposed characters like å are decomposed in the HFS+ filename and therefore count as two characters[7] and UTF-16 implies that characters from outside the Basic Multilingual Plane – typically seldom-used characters or those from ancient writing systems – also count as two characters in an HFS+ filename). HFS Plus permits filenames up to 255 UTF-16 characters in length, and n-forked files similar to NTFS, though until recently, almost no systems software took advantage of forks other than the data fork and resource fork. HFS Plus also uses a full 32-bit allocation mapping table, rather than HFS’s 16 bits. This was a serious limitation of HFS, meaning that no disk could support more than 65,536 allocation blocks under HFS. When disks were small, this was of little consequence, but as larger-capacity drives became available, it meant that the smallest amount of space that any file could occupy (a single allocation block) became excessively large, wasting significant amounts of space. For example, on a 1 GB disk, the allocation block size under HFS is 16 KB, so even a 1 byte file would take up 16 KB of disk space. Unlike most other file systems HFS Plus supports hard links to directories.

Like HFS, HFS Plus uses B-trees to store most volume metadata.

History[edit]

HFS+ was introduced with the January 19, 1998 release of Mac OS 8.1.[1] However, its first appearance, as a beta filesystem, was in the never-released Copland OS betas.

With the release of the Mac OS X 10.2.2 update on November 11, 2002, Apple added optional journaling features to HFS Plus for improved data reliability. These features were easily accessible in Mac OS X Server, but only accessible through the command line in the standard desktop client.[8]

With OS X v10.3, all HFS Plus volumes on all Macs are set to be journaled by default. Within the system, an HFS Plus volume with a journal is identified as HFSJ.

Mac OS X 10.3 also introduced another version of HFS Plus called HFSX. HFSX volumes are almost identical to HFS Plus volumes, except that they are never surrounded by the HFS Wrapper that is typical of HFS Plus volumes and they optionally support case sensitivity for file and folder names. HFSX volumes can be recognized by two entries in the Volume Header, a value of HX in the signature field and 5 in the version field.[1]

Mac OS X 10.3 also marked Apple's adoption of Unicode 3.2 decomposition, superseding the Unicode 2.1 decomposition used previously. This change has caused problems for developers writing software for OS X.[9]

With Mac OS X 10.4, Apple added support for Inline Attribute Data records, something that had been a part of the OS X implementation of HFS Plus since at least 10.0, but always marked as "reserved for future use".[10] Until the release of OS X Server 10.4, HFS Plus supported only the standard UNIX file system permissions; however, 10.4 introduced support for access control list-based file security, which provides a richer mechanism to define file permissions and is also designed to be fully compatible with the file permission models on other platforms such as Microsoft Windows XP and Windows Server 2003.[11]

In Mac OS X Leopard 10.5, directory hard-linking was added as a fundamental part of Time Machine.

In Mac OS X Snow Leopard 10.6, HFS+ compression was added. In open source and some other areas this is referred to as AppleFSCompression. Compressed data may be stored in either an extended attribute or the resource fork.[12] When using non-Apple APIs, AppleFSCompression is not always completely transparent.

In OS X Lion 10.7, logical volume encryption (known as FileVault 2) was added to the operating system. This addition to the operating system in no way changed the logical structure of the file system. Apple's logical volume manager is known as Core Storage and its encryption at the volume level can apply to file systems other than HFS Plus. With appropriate hardware, both encryption and decryption should be transparent.

Design[edit]

HFS Plus volumes are divided into sectors (called logical blocks in HFS), that are usually 512 bytes in size. These sectors are then grouped together into allocation blocks which can contain one or more sectors; the number of allocation blocks depends on the total size of the volume. HFS Plus uses a larger value to address allocation blocks than HFS, 32 bits rather than 16 bits; this means it can access 4,294,967,296 (= 232) allocation blocks rather than the 65,536 (= 216) allocation blocks available to HFS.[1]

Formerly, HFS Plus volumes were embedded inside an HFS standard filesystem. This was phased out by the Tiger transition to Intel Macs, where the HFS Plus filesystem was not embedded inside a wrapper. The wrapper was designed for two purposes; it allowed Macintosh computers without HFS Plus support in their ROM to boot HFS Plus volumes and it also was designed to help users transition to HFS Plus by including a minimal HFS volume with a read-only file called Where_have_all_my_files_gone?, explaining to users with versions of Mac OS 8.0 and earlier without HFS Plus, that the volume requires a system with HFS Plus support. The original HFS volume contains a signature and an offset to the embedded HFS Plus volume within its volume header. All allocation blocks in the HFS volume which contain the embedded volume are mapped out of the HFS allocation file as bad blocks.[1] Notable among filesystems used for Unix systems, HFS Plus does not support sparse files.

There are nine structures that make up a typical HFS Plus volume:[1]

  1. Sectors 0 and 1 of the volume are HFS boot blocks. These are identical to the boot blocks in an HFS volume. They are part of the HFS wrapper.
  2. Sector 2 contains the Volume Header equivalent to the Master Directory Block in an HFS volume. The Volume Header stores a wide variety of data about the volume itself, for example the size of allocation blocks, a timestamp that indicates when the volume was created or the location of other volume structures such as the Catalog File or Extent Overflow File. The Volume Header is always located in the same place.
  3. The Allocation File which keeps track of which allocation blocks are free and which are in use. It is similar to the Volume Bitmap in HFS, in which each allocation block is represented by one bit. A zero means the block is free and a one means the block is in use. The main difference with the HFS Volume Bitmap, is that the Allocation File is stored as a regular file, it does not occupy a special reserved space near the beginning of the volume. The Allocation File can also change size and does not have to be stored contiguously within a volume.
  4. The Catalog File is a B-tree that contains records for all the files and directories stored in the volume. The HFS Plus Catalog File is very similar to the HFS Catalog File, the main differences being records are larger to allow more fields and to allow for those fields to be larger (for example to allow the longer 255-character unicode file names in HFS Plus). A record in the HFS Catalog File is 512 bytes in size, a record in the HFS Plus Catalog File is 4 KB in Mac OS and 8 KB in OS X. Fields in HFS are of fixed size, in HFS Plus the size can vary depending on the actual size of the data they store.
  5. The Extents Overflow File is another B-tree that records the allocation blocks that are allocated to each file as extents. Each file record in the Catalog File is capable of recording eight extents for each fork of a file; once those are used additional extents are recorded in the Extents Overflow File. Bad blocks are also recorded as extents in the Extents Overflow File. The default size of an extent record in Mac OS is 1 KB and 4 KB in OS X.
  6. The Attributes File is a new B-tree in HFS Plus that does not have a corresponding structure in HFS. The Attributes File can store three different types of 4 KB records: Inline Data Attribute records, Fork Data Attribute records and Extension Attribute records. Inline Data Attribute records store small attributes that can fit within the record itself. Fork Data Attribute records contain references to a maximum of eight extents that can hold larger attributes. Extension Attributes are used to extend a Fork Data Attribute record when its eight extent records are already used.
  7. The Startup File is designed for non-Mac OS systems that don't have HFS or HFS Plus support. It is similar to the Boot Blocks of an HFS volume.
  8. The second to last sector contains the Alternate Volume Header equivalent to the Alternate Master Directory Block of HFS.
  9. The last sector in the volume is reserved for use by Apple. It is used during the computer manufacturing process.[1]

Other operating systems[edit]

Linux[edit]

The Linux kernel includes the hfsplus module[13] for mounting HFS+ filesystems read-write. HFS+ fsck and mkfs have been ported to Linux and are part of the hfsprogs package.[14]

In 2009, these drivers were diagnosed to be corrupting HFS+ drives with a capacity greater than 2 TB.[15] Consequently, Linux distributions such as Debian and Ubuntu also stopped allowing mounting of HFS+ drives or partitions greater than 2 TB.[16] As of February 2011, work is in progress to lift this restriction.[17]

Under Linux's current HFS+ driver, journaling must be disabled in order to write data safely to an HFS+ partition; journaling can be disabled under OS X,[18][19] provided the partition isn't being used by Apple's Time Machine software. An HFS+ partition with journaling enabled may be forcibly mounted with write-access under Linux, but this is unsupported and unwise.[19][20]

A Google Summer of Code project to implement write-support to journaled HFS+ [21] was accepted by the Linux Foundation in 2011 but was not completed at that time and is still a work in progress. Progress and improvements to the HFS+ driver, including some updates to journaling support, are posted on the linux-fsdevel mailing list [22] from time to time.

As of July 2011, Paragon Software Group provided kernel drivers that allow full read-write on HFS+ journaled volumes.[23] The product is proprietary implementation of HFS+ based on Paragon's proprietary UFSD library. There are both free and paid editions of the driver, and they include a utility for checking and repairing HFS+ volumes. According to the online documentation (free version [24] or the paid edition [25]), both the free edition and the paid edition currently support Linux kernels from 2.6.15 (on 2.6 kernel branch) as well as 3.0.x to 3.11.x (on 3.x kernel branch).

Windows[edit]

As of May 2012, Apple has only released read-only HFS+ drivers for Windows XP, Windows Vista, and Windows 7 as part of the Boot Camp software in OS X 10.6. This means users on these systems can read data on the HFS+ drive, but not write to them. (apple.com downloads bootcamp) Microsoft has created an HFS+ driver for the Xbox 360 mainly for the purpose of reading HFS+ formatted iPods.

A free (GPL) alternative is HFSExplorer written by Erik Larsson.[26] HFSExplorer is an application for viewing and extracting files from an HFS+ volume (Mac OS Extended) or an HFSX volume (Mac OS Extended, Case-sensitive) located either on a physical disk, on a .dmg disk image, or in a raw file system dump. However HFSExplorer can only read, but not write to HFS formatted volumes.

A free and opensource software – jHFSplus, based on HFSExplorer and jpfm – can be used to mount hfs/hfs+ partitions as read-only virtual folders.[27]

A freeware plugin for Total Commander exists, that can read, among others, HFS and HFS+ filesystems.[28]

A freeware DiskInternals Linux Reader, can be used to extract/save folders/files out of HFS and HFS+ Hard Drives/Partitions.

A commercial product, MacDrive, is also available for mounting HFS and HFS+ drives, optical discs, and other media in Windows Explorer, and allows both reading and writing to the volume, as well as repairing and formatting Mac disks.[29]

A commercial product, Paragon's HFS+ for Windows allows full read and write and disk management from all versions of Windows from Windows XP to Windows Server 2008. [30]

See also[edit]

References[edit]

  1. ^ a b c d e f g "Technical Note TN1150: HFS Plus Volume Format". Apple Developer Connection. March 5, 2004. Retrieved 2007-03-28. 
  2. ^ "OS X: Mac OS Extended format (HFS Plus) volume and file limits". Support.apple.com. 2008-07-29. Retrieved 2010-07-05. 
  3. ^ 10.6: Compress files with HFS+ compression - Mac OS X Hints
  4. ^ Boot Camp 3.0, Mac OS X 10.6: Frequently asked questions
  5. ^ "New Mac OS Extended Format (HFS+) Available". Apple Developer News. 1997. Retrieved 2007-03-28. 
  6. ^ "Technical Q&A QA1235: Converting to Precomposed Unicode". Apple Developer Connection. February 7, 2003. Retrieved 2007-03-28. 
  7. ^ there are some minor differences derived from the fact that the HFS Plus format was finalized before Unicode had standardized the NFD format (see “Unicode Subtleties” for more information)
  8. ^ John Gruber (November 11, 2002). "Crow". DaringFireball.net. Retrieved 2007-03-28. 
  9. ^ "Re: git on MacOSX and files with decomposed utf-8 file names". KernelTrap. 2010-05-07. Retrieved 2010-07-05. 
  10. ^ John Siracusa (April 28, 2005). "OS X 10.4 Tiger: Metadata revisited". Ars Technica. Retrieved 2007-03-28. 
  11. ^ "Apple - OS X Server - Windows Services". Apple.com. Archived from the original on 2007-12-31. Retrieved 2007-11-12. 
  12. ^ iohead LLC (2011). "fileXray user guide and reference". iohead LLC. p. 31. Retrieved 26 June 2013. 
  13. ^ Git Repository Kernel.org
  14. ^ User-space supporting tools for HFS+ filesystems under Posix systems.
  15. ^ http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=5c36fe3d87b3f0c85894a49193c66096a3d6b26f
  16. ^ #550010 - hfsplus corrupts filesystems >2TB - Debian Bug report logs
  17. ^ [PATCH 2/3] hfsplus: lift the 2TB size limit — Linux Filesystem Development
  18. ^ [1]
  19. ^ a b How to mount a HFS partition in Ubuntu as Read/Write? - Super User
  20. ^ Banks, Wyatt (2007-07-31), Macintosh HFSPlus Filesystem for Linux 
  21. ^ Implement HFSPlus Journal on Linux[dead link]
  22. ^ 'hfsplus' in linux-fsdevel - MARC
  23. ^ Paragon NTFS&HFS for Linux Express - Overview
  24. ^ Paragon NTFS&HFS for Linux Express - Full Features & System Requirements
  25. ^ Paragon NTFS&HFS for Linux Professional - Full features
  26. ^ "Catacombae - HFSExplorer". Erik Larsson. 2008-12-23. Retrieved 2010-12-19. 
  27. ^ "jHFSplus". Shashank Tulsyan. 2011-06-29. 
  28. ^ "DiskInternals Reader for Total Commander". DiskInternals. 2011-03-16. Retrieved 2011-11-23. 
  29. ^ "MacDrive 9 Standard". Mediafour. 2013-09-19. Retrieved 2013-09-19. 
  30. ^ http://www.paragon-software.com/home/hfs-windows/

External links[edit]

  • hfsexplorer - Open Source Explorer for MS-Windows® written in Java, with support for HFS, HFS+, and HFSX
  • Apple "legacy" Technote 1150 - HFS Plus Volume Format
  • Apple "legacy" Technote 1189 - The Monster Disk Driver Technote
  • hfsdebug - A debugger for HFS Plus volumes by Amit Singh
  • hfsprogs - Userspace support tools for HFS+ filesystems under Linux systems (adapted from Apple's native tools).
  • iBored - A disk editor and viewer supporting HFS Plus
  • MacDrive - A commercial product for reading, writing and creating HFS and HFS+ volumes in Windows
  • HFSleuth - A free command line tool allowing the inspection of HFS+/HFSX volumes and Disk Images (DMGs) for OS X and Linux