fix(youko): mitigate the flaky USB-SATA HDD bridge

The two 4TB HDDs sit behind a JMicron JMS567 that resets and throws
UDMA-CRC / I/O errors (the disks themselves are healthy). Best-effort
mitigations while the enclosure stays in use:

- kernel: usbcore.autosuspend=-1, usb-storage.delay_use=10, pcie_aspm=off
- udev: keep the bridge's power/control=on (never autosuspend)
- disable APM/standby on the HDDs (spindown is a common reset trigger)
- enable smartd (watch the CRC count and disk health)

The kernel parameters need a reboot to take effect.
This commit is contained in:
Ryan Yin committed 2026-09-21 17:37:52 +08:00
1 parent 4867e94171
commit ce1645619f
1 file changed
+41 -6
+41 -6
View File
@@ -31,11 +31,46 @@ in
# scheduling). The VMs now use ordinary memory.
"transparent_hugepage=madvise"
# https://kubevirt.io/user-guide/compute/host-devices/
#
# PCI passthrough
# "amd_iommu=on" # enable IOMMU
# "iommu=pt" # use passthrough mode
# "pcie_acs_override=downstream" # enable ACS override
# --- mitigations for the flaky USB-SATA bridge the two 4TB HDDs sit behind.
# 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
# reset on resume.
services.udev.extraRules = ''
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="152d", ATTR{idProduct}=="0567", TEST=="power/control", ATTR{power/control}="on"
'';
# 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.
systemd.services.hdd-no-spindown = {
description = "Disable APM/standby on the USB HDDs";
after = [
"dev-sda.device"
"dev-sdb.device"
];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
script = ''
${pkgs.hdparm}/bin/hdparm -B 255 -S 0 /dev/sda || true
${pkgs.hdparm}/bin/hdparm -B 255 -S 0 /dev/sdb || true
'';
};
# Watch the disks with SMART. UDMA_CRC_Error_Count growth is the early warning
# for the bridge/link problem.
services.smartd = {
enable = true;
notifications.wall.enable = true;
devices = [
{ device = "/dev/sda"; }
{ device = "/dev/sdb"; }
];
};
}