> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/di-26-zhang-qi-ta-wen-jian-xi-tong/di-26.3-jie-macos-wen-jian-xi-tong.md).

# 26.3 macOS 文件系统

FreeBSD 提供了对 macOS 文件系统的支持，包括 HFS/HFS+、APFS，可用于访问为 Apple 系统格式化的存储设备。

## APFS 文件系统

Apple 文件系统（APFS）是 Apple 开发的新一代文件系统，自 macOS High Sierra 起成为 macOS 的默认文件系统。在 FreeBSD 上，可通过 `libfsapfs` 实现对 APFS 分区的只读访问。

### 安装 libfsapfs

使用 pkg 安装 libfsapfs 软件包：

```sh
# pkg install libfsapfs
```

使用 Ports 安装：

```sh
# cd /usr/ports/filesystems/libfsapfs/
# make install clean
```

### 加载 fusefs 内核模块

在使用 FUSE 文件系统前，需加载 fusefs(4) 内核模块：

```sh
# kldload fusefs
```

使用 sysrc(8) 设置开机自动加载该模块：

```sh
# sysrc kld_list+=fusefs
```

### 识别 APFS 卷

将包含 APFS 卷的磁盘连接到计算机后，可使用 `gpart` 查看分区信息。APFS 卷通常显示为 `apple-apfs` 类型：

```sh
# gpart show -p nda1
=>    34  195286    nda1  GPT  (95M)
      34       6          - free -  (3K)
      40  195280  nda1p1  apple-apfs  (95M)
```

可以使用 `file` 命令更精确地判断文件系统类型：

```sh
# file -s /dev/nda1p1
/dev/nda1p1: Apple File System (APFS), blocksize 4096
```

### 挂载 APFS 卷

使用 `libfsapfs` 挂载 APFS 卷。将 APFS 卷 **/dev/nda1p1** 挂载到 **/mnt**：

```sh
# fsapfsmount /dev/nda1p1 /mnt
```

验证挂载情况并查看内容：

```sh
# ls /mnt/
/mnt/.DS_Store      /mnt/.Trashes/      /mnt/evidence.json  /mnt/README.md
/mnt/.fseventsd/    /mnt/container/     /mnt/image/
```

> **注意**
>
> 当前 `libfsapfs` 仅提供只读支持，无法进行写入操作。

## HFS/HFS+ 文件系统

> **注意**
>
> HFS/HFS+ 是 macOS 在 APFS 问世前的主要文件系统。自 macOS High Sierra（2017）起，APFS 已取代 HFS+ 成为默认文件系统；自 macOS Catalina 起，系统卷必须使用 APFS。HFS+ 现仅存在于老旧 Mac 设备和以 HFS+ 格式化的外置存储中，仅适用于需要访问此类老旧存储的场景。

FreeBSD 通过 filesystems/hfsfuse 软件包提供对 HFS/HFS+ 的只读支持。

要在 FreeBSD 上使用 HFS/HFS+，需安装 **filesystems/hfsfuse** 软件包，加载 FUSE 内核模块，并按如下方式挂载文件系统：

### 安装 HFS/HFS+ 软件包

使用 pkg 安装：

```sh
# pkg install fusefs-hfsfuse
```

使用 Ports 安装：

```sh
# cd /usr/ports/filesystems/hfsfuse/
# make install clean
```

### 加载 fusefs 内核模块

在使用 FUSE 文件系统前，需加载 fusefs(4) 内核模块：

```sh
# kldload fusefs
```

使用 sysrc(8) 设置开机自动加载该模块：

```sh
# sysrc kld_list+=fusefs
```

### 识别 HFS/HFS+ 卷

可以使用 `file` 命令判断文件系统类型：

```sh
# file -s /dev/ada0
/dev/ada0: Apple HFS Plus version 4 data (mounted) last mounted by: 'HFSJ', created: Thu Jan 29 17:33:30 2009, last modified: Thu Jan 29 17:33:36 2009, last checked: Thu Jan 29 17:33:30 2009, block size: 4096, number of blocks: 2560, free blocks: 444
```

### 挂载 HFS/HFS+ 卷

通过指定其 FreeBSD 分区名和挂载点（需已存在）来挂载 HFS/HFS+ 卷。以下示例将 **/dev/ada0** 挂载到 **/mnt**：

```sh
# hfsfuse /dev/ada0 /mnt
```

验证挂载情况

```sh
# mount
/dev/ada0 on /mnt (fusefs.hfs, read-only)

……省略无关输出……

# df -hl
/dev/ada0       10M    8.3M    1.7M    83%    /mnt
```

查看内容：

```sh
# ls /mnt
.Trashes	.fseventsd	file1.txt	file2.txt
# cat file1.txt
This is file 1 - snarf
```

> **注意**
>
> 当前 `fusefs-hfsfuse` 仅提供只读支持，无法进行写入操作，且目前无写入支持计划。

## 参考文献

* Apple. Apple File System Reference\[EB/OL]. \[2026-03-25]. <https://developer.apple.com/support/downloads/Apple-File-System-Reference.pdf>. Apple 官方 APFS 技术文档。
* FreeBSD Forums. Mounting APFS partition\[EB/OL]. \[2026-03-25]. <https://forums.freebsd.org/threads/mounting-apfs-partition.69094/>. FreeBSD 论坛关于 APFS 挂载支持的讨论。
* libfsapfs Project. GitHub Repository\[EB/OL]. \[2026-03-25]. <https://github.com/libyal/libfsapfs>. libfsapfs 开源项目仓库。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/di-26-zhang-qi-ta-wen-jian-xi-tong/di-26.3-jie-macos-wen-jian-xi-tong.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
