I want to convert a backup system to serve as a NixOS NAS experiment. Since a NAS spends most of its time idling I am trying to figure out how to maximize the power-saving features. I am also figuring out the best way to have convenient monitoring.
The issue with power-saving is that most documentation which can be found is geared towards laptops. Obviously not that much of an issue, I could just ignore the battery parts. But I’m hoping there is something more targeted.
The obvious one is the CPU governor. It’s a few generations old Ryzen so the kernel driver is the EPP one apparently. This seems to bring its own challenges. The only clear instructions I can find on that is to use the auto-epp package which can then be set to power or balanced-power. There do not seem to be any instructions on how to set it statically without auto-epp.
The governor is another thing, the EPP driver only supports powersave and performance, so powersave it is.
What else can I do? Put USB and PCIe to sleep? What is already on by default and what should be declared in the config?
As far as monitoring goes, I would have hddtemp, smartd and figure out with sensors-detect what to do there (do I need to switch the k10 driver to the zenpower driver?). fancontrol is probably also a good bet.
Any other tips? I see flakes here and there but they are focused mainly on the filesystems and prometheus/grafana, not the supporting stuff.
Thanks!
For a mostly idle NAS, setting powerManagement.cpuFreqGovernor = “powersave” covers the governor, and powerManagement.powertop.enable = true applies powertop auto-tune (USB/PCIe runtime PM) at boot. If you want drives to spin down, check hdparm -S in a udev rule or services.udev.extraRules, but test it since some disks dislike frequent spin-ups. For monitoring, services.smartd.enable = true with sensible notifications is usually enough, and lm_sensors plus hddtemp covers temperatures.
Thanks for the tips. I ended up with this (relevant parts only):
hardware = {
# fancontrol = {
# enable = true;
# config = "";
# };
i2c.enable = true;
sensor.hddtemp = {
enable = true;
drives = [
# NVMe NOT SUPPORTED BY HDDTEMP
"/dev/disk/by-id/SSD"
];
# extraArgs = [];
};
usbStorage.manageShutdown = true;
};
services.auto-epp = {
enable = true;
settings.Settings = {
epp_state_for_AC = "balance_power";
};
};
powerManagement = {
enable = true;
cpuFreqGovernor = "powersave";
powertop.enable = true;
};
environment = {
systemPackages = with pkgs; [
powertop
lm_sensors
hddtemp
cpufrequtils
smartmontools
];
};
services = {
smartd = {
enable = true;
};
};
From what I read the fans are best controlled by the BIOS/system itself rather than software. I might make a derivation to enable the sensors overview for Cockpit as it’s not in nixpkgs. I looked into Prometheus/Grafana but that’s a bit much for my taste. And smartd still has to be configured, once I figure out how to make it actually notify me.
As for the spin-down, I’m on the fence about that. From what I know not a single platter-drive likes parking and spooling, so if I do end up using a single HDD as the first drive to process the worst of the writes I will probably keep it running. I honestly don’t know what the lifespan of an SSD is when downloading all those Linux distributions all the time.
It’s still not entirely functional, powertop won’t show CPU data for example, but it works. Still debating if I should put step-ca on it as well, to provide certificates for the dashboards internally. But I suppose the core is done.
Just seems too easy, like I’m missing something…
Ive yet to give this a proper read, but i saw spin down mentioned and alarm bells went off. Do NOT enable spin down under any circumstances. To make your drive last, it needs to spin at a mostly constant velocity (thats up to the firmware) and you should never move it while ite spinning.
Ok, so reading properly now, i dont have much to comment on power saving measures. Ive yet to do any tuning myself tbh. I will point out that I am not 100% sure switching governors actually gives any meaningful benefit on modern systems.
CPU governors do work. Their main purpose is to tune your processor frequency in such a way you get the most benefit from it without utilizing 100% cap. Back in the days I used to set it to performance on an unstable Intel Baytrail chip (known for their atrocious silicon quality) to keep stable GHz so it crashes less (until it died).
As for your usecase, you may save some cents on electricity from that (if any - depends on hardware), but most importnatly, it will keep your PC cool and less dusty.
Also check BIOS for stuff like ErP, fan presets and so on. Run sudo sensors-detect, answer yes to everything (dw, it will not cause hangs it says!), and save somewhere what it polled in the end. Do not choose writing to /etc/modules.
You said you are not sure about SSDs. I suggest you look up its model and check for TBW value on the manufacturer’s page. It is how much TB you can write to the drive before guaranteed memory fade/failure. Usually it’s close to real life performance, and most SSDs predict total wearout via showing “life left” in %. Simple math: gather yearly IO statistics and calculate how much you actually write.
Keep in mind you should never store anything critical on solid disks. I saw them die while in use. Corruption there is irreversible + often leads to total freezes. Just buy a good NAS HDD. You will always be able to predict failures just by pooling SMART and periodically running Short Self Tests (check smartmontools, not smartd). I saved so many important files just by reading drive report E-Mails once a week (simple sendmail script) - talking from experience.
Cheers! 
My experience is to keep them spinning and they can go far past their estimated life. More than one drive of mine went from 65535 to 0 hours in its SMART log and with today’s prices (thanks, AI!) I try my hardest to treat them like they just traveled first class with a cheerleader on their lap.
My idea was to have one spinning drive to capture the unsorted stuff, then remove, sort etc that and possibly keep some more static stuff on solid state. Maybe it uses a bit more power and I can’t write all those Linux distros at the same speed as my bandwidth can handle, but I’ll survive. Still debating which file system to use, but that’s another matter.
I still remember those WD drives which had such an aggressive parking set that we needed hdparm to tell them to cut it out.
Thanks for the feedback, by the way!
PS I do need to figure out how to do the auto-test and mailing part some day. I still do that all interactively.
You’re welcome!
Agreeing on WD - very common with the Blue model line.
I’ll share some scripts from 2024 (before I switched to TrueNAS), which might make a good strating point for incorporating into NixOS. They are far from ideal, but used to do the job well:
smartcheck-all.bash
#!/bin/bash
check_smart() {
drive=$1
echo "--------Smart attributes for $drive--------"
/usr/sbin/smartctl -a "$drive" 2>&1
}
# Capture script output and log entries in a variable
output=$(check_smart /dev/sda)
# Append script output for /dev/sdb
output="${output}
$(check_smart /dev/sdb)"
# Write the log entries and smartctl output to the log file
echo -e "$output" >> /root/sc/logs/smartcheck-all.log
# Send the email with the captured output
echo -e "$output" | mail -s "Hard Drives SMART Status at $(date)" bot@mail.dom.lan
smarttest.bash
#!/bin/bash
test_smart() {
drive=$1
/usr/sbin/smartctl -t short "$drive"
}
test_smart /dev/sda
test_smart /dev/sdb
# crontab -l
30 1 28 * * /root/sc/smarttest.sh > /dev/null
45 1 28 * * /root/sc/smartcheck-all.sh > /dev/null