Thicket data repository for the EEG
at main 15 kB view raw
1{ 2 "id": "https://ryan.freumh.org/nas.html", 3 "title": "Building a Low-Powered NAS", 4 "link": "https://ryan.freumh.org/nas.html", 5 "updated": "2024-08-03T00:00:00", 6 "published": "2024-08-03T00:00:00", 7 "summary": "<div>\n \n <span>Published 3 Aug 2024.</span>\n \n \n </div>\n \n <div> Tags: <a href=\"/technology.html\" title=\"All pages tagged 'technology'.\">technology</a>, <a href=\"/self-hosting.html\" title=\"All pages tagged 'self-hosting'.\">self-hosting</a>. </div>\n \n \n\n <p><span>At the start of this year I built a\nNetwork-Attached Storage (NAS) server to store backups, photos &amp;\nvideos, digitised VHS tapes, cached builds, and more. Having a dedicated\nmachine has allowed me to use it in ways that wouldn’t be feasible with\ncloud storage, such as live transcoding of media playback to different\nresolutions or codecs, and having it physically co-located makes it\nresilient to network outages. I had a look at some of the pre-built\nsolutions out there, but they seemed expensive for what they were, often\nhaving architectures a few generations behind. So I decided to build my\nown. With the price of energy in the UK power efficiency was a primary\nconcern and informed many of the decisions made when building\nit.</span></p>\n<h3>Hardware</h3>\n<p><span>The <a href=\"https://ark.intel.com/content/www/us/en/ark/products/231803/intel-processor-n100-6m-cache-up-to-3-40-ghz.html\">N100\nCPU</a>, while designed for mobile, looked very attractive due to its\nlow 6W Thermal Design Power (TDP) whilst supporting hardware transcoding\nwith an integrated GPU. The <a href=\"https://www.asrock.com/mb/Intel/N100M/\">Asrock N100M\nmotherboard</a> uses this chip and gives us 2x SATA3 and 1x M.2 ports,\nwith the possibility of expanding this with e.g. <a href=\"https://www.asmedia.com.tw/product/45aYq54sP8Qh7WH8/58dYQ8bxZ4UR9wG5\">ASMedia\n1166 PCIe Gen3 x2 to 6x SATA3</a>. Due to the low TDP of the chip it\nalso uses passive (fanless) cooling. I also looked at the <a href=\"https://www.aliexpress.us/item/1005006313023975.html?gatewayAdapt=4itemAdapt\">Topton\nN100 motherboard</a> (and other chips they offer) as recommend by some\n<a href=\"https://blog.briancmoses.com/2023/09/diy-nas-econonas-2023.html\">blogs</a>,\nbut various <a href=\"https://forums.servethehome.com/index.php?threads/topton-nas-motherboard.37979/\">forum\nposts</a> and <a href=\"https://mattgadient.com/7-watts-idle-on-intel-12th-13th-gen-the-foundation-for-building-a-low-power-server-nas/\">blogs</a>\nreported issues with performance and sleep states due to the in-built\nJMB585 PCIe SATA controller. I got the Asrock N100M along with 16GB\ncompatible RAM. As I didn’t opt for ECC memory I ran memtest from the\nBIOS a few times to give me some confidence.</span></p>\n<p><span>I bought the <a href=\"https://www.corsair.com/uk/en/p/psu/cp-9020121-uk/cx-series-cx550-550-watt-80-plus-bronze-certified-atx-psu-uk-cp-9020121-uk\">Corsair\nCX550</a> to handle power spikes that might result from booting if I\nwant to scale this up to 10+ drives, whilst also purportedly being power\nefficient at the lower end of the draw/efficiency curve.</span></p>\n<h3>Storage</h3>\n<p><span>I got two 16TB Hard Disk Drives for the NAS\nto run in RAID 1 (mirroring) with <a href=\"https://en.wikipedia.org/wiki/ZFS\">ZFS</a>. I went for two large\nhard drives in RAID 1 for simple recovery and power efficiency. The\ngreater the number of drives the greater the power draw (~4W per drive).\nSSDs would have been quieter and more power efficiency, but they are\nsignificantly more expensive than HDDs especially for this\nsize.</span></p>\n<pre><code>$ zpool create tank mirror /dev/disk1 /dev/disk2\n</code></pre>\n<p><span>The majority of the time the drives are not\nactive. There’s a trade-off here between hard drive wear in spin-ups,\nand power efficiency, but at the moment I’ve got them configured to spin\ndown after 1 hour of idling, using <a href=\"https://sourceforge.net/projects/hdparm/\">hdparm</a>.</span></p>\n<pre><code>$ hdparm -S 242 /dev/disk\n</code></pre>\n<p><span>I have a 1TB M.2 SSD to run the OS from,\nsome trivial storage like git repositories that I don’t need a lot of\nspace or redundancy for, as well as a ZFS level 2 adaptive replacement\ncache (L2ARC).</span></p>\n<pre><code>$ truncate -s 512G /var/zfs_cache\n$ zpool add poolname cache /var/zfs_cache\n</code></pre>\n<h3>Software</h3>\n<p><span>Like most of my machines I’m running NixOS\non my NAS for declarative management of system configuration. The\nconfiguration can be found <a href=\"https://github.com/RyanGibb/nixos/tree/master/hosts/elephant\">here</a>.\nWhile getting hardware transcoding working with Intel’s QuickSync I\nended up <a href=\"https://github.com/NixOS/nixpkgs/pull/291559\">contributing</a> to\nfixing it on NixOS.</span></p>\n<p><span>I’m running a number of storage-heavy\nservices including Jellyfin, a Sambda file server, Nextcloud, and\nRestic. This machine isn’t exposed to the Internet at the moment, only\nbeing accessible over Wireguard VPN. If it were exposed I could move a\nnumber of service currently running on a small cloud VPS to the NAS\nincluding a nameserver, matrix server, mastodon server, webserver\nserving a number of websites, and a mailserver (perhaps utilizing\nsendgrid for mail deliverable from a residential IP).</span></p>\n<p><span>I’m using Restic to backup various\nmachines to this NAS. As RAID is not a backup, I’m also using Backblaze\nto store ~100GB of precious data for pennies a month.</span></p>\n<h3>Power usage</h3>\n<p><span>I took some non-exhaustive power\nmeasurements, using a power meter plug, while tinkering:</span></p>\n<ul>\n<li>I measured 35W with two drives running <a href=\"https://sourceforge.net/projects/e2fsprogs/\">badblocks</a> to\nverify their integrity.</li>\n<li>One drive was bad and had to be returned at this point. After, I\nenabled all the power saving features in the BIOS, ran <code>powertop --auto-tune</code> to tune power usage by,\ne.g., disabling the Wi-Fi radio. I verified that we were hitting C10\nsleep state according to powertop. With power saving enabled and one\ndrive idling I registered 17.7W.</li>\n<li>I disconnected the display and registered 16.2W, a drop of\n1.5W.</li>\n<li>Powering down the HDD with hdparm gave 12.2W, a drop of 4W.</li>\n<li>Disabling the case’s fans gave 11.6W.</li>\n</ul>\n<h3>Cost</h3>\n<p><span>All in all the hardware for this NAS,\nexcluding the cost of the hard disk drives, was:</span></p>\n<ul>\n<li>Motherboard &amp; CPU board: £137.25</li>\n<li>PSU: £52.99</li>\n<li>SSD: £53.60</li>\n<li>RAM: £35.97</li>\n<li>Case: £115.47</li>\n<li><strong>Total</strong>: £395.28</li>\n</ul>\n<p><span>Which is competitive with off the shelf\nsolutions out there. You could reduce this further by opting for a\ncheaper case or smaller SSD.</span></p>\n<p><span>Assuming an idle power draw of 12W running\n24/7 we would use 12W * (365*24)=105kWh in a year. With a price of\n22.36p/kWh this costs ~£23 per year to run. We could possibly reduce\nthis by taking advantages of cheaper electricity during the night that\nsome providers offer in scheduling energy-intensive tasks, like backups.\nAnother possibility that I’m toying with is when the NAS is idling for\nlong periods putting it into a hibernation, which should idle at 1 or 2\nWatts. To wake the NAS up, we could send a Wake-on-LAN (WoL) packet from\na nameserver running on the local router on a DNS resolution for the\nNAS’ name.</span></p>", 8 "content": "<div>\n \n <span>Published 3 Aug 2024.</span>\n \n \n </div>\n \n <div> Tags: <a href=\"/technology.html\" title=\"All pages tagged 'technology'.\">technology</a>, <a href=\"/self-hosting.html\" title=\"All pages tagged 'self-hosting'.\">self-hosting</a>. </div>\n \n \n\n <p><span>At the start of this year I built a\nNetwork-Attached Storage (NAS) server to store backups, photos &amp;\nvideos, digitised VHS tapes, cached builds, and more. Having a dedicated\nmachine has allowed me to use it in ways that wouldn’t be feasible with\ncloud storage, such as live transcoding of media playback to different\nresolutions or codecs, and having it physically co-located makes it\nresilient to network outages. I had a look at some of the pre-built\nsolutions out there, but they seemed expensive for what they were, often\nhaving architectures a few generations behind. So I decided to build my\nown. With the price of energy in the UK power efficiency was a primary\nconcern and informed many of the decisions made when building\nit.</span></p>\n<h3>Hardware</h3>\n<p><span>The <a href=\"https://ark.intel.com/content/www/us/en/ark/products/231803/intel-processor-n100-6m-cache-up-to-3-40-ghz.html\">N100\nCPU</a>, while designed for mobile, looked very attractive due to its\nlow 6W Thermal Design Power (TDP) whilst supporting hardware transcoding\nwith an integrated GPU. The <a href=\"https://www.asrock.com/mb/Intel/N100M/\">Asrock N100M\nmotherboard</a> uses this chip and gives us 2x SATA3 and 1x M.2 ports,\nwith the possibility of expanding this with e.g. <a href=\"https://www.asmedia.com.tw/product/45aYq54sP8Qh7WH8/58dYQ8bxZ4UR9wG5\">ASMedia\n1166 PCIe Gen3 x2 to 6x SATA3</a>. Due to the low TDP of the chip it\nalso uses passive (fanless) cooling. I also looked at the <a href=\"https://www.aliexpress.us/item/1005006313023975.html?gatewayAdapt=4itemAdapt\">Topton\nN100 motherboard</a> (and other chips they offer) as recommend by some\n<a href=\"https://blog.briancmoses.com/2023/09/diy-nas-econonas-2023.html\">blogs</a>,\nbut various <a href=\"https://forums.servethehome.com/index.php?threads/topton-nas-motherboard.37979/\">forum\nposts</a> and <a href=\"https://mattgadient.com/7-watts-idle-on-intel-12th-13th-gen-the-foundation-for-building-a-low-power-server-nas/\">blogs</a>\nreported issues with performance and sleep states due to the in-built\nJMB585 PCIe SATA controller. I got the Asrock N100M along with 16GB\ncompatible RAM. As I didn’t opt for ECC memory I ran memtest from the\nBIOS a few times to give me some confidence.</span></p>\n<p><span>I bought the <a href=\"https://www.corsair.com/uk/en/p/psu/cp-9020121-uk/cx-series-cx550-550-watt-80-plus-bronze-certified-atx-psu-uk-cp-9020121-uk\">Corsair\nCX550</a> to handle power spikes that might result from booting if I\nwant to scale this up to 10+ drives, whilst also purportedly being power\nefficient at the lower end of the draw/efficiency curve.</span></p>\n<h3>Storage</h3>\n<p><span>I got two 16TB Hard Disk Drives for the NAS\nto run in RAID 1 (mirroring) with <a href=\"https://en.wikipedia.org/wiki/ZFS\">ZFS</a>. I went for two large\nhard drives in RAID 1 for simple recovery and power efficiency. The\ngreater the number of drives the greater the power draw (~4W per drive).\nSSDs would have been quieter and more power efficiency, but they are\nsignificantly more expensive than HDDs especially for this\nsize.</span></p>\n<pre><code>$ zpool create tank mirror /dev/disk1 /dev/disk2\n</code></pre>\n<p><span>The majority of the time the drives are not\nactive. There’s a trade-off here between hard drive wear in spin-ups,\nand power efficiency, but at the moment I’ve got them configured to spin\ndown after 1 hour of idling, using <a href=\"https://sourceforge.net/projects/hdparm/\">hdparm</a>.</span></p>\n<pre><code>$ hdparm -S 242 /dev/disk\n</code></pre>\n<p><span>I have a 1TB M.2 SSD to run the OS from,\nsome trivial storage like git repositories that I don’t need a lot of\nspace or redundancy for, as well as a ZFS level 2 adaptive replacement\ncache (L2ARC).</span></p>\n<pre><code>$ truncate -s 512G /var/zfs_cache\n$ zpool add poolname cache /var/zfs_cache\n</code></pre>\n<h3>Software</h3>\n<p><span>Like most of my machines I’m running NixOS\non my NAS for declarative management of system configuration. The\nconfiguration can be found <a href=\"https://github.com/RyanGibb/nixos/tree/master/hosts/elephant\">here</a>.\nWhile getting hardware transcoding working with Intel’s QuickSync I\nended up <a href=\"https://github.com/NixOS/nixpkgs/pull/291559\">contributing</a> to\nfixing it on NixOS.</span></p>\n<p><span>I’m running a number of storage-heavy\nservices including Jellyfin, a Sambda file server, Nextcloud, and\nRestic. This machine isn’t exposed to the Internet at the moment, only\nbeing accessible over Wireguard VPN. If it were exposed I could move a\nnumber of service currently running on a small cloud VPS to the NAS\nincluding a nameserver, matrix server, mastodon server, webserver\nserving a number of websites, and a mailserver (perhaps utilizing\nsendgrid for mail deliverable from a residential IP).</span></p>\n<p><span>I’m using Restic to backup various\nmachines to this NAS. As RAID is not a backup, I’m also using Backblaze\nto store ~100GB of precious data for pennies a month.</span></p>\n<h3>Power usage</h3>\n<p><span>I took some non-exhaustive power\nmeasurements, using a power meter plug, while tinkering:</span></p>\n<ul>\n<li>I measured 35W with two drives running <a href=\"https://sourceforge.net/projects/e2fsprogs/\">badblocks</a> to\nverify their integrity.</li>\n<li>One drive was bad and had to be returned at this point. After, I\nenabled all the power saving features in the BIOS, ran <code>powertop --auto-tune</code> to tune power usage by,\ne.g., disabling the Wi-Fi radio. I verified that we were hitting C10\nsleep state according to powertop. With power saving enabled and one\ndrive idling I registered 17.7W.</li>\n<li>I disconnected the display and registered 16.2W, a drop of\n1.5W.</li>\n<li>Powering down the HDD with hdparm gave 12.2W, a drop of 4W.</li>\n<li>Disabling the case’s fans gave 11.6W.</li>\n</ul>\n<h3>Cost</h3>\n<p><span>All in all the hardware for this NAS,\nexcluding the cost of the hard disk drives, was:</span></p>\n<ul>\n<li>Motherboard &amp; CPU board: £137.25</li>\n<li>PSU: £52.99</li>\n<li>SSD: £53.60</li>\n<li>RAM: £35.97</li>\n<li>Case: £115.47</li>\n<li><strong>Total</strong>: £395.28</li>\n</ul>\n<p><span>Which is competitive with off the shelf\nsolutions out there. You could reduce this further by opting for a\ncheaper case or smaller SSD.</span></p>\n<p><span>Assuming an idle power draw of 12W running\n24/7 we would use 12W * (365*24)=105kWh in a year. With a price of\n22.36p/kWh this costs ~£23 per year to run. We could possibly reduce\nthis by taking advantages of cheaper electricity during the night that\nsome providers offer in scheduling energy-intensive tasks, like backups.\nAnother possibility that I’m toying with is when the NAS is idling for\nlong periods putting it into a hibernation, which should idle at 1 or 2\nWatts. To wake the NAS up, we could send a Wake-on-LAN (WoL) packet from\na nameserver running on the local router on a DNS resolution for the\nNAS’ name.</span></p>", 9 "content_type": "html", 10 "categories": [], 11 "source": "https://ryan.freumh.org/atom.xml" 12}