From 899162055a149afbe4ec28d8928458893d238e5e Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Mon, 21 Sep 2026 17:42:21 +0800 Subject: [PATCH] fix(youko): drop pcie_aspm=off, re-assert the hdparm settings hourly pcie_aspm=off was the least-justified mitigation (the flakiness is on the USB/SATA side) and costs power. Also log the disks' APM level/state and re-apply the settings hourly, since the bridge or the disk firmware can drop them (the disks were still reaching standby). --- hosts/12kingdoms-youko/default.nix | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/hosts/12kingdoms-youko/default.nix b/hosts/12kingdoms-youko/default.nix index 622f2afa..940488ec 100644 --- a/hosts/12kingdoms-youko/default.nix +++ b/hosts/12kingdoms-youko/default.nix @@ -40,7 +40,6 @@ in # It is a JMicron JMS567 that resets and throws link (UDMA-CRC) + I/O errors. "usbcore.autosuspend=-1" # no USB autosuspend "usb-storage.delay_use=10" # give the bridge time to settle after probing - "pcie_aspm=off" # ASPM can also make the link flap ]; # Keep the bridge powered: a suspended device is what most often triggers a @@ -50,7 +49,10 @@ in ''; # A spindown/spinup is a common trigger for the bridge resetting, so disable - # APM/standby on the HDDs. Best effort: hdparm may not get through the bridge. + # APM/standby on the HDDs. sdb in particular has ~1M load cycles (WD + # Intellipark), so stopping the idle head-parking also saves its mechanism. + # Read the settings back into the journal, and re-assert them hourly: the + # bridge or the disk's own firmware can drop them. systemd.services.hdd-no-spindown = { description = "Disable APM/standby on the USB HDDs"; after = [ "local-fs.target" ]; @@ -60,11 +62,24 @@ in RemainAfterExit = true; }; script = '' - ${pkgs.hdparm}/bin/hdparm -B 255 -S 0 ${hddPublic} || true - ${pkgs.hdparm}/bin/hdparm -B 255 -S 0 ${hddEncrypted} || true + for d in ${hddPublic} ${hddEncrypted}; do + echo "== $d ==" + ${pkgs.hdparm}/bin/hdparm -B 255 -S 0 "$d" || true + ${pkgs.hdparm}/bin/hdparm -B "$d" || true + ${pkgs.hdparm}/bin/hdparm -C "$d" || true + done ''; }; + systemd.timers.hdd-no-spindown = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "10min"; + OnUnitActiveSec = "1h"; + Persistent = true; + }; + }; + # Watch the disks with SMART. UDMA_CRC_Error_Count growth is the early warning # for the bridge/link problem. services.smartd = {