如何在 nixos 来宾系统中缩小 VirtualBox 虚拟机并释放磁盘 Space?

How to Shrink a VirtualBox Virtual Machine and Free Up Disk Space in nixos guest system?

我正在关注此 instruction 以尝试缩小我的虚拟 nixos。 它说,

You can’t actually use zerofree on your / partition while you’re booted into the standard Linux environment. Instead, you’ll want to boot into a special recovery mode where your normal root partition isn’t mounted.

但是我在 nixos 中找不到启动进入恢复模式的地方。 问题:如何引导进入我的根分区未安装在 nixos 中的某种模式?或者如何在 nixos 中执行 zerofree?

NixOS 没有使用备用根文件系统的恢复模式。您可以通过将 boot.loader.grub.extraEntries 添加到您的 configuration.nix 来向您的引导加载程序添加额外的条目来自己完成。 这样,您可以启动到另一个分区。您将需要在该分区上准备额外的安装。但考虑到它是一个虚拟机,可能有更好的选择:

您可以将已停止的 VM 的根文件系统附加到具有自己的带有 zerofree 的 rootfs 的 VM。这样,您就不必为额外的分区而烦恼了。