Using snapshot zfs on nixos

Hi all, I have setted my nixos with zfs as fs and zrepl for taking snapshot. But, on nixos what if if I restored old snapshot? On other distros I don’t have doubt, but on nixos with generations I don’t understand

Use snapshots for your data, not for the nix store (`/nix’). As long as you have your nix configuration, you can rebuild the store even if it’s gone.

1 Like

So, with nixos, snapshots are useless

well, generations just serve a very similar purpose to snapshots, in terms of the OS. So you just don’t really need snapshots for the OS. Snapshots are still incredibly useful and valuable for data, like /home and /var.

5 Likes

A friend just managed to shot down his audio setup, and we fiddled around for hours, trying to restore it.

So long as you dont backup or snapshot your config files as well, will you have no way of restoring from such issues, purely by rolling back packages.

File system rollbacks operate on a more general level, and are preferable to me.

If generations fail, the file system will cover it up.

1 Like

So, I’m thinking on nixos can’t I choose to mount boot folder inside root, and on /boot/efi only esp partition?

I don’t understand the question.

A few week ago, I had try to rollback one snapshot and after system didn’t go, blocking after stage 2. Now I’m thinking that I had have this because kernel on snapshot was different respect kernel inside boot partition, I believe

1 Like

No, that’s not really how that works. If you’re using systemd-boot (and if you’re on an EFI system, you probably are using systemd-boot), then NixOS sets up a boot loader entry for every generation on the ESP. This means a boot menu entry, and the necessary kernel and initrd. That boot entry will tell NixOS what the /nix/store path is for the generation the entry represents, and then that store path is selected for stage 2.

If you rolled back too far and lost the generation’s /nix/store path, then the system will fail to make it to stage 2. You have to boot an older generation, for which there are hopefully boot loader entries on your ESP.

Boot entries are dependent on their generations still existing in the nix store. There is simply no way around this. If you rollback and erase these paths, those boot entries are dead.

1 Like