hetzner-ex101: limit maximum frequency
All checks were successful
build / test (push) Successful in 7s

hetzner-ex101: limit to 4.5Ghz
This commit is contained in:
Jörg Thalheim 2023-07-19 14:45:39 +02:00
parent 39ee5d7f4e
commit f5d1b35345

View File

@ -1,8 +1,32 @@
{
{ pkgs, ... }: {
# Enable raid support specifically, this will disable srvos's
# systemd-initrd as well, which currently is not compatible with mdraid.
boot.initrd.services.swraid.enable = true;
systemd.services.mdmonitor.enable = false;
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# We are not limited by zfs, so we can use the latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;
# looks like the Intel i9-13900 draws too much power and crashes the system
systemd.services.limit-cpu-freq = {
description = "Limit CPU frequency to 4.2GHz";
wantedBy = [ "multi-user.target" ];
after = [ "systemd-modules-load.service" ];
# Some cores do have a scaling max freq less than 5GHz, so we need to
# check for that or else all cores will run at 800MHz
script = ''
#!/bin/sh
for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; do
old_val="$(<"$f")"
if [[ "$old_val" -gt 4200000 ]]; then
echo 4200000 > "$f"
fi
done
'';
serviceConfig = {
Type = "oneshot";
};
};
}