# 12.4 Steam 客户端

Steam 没有原生 FreeBSD 客户端，其 Linux 版本可通过 FreeBSD Linux 兼容层运行。本节介绍 **games/linux-steam-utils** 的安装与配置方法。

## 基于 Port games/linux-steam-utils

### 加载 Linux 兼容层模块

该模块使 FreeBSD 系统能够执行 Linux 二进制文件，是运行 Steam 的前提条件。

启用并启动 Linux 兼容层服务：

```sh
# service linux enable   # 启用 Linux 兼容层服务，并设置为开机自启
# service linux start    # 启动 Linux 兼容层服务
```

### 安装 games/linux-steam-utils

该软件包是社区开发的第三方封装工具，提供了在 FreeBSD 上运行 Steam 的必要工具与配置脚本。

使用 pkg 安装：

```sh
# pkg install linux-steam-utils
```

使用 Ports 安装：

```sh
# cd /usr/ports/games/linux-steam-utils/
# make install clean
```

查看安装后的说明：

```sh
# pkg info -D linux-steam-utils
```

### 文件结构

```sh
/
├── bin/
│   └── sh # Steam 用户的默认 shell
├── etc/
│   └── sysctl.conf # 系统控制变量配置文件
└── usr/
    └── local/
        ├── steam-utils/
        │   └── bin/
        │       ├── lsu-bootstrap # Steam 引导程序下载工具
        │       └── steam # Steam 启动器
        └── wine-proton/
            └── bin/
                └── pkg32.sh # 32 位依赖安装脚本
```

### 配置 Port linux-steam-utils

配置过程涉及系统参数调整、用户账户创建等操作：

如果使用 NVIDIA 显卡，需安装适配的 Port **x11/linux-nvidia-libs（-xxx）**。

#### 设置 sysctl 变量

将 sysctl 系统控制变量 `security.bsd.unprivileged_chroot`、`vfs.usermount` 与 `compat.linux.use_real_ifnames` 设置为 `1`。前两个参数分别允许非特权用户使用 chroot 和挂载文件系统，Steam 需要这些权限来创建隔离环境和挂载必要的文件系统。`compat.linux.use_real_ifnames` 使 Linux 兼容层使用真实的网络接口名称，Steam 依赖此设置进行网络通信。

立即生效：

```sh
# sysctl security.bsd.unprivileged_chroot=1   # 允许非特权用户使用 chroot
# sysctl vfs.usermount=1                      # 允许普通用户挂载文件系统
# sysctl compat.linux.use_real_ifnames=1      # 使用真实网络接口名称
```

如果需要永久生效：编辑 **/etc/sysctl.conf** 文件，在文件最后一行换行，添加：

```sh
security.bsd.unprivileged_chroot=1   # 允许非特权用户使用 chroot
vfs.usermount=1                      # 允许普通用户挂载文件系统
compat.linux.use_real_ifnames=1      # 使用真实网络接口名称
```

#### 启用内核模块 nullfs

nullfs 是一种透传文件系统，用于创建文件系统的绑定挂载，Steam 借此组织文件系统结构。

立即加载 nullfs 内核模块：

```sh
# kldload nullfs
```

将 `nullfs` 添加到 `kld_list`，以实现开机自动加载：

```sh
# sysrc kld_list+="nullfs"
```

#### 为 Steam 创建专用用户账户

出于安全考量，建议为 Steam 创建专用用户账户。该用户不应属于 wheel 组，以限制其系统权限，否则启动 Steam 时会提示安全警告。

创建用户 test，指定默认 shell 为 **/bin/sh**，并创建用户主目录：

```sh
# pw useradd -n test -s /bin/sh -m
```

切换到 test 用户：

```sh
# su test
```

> **技巧**
>
> 在 test 用户权限下，输入 `exit` 退回之前的用户。

#### 下载 Steam 的引导可执行文件

启动 steam-utils 的 lsu-bootstrap 初始化程序，该程序负责下载 Steam 客户端的引导文件：

```sh
$ /usr/local/steam-utils/bin/lsu-bootstrap
```

#### 允许 test 用户访问 X11

Steam 是图形化应用程序，需访问 X Server 以显示界面。在当前登录桌面的用户权限下执行以下命令，允许本地用户 test 访问当前的 X Server：

```sh
$ xhost +SI:localuser:test
```

### 启动 Steam

切换到 test 用户：

```sh
# su test
```

启动 Steam 客户端：

```sh
$ /usr/local/steam-utils/bin/steam
```

输入用户名和密码登录：

![Steam in FreeBSD](/files/OPZ293meG6ccF5VAsGsm)

加载中：

![Steam in FreeBSD](/files/AODYFbkVCb66JsD3Mpa8)

设置中文界面：

![Steam in FreeBSD](/files/MR3FOPfS37ycc0VYZOr2)

Steam：

![Steam in FreeBSD](/files/z8aJhzfFBAZqms4LEh7A)

### 测试游戏 Beholder 的运行情况

本节以游戏 Beholder 为例测试 Steam 的运行情况。

> **注意**
>
> Beholder 是付费游戏，需要购买后才能体验。

下载 Beholder：

![Beholder in FreeBSD](/files/H9cIj1A0iWjXLlvpjq6k)

启动 Beholder：

![Beholder in FreeBSD](/files/ML3wOBATMY06wU3qNiXu)

![Beholder in FreeBSD](/files/Id1aOETtV6xwFxCUM1Go)

### 故障排除

本节介绍常见问题的解决方法。

#### `Bubblewrap doesn't work on FreeBSD. Select LSU chroot or Legacy Runtime in the game compatibility settings.`

该错误表明 Steam 的容器运行时（pressure-vessel）在 FreeBSD 上不兼容，需要选择兼容的运行时环境。

右键单击游戏，点击属性，在兼容性选项卡中，勾选“强制使用特定 Steam Play 兼容性工具”，选择“Legacy Runtime 1.0”。

#### 无中文字体显示

该问题可通过安装中文字体解决，推荐安装 `wqy-fonts` 或 `noto-sans-sc`（简体中文）等字体包。

## 参考文献

* shkhln. linuxulator-steam-utils\[EB/OL]. \[2026-04-17]. <https://github.com/shkhln/linuxulator-steam-utils>. FreeBSD 上运行 Steam 客户端的社区适配工具，提供引导脚本和兼容性配置。


---

# 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-12-zhang-you-xi-ke-xue-ji-suan-he-zhuan-ye-gong-ju/di-12.4-jie-steam-ke-hu-duan.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.
