Power saving and conclusion
The only way to effectively measure a desktop's power is via a meter plugged into the wall. I have an 'Eco Savers' one and this reads ~24W (watts) when the server is idle. It's actually not a bad starting point considering, but there are a few tricks to get it a little lower.
The first is to use a utility called powertop
sudo apt-get install powertop sudo powertop
With the monitor connected and powertop running, it's around 26W.
Hit tab until we reach the Tunables area.
Then hit enter for each one, watching the power usage.
For me the effective ones seemed to be:
- Enable SATA link power management for host0 (through to host5)
- Runtime PM for PCI Device Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1
Others made little difference, but didn't impact the system, except the Autosuspend for my mouse, which stopped it working.
The end result was about 2W of power saved, now using 24W (or averaging slightly less). This is small, but is 8% less for a machine that will be on 24/7. Once I unplugged the keyboard, mouse and monitor too, it will also reduce further.
The other thing I can do, since all my disks are 2.5" laptop disks, is spin them down when idle.
By executing hdparm -y for all my disks, I save an additional ~4W power. I'm now at 19.8W. Including the powertop settings too, that's a 23% saving.
sudo hdparm -y /dev/sdb sudo hdparm -y /dev/sdc
I ignore /dev/sda - that's an SSD, and also where the O/S is installed so it shouldn't really spin down.
To make things more permanent, and less immediate, we can make a script to set the Runtime Power Management, SATA link power management and set the HDD idle times after boot.
I've used hdparm -B127 -S180 /dev/sdb and /dev/sdc
Hdparm uses a strange set of parameters, more info is in the link referenced below. This however first sets the power management flag (-B) to allow spindown, and spindown (-S) occurs after 15 minutes. A full list of numbers associated with the spindown times here - http://www.howtoeverything.net/linux/hardware/list-timeout-values-hdparm-s
#!/bin/sh # Disables the lockup watchdog echo 0 > /proc/sys/kernel/nmi_watchdog # 1.5 sec intervals to check if cache writes need writing to disk (default 0.3s) echo 1500 > /proc/sys/vm/dirty_writeback_centisecs # Medium power for SATA ALPM echo min_power | tee /sys/class/scsi_host/host*/link_power_management_policy # Auto power control for PCI devices (default on) echo auto | tee /sys/bus/pci/devices/*/power/control # Stop Wake on LAN ethtool -s enp2s0 wol d ethtool -s enp4s0 wol d # Set hard disks APM and spin down time hdparm -B127 -S180 /dev/sdb hdparm -B127 -S180 /dev/sdc exit 0
To make it runnable and execute at boot, use these commands:
sudo chmod +x ~/powersave.sh
Then add the script into a cron job on reboot by inserting a new line (change the directory to your home location).
sudo crontab -e
Now reboot and check the power usage on your wall plug monitor (if you have one). It should be lower than before.
I found in the past that using hdparm did not spin my disks down after the expected time. This looks like a common problem with Western Digital disks. I spent a while looking for a solution using hdparm, but actually found that setting the spindown time using Ubuntu's disks utility (gnome-disks) under Drive Settings does work, and keeps it after reboots. So I just used that instead.
My latest Seagate drives seem to be spinning down fine with hdparm settings 127 for power management, and 180 (15 minutes) for spindown time, but didn't seem to work with 241 (30 minutes).
Beware though - spinning up/down reduces the life of a hard disk so if you expect to be regularly accessing your files, give the drives a reasonable timeout before spinning down. Also, be more cautious with 3.5" desktop hard drives. These have larger platters and spin faster so have more stress on them during spin-up (I suggest specific NAS disks such as WD Red or Seagate Ironwolf which are designed to operate 24x7 and slow down when not in use).
Laptop disks (2.5") are designed to spin up more often so unless you need the best performance and/or high capacity, I'd choose those instead.
With the monitor unplugged and USB keyboard/mouse unplugged (there are now just three cables connected to my PC - Power cord, LAN Network cable and WAN Network cable), the idle power use comes down to 17.8W.
Your power savings may vary. If your building new, hopefully you can do really well with an Skylake or Kaby Lake CPU (or maybe AMD Ryzen?) and a more modern motherboard. Low power Celerons will do even better. Something that supports DDR3L (low voltage) or DDR4 may also help a bit.
Equally, if you're re-purposing an old desktop, this will not do as well as the 20W idle that I'm getting - but although it will cost more electric, for some years it will save money compared to purchasing new hardware, and you could argue more environmentally friendly than trying to dispose of old hardware!
Also, have a think about CPU and case fans. The CPU fan unless it is old hardware should definitely be a PWM type (4 pin). Case fans ideally PWM too if your motherboard supports it (these fans will then speed up/down depending on temperatures), or do as I did and add a fan control with an LM2956 module.
My system has been running reliably for many months now. It's taken a long time to build it and write this as I go, but it has been a worthwhile learning experience and hopefully other's reading can build and even improve on it.
Remember that it is flexible. If you want to add services, like HTTP server, SFTP, game servers, torrent software, you can. If you have the hardware, it could also be used to build additional VMs for say software development.
One useful addition I did add was Plex, which allows me to cast music, pictures and videos to my TV and Chromecast/Chromecast Audio. Nextcloud might be another suggestion, giving Dropbox like synchronisation of files such as my Documents.
For my needs, it has met them well. The router happily handles Internet browsing, Gaming on the PS4, watching 4K TV streams. It never crashes and rarely needs reboots (patches being the only reason). The VPN also lets me access my files whilst away, amongst other benefits.
^ Picture of server inside, showing intake fan (left), outtake fan (right), CPU fan and LM2956 voltage regulator for in/out fans (top middle)
^ Picture of server inside, top view, showing the motherboard, hard drives on the left (the second is hidden in the 3.5 bay with the red adaptor), power supply and fans
^ Picture of server inside, showing the additional network card in the PCI slot, hard drives and intake fan
^ Picture of server open side. The SSD sits in a 2.5 to ODD (laptop style DVD/optical disk drive) adaptor, since I won't need a CD/DVD drive in the server and already had the adaptor from an old laptop.
References and more reading:
How To Everything - Permanently Configure Hard Drives To Spin Down After A Given Idle Time