-
Notifications
You must be signed in to change notification settings - Fork 0
Disaster Recovery
Emily edited this page Mar 6, 2024
·
8 revisions
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:
- Boot a previous version of the system with
grub-reboot
- Mount the system and use
nixos-enter
tochroot
into the system and rebuild the config to your liking.
mkdir /boot
zpool import bpool
mount -t zfs bpool/nixos/root /boot
- Find a Grub Entry by checking the
/boot/grub/grub.cfg
file formenuentry
grub-reboot "<menuentry>"
zpool export -a
reboot
- 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
- Import all pools:
zpool import -a
- Check that all pool have been successfully imported by executing
zpool list
- 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
nixos-enter
- Edit the configuration to your liking
- Rebuild the system by executing
nixos-rebuild switch --flake .#<hostname>
while in theNixDotfiles
The rebuilding might fail with an error such as
'/nix/store/gz9kldhk94fkzrirjxr0rq0vafxh37nd-system-path/bin/busctl --json=short call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager ListUnitsByPatterns asas 0 0' exited with value 1
In that case exit the chroot
with Ctrl+D
and do the following:
- Backup the
/run
dir:cp -r /run /run.bak
mount -o bind /run /mnt/run
nixos-enter
-
nixos-rebuild switch --flake .#<hostname>
while in theNixDotfiles
- A lot of errors will arise. The rebuilding will still have happened, but its not "clean".
- Exit the
chroot
withCtrl+D
/run.bak/current-system/sw/bin/zpool export -a
/run.bak/current-system/sw/bin/reboot