Issue
I was following this instruction to try to shrink my virtual nixos. It says,
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.
But I can't find a place to boot into recovery mode in nixos. Question: How to boot into some mode where my root partiion isn't mounted in nixos? Or how do I do zerofree in nixos?
Solution
NixOS does not have a recovery mode that uses an alternative root filesystem. You can do it yourself by adding extra entries to your bootloader by adding boot.loader.grub.extraEntries to your configuration.nix
.
This way, you can boot into an another partition. You will need to prepare an extra installation on that partition. But considering that it's a VM there's probably a better option:
You may be able to attach the root filesystem of your stopped VM to a VM that has its own rootfs with zerofree on it. This way, you won't have to muck about with extra partitions.
Answered By - Robert Hensing Answer Checked By - Candace Johnson (WPSolving Volunteer)