commit f223d76cbf44326889de363108024e331f568f46 Author: Per Magnus Petersen Date: Fri Mar 6 15:51:09 2026 +0100 Initial commit: NAS backup, NFS mount docs, NVMe fix docs Co-Authored-By: Claude Opus 4.6 diff --git a/README.md b/README.md new file mode 100644 index 0000000..d8ed6dc --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# System + +Scripts and documentation for system administration tasks. + +## NAS Backup + +`nas-backup.sh` — rsyncs `/data/backup/` (gitea + postgres) to the NFS-mounted NAS at `/mnt/nas/backup/` every 15 minutes. + +- **Timer**: `~/.config/systemd/user/nas-backup.timer` +- **Service**: `~/.config/systemd/user/nas-backup.service` +- **Sudoers**: `/etc/sudoers.d/nas-backup` (passwordless rsync) + +```bash +# Check status +systemctl --user status nas-backup.timer +systemctl --user list-timers nas-backup.timer + +# Run manually +systemctl --user start nas-backup.service + +# View logs +journalctl --user -u nas-backup.service +``` + +## NFS NAS Mount + +`nfs-nas-mount.md` — NAS connection details and mount configuration for `nas.local.pmagnus.dk:/omarchy` at `/mnt/nas`. + +## NVMe Freeze Fix + +`nvme-fix-plan.md` — Fix for Kingston SNV2S2000G freezes caused by NVMe deep power state transitions. Applied via `nvme_core.default_ps_max_latency_us=5000` kernel parameter. diff --git a/config/elephant.service b/config/elephant.service new file mode 100755 index 0000000..f2a0dad --- /dev/null +++ b/config/elephant.service @@ -0,0 +1,13 @@ + +[Unit] +Description=Elephant +After=graphical-session.target + +[Service] +Type=simple +ExecStart=elephant +Restart=on-failure + +[Install] +WantedBy=graphical-session.target + \ No newline at end of file diff --git a/config/fetch-mail.service b/config/fetch-mail.service new file mode 100644 index 0000000..8634b96 --- /dev/null +++ b/config/fetch-mail.service @@ -0,0 +1,6 @@ +[Unit] +Description=Fetch Medium Daily Digest emails + +[Service] +Type=oneshot +ExecStart=/home/pmp/ai/medium/fetch-mail.sh diff --git a/config/fetch-mail.timer b/config/fetch-mail.timer new file mode 100644 index 0000000..b932d22 --- /dev/null +++ b/config/fetch-mail.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Fetch Medium emails daily at 6:30 + +[Timer] +OnCalendar=*-*-* 06:30:00 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/config/nas-backup.service b/config/nas-backup.service new file mode 100644 index 0000000..5d56f44 --- /dev/null +++ b/config/nas-backup.service @@ -0,0 +1,6 @@ +[Unit] +Description=Rsync backup to NAS + +[Service] +Type=oneshot +ExecStart=/home/pmp/ai/system/nas-backup.sh diff --git a/config/nas-backup.timer b/config/nas-backup.timer new file mode 100644 index 0000000..e292a51 --- /dev/null +++ b/config/nas-backup.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Rsync backup to NAS every 15 minutes + +[Timer] +OnCalendar=*:0/15 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/config/omarchy-battery-monitor.service b/config/omarchy-battery-monitor.service new file mode 100644 index 0000000..6e2e8e9 --- /dev/null +++ b/config/omarchy-battery-monitor.service @@ -0,0 +1,9 @@ +[Unit] +Description=Omarchy Battery Monitor Check +After=graphical-session.target + +[Service] +Type=oneshot +ExecStart=%h/.local/share/omarchy/bin/omarchy-battery-monitor +Environment=DISPLAY=:0 +LogLevelMax=warning diff --git a/config/omarchy-battery-monitor.timer b/config/omarchy-battery-monitor.timer new file mode 100644 index 0000000..dc43763 --- /dev/null +++ b/config/omarchy-battery-monitor.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Omarchy Battery Monitor Timer +Requires=omarchy-battery-monitor.service + +[Timer] +OnBootSec=1min +OnUnitActiveSec=30sec +AccuracySec=10sec + +[Install] +WantedBy=timers.target \ No newline at end of file diff --git a/nas-backup.sh b/nas-backup.sh new file mode 100755 index 0000000..3982603 --- /dev/null +++ b/nas-backup.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -euo pipefail + +SRC="/data/backup/" +DEST="/mnt/nas/backup/" + +# Ensure NAS is mounted +if ! mountpoint -q /mnt/nas; then + echo "NAS not mounted at /mnt/nas, skipping backup" >&2 + exit 1 +fi + +mkdir -p "$DEST" +sudo rsync -a --delete --no-group --no-perms --no-owner "$SRC" "$DEST" diff --git a/nfs-nas-mount.md b/nfs-nas-mount.md new file mode 100644 index 0000000..0d4a5cc --- /dev/null +++ b/nfs-nas-mount.md @@ -0,0 +1,34 @@ +# NFS NAS Mount + +## NAS Details +- **Hostname**: `nas.local.pmagnus.dk` +- **IP**: `192.168.50.112` +- **Protocol**: NFSv4.1 + +## Available NFS Exports +All exports are accessible from `192.168.50.0/24`: +- `/vol01`, `/vm`, `/umbrel`, `/pve`, `/omarchy`, `/k8s`, `/docker`, `/Dev1Partition1`, `/data`, `/citadel`, `/btcdata` + +## Current Mount +- **Source**: `nas.local.pmagnus.dk:/omarchy` +- **Mount point**: `/mnt/nas` +- **Options**: `rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,hard,proto=tcp` +- **Size**: 7.1T total, 127G used (2%) +- **Contents**: `backup/`, `@Recycle/` + +## Useful Commands +```bash +# Show NAS exports +showmount -e nas.local.pmagnus.dk + +# Mount +sudo mount -t nfs nas.local.pmagnus.dk:/omarchy /mnt/nas + +# Persistent mount (add to /etc/fstab) +nas.local.pmagnus.dk:/omarchy /mnt/nas nfs defaults,_netdev 0 0 +``` + +## Notes +- This machine: `192.168.50.42` on `enp88s0` +- `nmap` is not installed; use `ip neigh show` for network discovery +- `sudo` requires a terminal (not available from Claude Code) diff --git a/nvme-fix-plan.md b/nvme-fix-plan.md new file mode 100644 index 0000000..189540d --- /dev/null +++ b/nvme-fix-plan.md @@ -0,0 +1,76 @@ +# NVMe Freeze Fix Plan — Kingston SNV2S2000G + +## Problem +System freezes and SSHD becomes unresponsive due to NVMe I/O write timeouts. +The Kingston SNV2S2000G firmware fails to wake from deep power states (PS3/PS4) in time, +causing the kernel to abort I/O operations and eventually hard-lock the system. + +- 152 NVMe I/O timeout errors logged in previous boot (Feb 17-20) +- 1 NVMe controller reset (Feb 19 09:41) +- 52 unsafe shutdowns (hard power-offs from freezes) +- SMART health: PASSED — drive is not failing, firmware power management is the issue + +## Root Cause +NVMe Autonomous Power State Transition (APST) puts the drive into PS3/PS4. +Exit latencies (5ms / 70ms) exceed what the firmware can reliably handle, +causing write and flush operations to time out. + +## Fix: Disable Deep NVMe Power States + +### Step 1 — Apply kernel parameter + +Run with sudo in a terminal: + +```bash +sudo sed -i 's|rootfstype=btrfs|rootfstype=btrfs nvme_core.default_ps_max_latency_us=5000|' /boot/limine.conf +``` + +### Step 2 — Verify the change + +```bash +grep nvme_core /boot/limine.conf +``` + +Every `cmdline:` line should now end with `nvme_core.default_ps_max_latency_us=5000`. + +### Step 3 — Reboot + +```bash +sudo reboot +``` + +### Step 4 — Confirm after reboot + +```bash +# Verify kernel parameter is active +cat /proc/cmdline | grep nvme_core + +# Monitor for NVMe errors (should show nothing new) +journalctl -b -k | grep -i 'nvme.*timeout' +``` + +## Monitoring + +Watch for recurrence over the next few days: + +```bash +# Check for any NVMe timeouts in current boot +journalctl -b -k | grep -i 'nvme.*timeout' + +# Check SMART data periodically +sudo smartctl -a /dev/nvme0 +``` + +## If Freezes Continue + +1. Try a stricter latency limit: change `5000` to `0` (disables all power state transitions) +2. Check for Kingston firmware updates for SNV2S2000G (current: SBK00104) +3. If nothing helps, the drive may need replacement despite passing SMART checks + +## Drive Info +- Model: KINGSTON SNV2S2000G (2TB) +- Serial: 50026B7784F6ACF9 +- Firmware: SBK00104 +- Percentage Used: 5% +- Bootloader: Limine +- Config: /boot/limine.conf