.docs/recovery.md
Docs/recovery.md

Recovery

Procedures for diagnosing failed installations, repairing unbootable hosts, recovering failing dm-cache SSDs, and re-enrolling nodes.

Live installer debugging

Switch to tty2 on the live ISO (Alt+F2) for an unauthenticated local root shell (console access only):

journalctl -u monarch-installer
cat /run/monarch/access-code
cat /run/monarch/install.log
systemctl restart monarch-installer   # generates a new access code

Useful disk and SMART diagnostics:

lsblk
lvs -a
smartctl -a /dev/sdX

If an install fails partway through, the browser displays the error and log output. Fix the underlying issue, return to the Review step, and run Install again — the installer unmounts and deactivates partially written volumes automatically before re-running.

Repairing an unbootable system

  1. Boot the Monarch.linux ISO and switch to tty2 (Alt+F2).
  2. Activate any LVM volumes (vgchange -ay if needed) and mount the root and EFI partitions (adjust partition numbers for your disk layout):
mount /dev/<disk>3 /mnt
mount /dev/<disk>2 /mnt/boot/efi
arch-chroot /mnt
  1. Reinstall GRUB for UEFI (including removable fallback) and/or BIOS, then regenerate grub.cfg:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable
grub-install --target=i386-pc /dev/<disk>
grub-mkconfig -o /boot/grub/grub.cfg

Data volumes live at /dev/vg_<name>/data; run vgchange -ay before mounting them manually. The installer log on an installed system is preserved at /var/log/monarch-install.log.

Replacing a failing cache SSD

When monarch-cache-guard detects a failing SSD:

  1. If the cache was in writeback mode, the guard switches it to writethrough (lvchange -y --cachemode writethrough <vg/lv>) so LVM flushes dirty blocks to the origin HDDs.
  2. Check the status in Monarch.panel under the node's Storage tab, or via journalctl -t monarch-cache-guard.
  3. Detach the cache from the Storage tab in the panel, or on the host:
lvconvert --uncache vg_<name>/data
  1. Power down if needed, swap the physical SSD, and attach a new cache partition from the Storage tab.

Re-enrolling or leaving a panel

If a node was removed from Monarch.panel, its ECDSA public key is revoked immediately and reconnects are rejected. To clean up or re-enroll:

sudo monarch-daemon leave
sudo monarch-daemon join https://panel.example:4382 ccj_... --fingerprint <sha256>

If monarch-firstboot.service failed to join Netmaker or a remote panel on first boot, the original tokens stay root-only under /etc/monarch/netclient-token and /etc/monarch/join/:

sudo netclient join -t "$(sudo cat /etc/monarch/netclient-token)"
sudo monarch-daemon join "$(sudo cat /etc/monarch/join/url)" "$(sudo cat /etc/monarch/join/token)" --fingerprint "$(sudo cat /etc/monarch/join/fingerprint)"