# 3.5 基于 Apple M1 和 UTM 安装 FreeBSD

## 概述

UTM 是基于 QEMU 的开源虚拟机软件，面向 Apple 设备，支持 ARM 与 x86 架构。在 M1（aarch64）设备上建议使用 aarch64 版 UTM 以获得最佳性能，本节给出安装 FreeBSD 的完整步骤。

UTM 官方网站为 <https://getutm.app>。

UTM（逆构词为 Universal Turing Machine）是开源、基于 QEMU、面向 Apple 设备的虚拟机软件，支持 ARM 和 x86 架构虚拟机。建议下载 aarch64（arm64）架构版本。除非有特殊需求，不建议使用 amd64（x86-64）版本。运行相同架构的虚拟机可获得更高性能和更流畅的系统体验（M1 为 aarch64 架构）。

因需向 Apple 缴纳年费以获取开发者资格，开发成本较高，故 UTM 在 App Store 中为收费软件。可在 [GitHub 项目，utmapp/UTM](https://github.com/utmapp/UTM/releases) 中免费获取 UTM。

## 安装说明

首先下载 FreeBSD 的安装镜像。

出于性能考虑，此处以 aarch64 镜像为例。

![下载安装镜像](/files/Fl0N2lk3eVID1yYKURtj)

接下来新建一个虚拟机，点击窗口上的加号 `+`。

![新建虚拟机](/files/HTYI7khTVFGxMNCZbyOq)

如果下载的是 aarch64 的镜像，选择“虚拟化”；如果是 amd64 的镜像，选择“模拟”。

![选择虚拟化类型](/files/eEhEDTkXRtLAgzGBVjj9)

操作系统选择“其他”。

![选择操作系统](/files/Q5l23EslaNWyYqTToJhs)

默认 4 GB 内存能适应大多数情况，初始状态 FreeBSD 15 约占用 500 MB 内存，可根据实际需求调整内存大小。CPU 核心按需设置，M1 芯片可以设置为 4。

![设置内存和处理器核心数量](/files/gy0YJFkhlJVSplJJCTKy)

启动设备选择 CD/DVD 映像，选择“浏览”按钮以选定已下载的安装镜像。

![设置启动设备](/files/H32oyVNdLCD0GnShCQl5)

存储空间默认 64 GB，初始状态的 FreeBSD 会占用约 5 GB 空间，可根据需求调整。

![设置存储空间](/files/Az55XfLZEaambTGvQUap)

共享目录可以暂时跳过。

![跳过共享目录](/files/OhoqSSf3RfywFJZshoFK)

以上步骤设置完成后，点击“存储”。如需进一步设置，可以勾选“打开虚拟机设置”，或者在保存后点击右上角的设置按钮打开配置界面。

![完成设置](/files/e7VT88ywIiYXfPk7zViS)

点击播放按钮启动虚拟机。

![启动虚拟机](/files/5ZwPzjNPjm6yChBs58ve)

![虚拟机启动界面](/files/nt67ORXd801spDMfLuSG)

启动 FreeBSD 安装镜像，按回车键可以跳过启动菜单等待时间。

![系统引导界面](/files/paiKvpBhztu0oJpGMyto)

进入安装程序，鼠标默认可用。按下 Control + Option 快捷键可捕获鼠标光标，再次按下此快捷键可释放鼠标。

![安装程序界面](/files/fVO2btGJ2kqAOqUDm4oq)

基本系统安装完成，终端能正常运行。在虚拟机内执行 `ifconfig` 命令查看 IP 地址后，便可在宿主机的终端仿真器中发起 SSH 连接。

![终端](/files/0dWrhCd5fuJINUZexHWb)

![SSH](/files/BpH9k1UuzSnJheEOkR6q)

## 故障排除与未竟事宜

### Xorg 不可用

直接启动 Xorg 默认的窗口管理器 TWM 会报错，输出内容如下：

```sh
voosk@BSDVM:~ $ startx
xauth:  file /home/voosk/.serverauth.3074 does not exist


X.Org X Server 1.21.1.20
X Protocol Version 11, Revision 0
Current Operating System: FreeBSD BSDVM 15.0-RELEASE FreeBSD 15.0-RELEASE releng/15.0-n280995-7aedc8de6446 GENERIC arm64

Current version of pixman: 0.46.2
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Fri Feb 27 10:59:53 2026
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
scfb trace: probe start
scfb trace: probe done
scfb: PreInit 0
scfb: PreInit done
scfb: ScfbScreenInit 0
	bitsPerPixel=32, depth=24, defaultVisual=TrueColor
	mask: ff0000,ff00,ff, offset: 16,8,0
mmap returns: addr 0x0 len 0x3e8000, fd 12, off 0
(EE)
Fatal server error:
(EE) AddScreen/ScreenInit failed for driver 0
(EE)
(EE)
Please consult the The X.Org Foundation support
	 at http://wiki.x.org
 for help.
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
voosk@BSDVM:~ $
```

在 **/boot/loader.conf** 文件中加入下面两行可启动 TWM，但虚拟机将失去画面输出（SSH 仍可连接，说明这仅为显示问题）。

```sh
hint.virtio_gpu.0.disabled="1"
hint.vtgpu.0.disabled="1"
```

重启后 startx 能够正常启动 TWM，输出如下：

```sh
voosk@BSDVM:~ $ startx
xauth:  file /home/voosk/.serverauth.3072 does not exist


X.Org X Server 1.21.1.20
X Protocol Version 11, Revision 0
Current Operating System: FreeBSD BSDVM 15.0-RELEASE FreeBSD 15.0-RELEASE releng/15.0-n280995-7aedc8de6446 GENERIC arm64

Current version of pixman: 0.46.2
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Fri Feb 27 11:16:38 2026
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
scfb trace: probe start
scfb trace: probe done
scfb: PreInit 0
scfb: PreInit done
scfb: ScfbScreenInit 0
	bitsPerPixel=32, depth=24, defaultVisual=TrueColor
	mask: ff0000,ff00,ff, offset: 16,8,0
mmap returns: addr 0xe4d20000 len 0x1d5000, fd 12, off 0
scfb: ScfbSave 0
scfb: ScfbSave done
scfb: ScfbScreenInit done
scfb: SaveScreen 0
scfb: SaveScreen done
twm: created fontset with 10 fonts (7 missing) for "-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*"
twm: created fontset with 10 fonts (7 missing) for "-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*"
twm: created fontset with 10 fonts (7 missing) for "-adobe-helvetica-bold-r-normal--*-100-*-*-*-*-*-*"
twm: created fontset with 10 fonts (7 missing) for "-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*"
twm: created fontset with 10 fonts (7 missing) for "-adobe-helvetica-bold-r-normal--*-100-*-*-*"
twm: created fontset with 2 fonts (15 missing) for "fixed"
```

虚拟机无画面输出，显示 Display output is not active.

![虚拟机看不到画面](/files/BL9WNEchPErYRgD5O3nk)

## 参考文献

* utmapp. UTM — Virtual machines for macOS\[EB/OL]. \[2026-04-17]. <https://github.com/utmapp/UTM>. UTM 项目主页。


---

# Agent Instructions: 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:

```
GET https://book.bsdcn.org/di-3-zhang-freebsd-gao-ji-an-zhuang/di-3.5-jie-ji-yu-apple-m1-he-utm-an-zhuang-freebsd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
