在macOSCatalina和BigSur上在没有T2芯片的Mac上的FileVault加密启动卷上安装Nix时出错

我运行以下命令在我的 Mac 上安装 Nix:

sh <(curl -L https://nixos.org/nix/install) --daemon --darwin-use-unencrypted-nix-store-volume

我收到以下错误:

error: refusing to create Nix store volume because the boot volume is
       FileVault encrypted, but encryption-at-rest is not available.
       Manually create a volume for the store and re-run this script.
       See https://nixos.org/nix/manual/#sect-macos-installation

https://nixos.org/nix/manual/#sect-macos-installation说:

如果您使用的是带有T2 芯片的最新 Mac ,您的驱动器仍会在静止状态下加密(在这种情况下,“未加密”有点用词不当)。要使用这种方法,只需安装 Nix:

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

如果您不喜欢这样的声音,您将需要权衡本节中详述的其他方法和权衡。

我没有带 T2 芯片的 Mac,我该怎么办?

我发现了一些相关的github 问题,但没有直接答案。

回答

我选择使用Philipp Haussleiter概述的使用单独的加密卷建议:

此方法仅适用于使用 APFS 格式化的磁盘(如果您的操作系统运行的是 SSD,则应始终如此)。

您可以通过以下方式检查:

% diskutil list | grep APFS

…
0:      APFS Container Scheme -                      +250.8 GB   disk1
…

在磁盘上为 NIX 创建另一个卷:

% sudo diskutil apfs addVolume disk1 'APFS' nix
Will export new APFS Volume "nix" from APFS Container Reference disk1
Started APFS operation on disk1
Preparing to add APFS Volume to APFS Container disk1
Creating APFS Volume
Created new APFS Volume disk1s6
Mounting APFS Volume
Setting volume permissions
Disk from APFS operation: disk1s6
Finished APFS operation on disk1

您的磁盘可能没有命名disk1s6。使用以下命令查找磁盘名称:

% diskutil list | grep nix
4:                APFS Volume nix                      7.7 GB    disk1s6

同样,您的磁盘可能未命名为disk1s6

加密磁盘:

您需要输入密码进行加密。您必须记住该密码短语 - 您可以稍后将其添加到您的钥匙串中。之后磁盘加密将在后台启动。

% sudo diskutil apfs encryptvolume disk1s6 -user disk
Passphrase for the new "Disk" user (672C4CFF-34C6-4407-83ED-294C1C42E161):
Repeat passphrase:
Starting background encryption with the new "Disk" crypto user on disk1s6
The new "Disk" user will be the only one who has initial access to disk1s6
The new APFS crypto user UUID will be 672C4CFF-34C6-4407-83ED-294C1C42E161
Background encryption is ongoing; see "diskutil apfs list" to see progress

设置挂载点:

MacOS Catalina 不允许直接在您的 Root Path 下创建文件夹/。但是我们可以使用另一种方法让 MacOS 为我们创建该文件夹。为此,我们必须在文件中添加一个条目
/etc/synthetic.conf

% sudo bash -c 'echo nix >> /etc/synthetic.conf'

现在,下次系统启动时,将创建一个挂载点 /nix。下一个任务是在启动时安装我们的卷。

安装安装:

对于挂载配置,我们需要卷的 UUID。我们可以通过该diskutil工具找到它(同样,您的磁盘可能未命名
disk1s6):

% diskutil info /dev/disk1s6 | grep UUID

我们必须使用 vifs 编辑 /etc/fstab:

% sudo vifs

(vifs 的行为就像 vi,所以使用 vi 命令来编辑文件):

UUID=1D9389C1-5676-4077-88F5-8D5304A0B1A6 /nix apfs  rw

(您的 UUID 会有所不同!)

重启。您将收到一个 GUI 提示,要求您输入加密密码,并将其保存到钥匙串中。

然后我跑了:

sh <(curl -L https://nixos.org/nix/install) --daemon

--darwin-use-unencrypted-nix-store-volume选项不是必需的,因为我们现在有一个加密卷。


以上是在macOSCatalina和BigSur上在没有T2芯片的Mac上的FileVault加密启动卷上安装Nix时出错的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>