Skip to content

Disaster Recovery

Emily edited this page Mar 6, 2024 · 8 revisions

Restoring a Failed Build

If shit hits the fan and the server is not responding to pings, there is little left to do. As you won't be able to rebuild the messed up configuration without ssh, so you will have to fire up the rescue console.

Once booted into the live system, it is best to enter a NixOS via the kexec method described in the ReadMe.

To restore your system you have two options:

  1. Boot a previous version of the system with grub-reboot
  2. Mount the system and use nixos-enter to chroot into the system and rebuild the config to your liking.

Booting into a previous version of the system

  1. mkdir /boot
  2. zpool import bpool
  3. mount -t zfs bpool/nixos/root /boot
  4. Find a Grub Entry by checking the /boot/grub/grub.cfg file for menuentry
  5. grub-reboot "<menuentry>"
  6. reboot

Mounting the existing system

  1. If you are using an encrypted root, decrypt every drive in the rpool: cryptsetup luksOpen /dev/disk/by-id/<name>-part3 luks-rpool-<name>-part3
  2. Import all pools: zpool import -a
  3. Check that all pool have been successfully imported by executing zpool list
  4. Mount all volumes according to NixDotfiles/modules/boot/default.nix (zfs-root.fileSystems.datasets):
mount -t zfs rpool/nixos/root /mnt
mount -t zfs bpool/nixos/root /mnt/boot
mount -t zfs rpool/nixos/home /mnt/home
mount -t zfs rpool/nixos/var/lib /mnt/var/lib
mount -t zfs rpool/nixos/var/log /mnt/var/log
  1. nixos-enter
  2. Edit the configuration to your liking
  3. Rebuild the system by executing nixos-rebuild switch --flake .#ruwusch with in the NixDotfiles directory.
Clone this wiki locally