Macintosh HFS Filesystem for Linux¶
HFS stands for Hierarchical File System and is the filesystem used by the Mac Plus and all later Macintosh models. Earlier Macintosh models used MFS ( Macintosh File System ), which is not supported, MacOS 8.1 and newer support a filesystem called HFS+ that’s similar to HFS but is extended in various areas. Use the hfsplus filesystem driver to access such filesystems from Linux.
Mount options¶
When mounting an HFS filesystem, the following options are accepted:
creator=cccc, type=cccc
Specifies the creator/type values as shown by the MacOS finder used for creating new files. Default values: ‘. ‘.
uid=n, gid=n
Specifies the user/group that owns all files on the filesystems. Default: user/group id of the mounting process.
dir_umask=n, file_umask=n, umask=n
Specifies the umask used for all files , all directories or all files and directories. Defaults to the umask of the mounting process.
session=n
Select the CDROM session to mount as HFS filesystem. Defaults to leaving that decision to the CDROM driver. This option will fail with anything but a CDROM as underlying devices.
part=n
Select partition number n from the devices. Does only makes sense for CDROMS because they can’t be partitioned under Linux. For disk devices the generic partition parsing code does this for us. Defaults to not parsing the partition table at all.
quiet
Ignore invalid mount options instead of complaining.
Writing to HFS Filesystems¶
HFS is not a UNIX filesystem, thus it does not have the usual features you’d expect:
- You can’t modify the set-uid, set-gid, sticky or executable bits or the uid and gid of files.
- You can’t create hard- or symlinks, device files, sockets or FIFOs.
HFS does on the other have the concepts of multiple forks per file. These non-standard forks are represented as hidden additional files in the normal filesystems namespace which is kind of a cludge and makes the semantics for the a little strange:
- You can’t create, delete or rename resource forks of files or the Finder’s metadata.
- They are however created (with default values), deleted and renamed along with the corresponding data fork or directory.
- Copying files to a different filesystem will loose those attributes that are essential for MacOS to work.
Creating HFS filesystems¶
The hfsutils package from Robert Leslie contains a program called hformat that can be used to create HFS filesystem. See for details.
Credits¶
The HFS drivers was written by Paul H. Hargrovea (hargrove @ sccm . Stanford . EDU). Roman Zippel (roman @ ardistech . com) rewrote large parts of the code and brought in btree routines derived from Brad Boyer’s hfsplus driver.
Монтируем HFS+ в режиме записи
Mac OS форматирует накопители в файловую систему HFS+. В Debian, Ubuntu и Raspbian стандартные средства позволяют монтировать HFS+ разделы, но только в режиме read-only (только чтение). Для возможности записи необходимо установить несколько пакетов.
sudo apt-get install hfsplus hfsutils hfsprogs
Создадим точку монтирования для раздела.
Подключим раздел на накопителе для проверки.
sudo mount -o force /dev/sda2 /media/WD750
Если раздел всёже монтируется только в read-only или он был неправильно извлечён или повреждён, тогда нужно воспользоваться программой fsck.hfsplus .
Перед этим отмонтируем накопитель:
Теперь запустим программу восстановления:
** /dev/sda2 ** Checking HFS Plus volume. ** Checking Extents Overflow file. ** Checking Catalog file. ** Checking Catalog hierarchy. ** Checking Extended Attributes file. ** Checking volume bitmap. ** Checking volume information. ** The volume WD750 appears to be OK.
** /dev/sda2 ** Checking HFS Plus volume. fsck_hfs: Volume is journaled. No checking performed. fsck_hfs: Use the -f option to force checking.
Тогда нужно запустить программу с параметром -f :
sudo fsck.hfsplus -f /dev/sda2
Автоматическое монтирование
Узнаем UUID накопителя одним из двух способов.
1) Смотрим в /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 Jan 1 1970 02cdd893-43cc-3811-9e82-d02afb65f2ad -> ../../sda2
2) С помощью утилиты blkid
/dev/sda2: UUID="02cdd893-43cc-3811-9e82-d02afb65f2ad" LABEL="WD750" TYPE="hfsplus"
Добавим запись в fstab для автоматического монтирования:
# EXTERNAL HDD UUID="02cdd893-43cc-3811-9e82-d02afb65f2ad" /media/WD750 hfsplus defaults,force 0 0
Теперь имеется возможность не только чтения с накопителя отформатированного в HFS+, но и записи, а также автоматическое монтирование.
Если эта статья помогла вам, пожалуйста, оставьте комментарий
Если этот пост помог вам, и вы хотели бы показать свою поддержку, подумайте о том, чтобы заправить будущие посты, купив мне чашку кофе!
Arthur is a designer and full stack software engineer. He is the founder of Space X-Chimp and the blog My Cyber Universe. His personal website can be found at arthurgareginyan.com.
Macintosh HFS Filesystem for Linux¶
HFS stands for Hierarchical File System and is the filesystem used by the Mac Plus and all later Macintosh models. Earlier Macintosh models used MFS ( Macintosh File System ), which is not supported, MacOS 8.1 and newer support a filesystem called HFS+ that’s similar to HFS but is extended in various areas. Use the hfsplus filesystem driver to access such filesystems from Linux.
Mount options¶
When mounting an HFS filesystem, the following options are accepted:
creator=cccc, type=cccc
Specifies the creator/type values as shown by the MacOS finder used for creating new files. Default values: ‘. ‘.
uid=n, gid=n
Specifies the user/group that owns all files on the filesystems. Default: user/group id of the mounting process.
dir_umask=n, file_umask=n, umask=n
Specifies the umask used for all files , all directories or all files and directories. Defaults to the umask of the mounting process.
session=n
Select the CDROM session to mount as HFS filesystem. Defaults to leaving that decision to the CDROM driver. This option will fail with anything but a CDROM as underlying devices.
part=n
Select partition number n from the devices. Does only makes sense for CDROMS because they can’t be partitioned under Linux. For disk devices the generic partition parsing code does this for us. Defaults to not parsing the partition table at all.
quiet
Ignore invalid mount options instead of complaining.
Writing to HFS Filesystems¶
HFS is not a UNIX filesystem, thus it does not have the usual features you’d expect:
- You can’t modify the set-uid, set-gid, sticky or executable bits or the uid and gid of files.
- You can’t create hard- or symlinks, device files, sockets or FIFOs.
HFS does on the other have the concepts of multiple forks per file. These non-standard forks are represented as hidden additional files in the normal filesystems namespace which is kind of a cludge and makes the semantics for the a little strange:
- You can’t create, delete or rename resource forks of files or the Finder’s metadata.
- They are however created (with default values), deleted and renamed along with the corresponding data fork or directory.
- Copying files to a different filesystem will loose those attributes that are essential for MacOS to work.
Creating HFS filesystems¶
The hfsutils package from Robert Leslie contains a program called hformat that can be used to create HFS filesystem. See for details.
Credits¶
The HFS drivers was written by Paul H. Hargrovea (hargrove @ sccm . Stanford . EDU). Roman Zippel (roman @ ardistech . com) rewrote large parts of the code and brought in btree routines derived from Brad Boyer’s hfsplus driver.