===== WARNING =======
The method I describe below I'm sure is not supported, it can lead to system data loss on your NAS, in extreme cases can lead to stored data loss, lowers NAS resiliency to single disk failure. And ideal solution will cost you some money up front.
Having said that, I believe it's relatively safe, includes backup scheme and is easily reversible.
It is aimed at advanced users, that understand how Linux and RAID works, but I'll try to explain as much as I can.
===== CONTEXT ======
I bought a QNAP TS-453A - a powerful NAS with HDMI output. I intend to use all of it's features - playing my home media on my TV with HDMI output, running VMs, containers, etc.
As it is connected to my TV, it stays in my living room (and with relatively small apartment I don't have other place to put it anyway). And the normal setup drove me crazy with HDD never spinning down, which made a terrible night's sleep for occasional guests and reading books was not so pleasant.
====== THE WHY =====
Why HDDs don't spin down? It's basically down to the fact, that almost no software on our NAS is designed to not use disks. I tried chasing those individual programs and looking into system settings, but this was tedious and there was always something jumping out on me, so I gave up.
====== THE WHAT ====
So I decided to ignore my original set-up of RAID-5 for 3 HDDs and added an SSD as a system disk. The thinking was - have all the software that needs to access the disk, do so on SSD - it's silent anyway, and rest of HDDs will only spin up if I actively want to access the data stored there.
I split those into RAID 1 with 2xHDD for data, that I can't recreate like my photos, plus 1xHDD for data I can recreate like my DVD rips. Remember, RAID is not a backup replacement, so all my data is backed up in other places anyway.
To sum up my drive set up looks like this:
Bay 1 - SSD - 256 GB
Bay 2 - HDD RAID 1 - 3TB
Bay 3 - HDD RAID 1 - 3TB
Bay 4 - HDD no RAID - 3TB
This set up gives me a good balance of silence, power consumption, safety and cost. Turns out my HDDs when spinning all the time use as much power, that cumulated over 5 years they will pay for the SSD I bought.
I did not mind it much, but I had to start over with NAS set up, and this might be a downer for you, as it might be laborious to resetup your NAS, but read on and you might be able to get good results with no resetup.
Instead of an SSD for a system disk you can get a 2,5" HDD which is much quieter than 3'5" and even one 3,5" HDD will be more silent and power efficient than 3 or 4.
===== THE HOW ====
Once I set up my NAS with SSD as a system disk, my HDDs wouldn't go to sleep anyway. The problem is, that QNAP, silently creates an internal RAID-1 system partition, that spans all your drives and constantly accesses this partition. The second, smaller problem is SWAP partitions get created by QTS on other drives as well.
Problem #1 - Internal RAID 1
You can verify this by running this command:
Code: Select all
mdadm -D /dev/md9
Code: Select all
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
34 8 17 1 active sync /dev/sdb1
32 8 33 2 active sync /dev/sdc1
33 8 49 3 active sync /dev/sdd1
Disclaimer - this is how it looks like on my TS-453A Intel based NAS. In your case RAID device names can be different.
You can look at all RAID partitions you have with this command:
Code: Select all
cat /proc/mdstat
Code: Select all
.
.
.
md13 : active raid1 sdb4[34] sdc4[32] sdd4[33] sda4[0]
458880 blocks super 1.0 [32/4] [UUUU____________________________]
bitmap: 1/1 pages [4KB], 65536KB chunk
md9 : active raid1 sdb1[34] sdc1[32] sdd1[33] sda1[0]
530048 blocks super 1.0 [32/4] [UUUU____________________________]
bitmap: 1/1 pages [4KB], 65536KB chunk
.
.
.
Code: Select all
parted /dev/sdb print
Code: Select all
Number Start End Size File system Name Flags
1 20.5kB 543MB 543MB ext3 primary
2 543MB 1086MB 543MB linux-swap(v1) primary
3 1086MB 2991GB 2990GB primary
4 2991GB 2992GB 543MB ext3 primary
5 2992GB 3001GB 8554MB linux-swap(v1) primary
Code: Select all
[~]# cat disconnect_internal_raid.sh
#!/bin/bash
echo "Disconnecting md9"
mdadm /dev/md9 --fail /dev/sdd1
mdadm /dev/md9 --fail /dev/sdc1
mdadm /dev/md9 --fail /dev/sdb1
echo "Disconnecting md13"
mdadm /dev/md13 --fail /dev/sdd4
mdadm /dev/md13 --fail /dev/sdc4
mdadm /dev/md13 --fail /dev/sdb4
Code: Select all
mdadm -D /dev/md9
Code: Select all
mdadm -D /dev/md13
Now, the drives should really go to sleep after a period defined in QTS [Control Panel -> Hardware -> Disk standby]. If there is nothing else wanting to access your data, like for example Plex constantly updating media library. There are many threads in this forum to help you discover and fight those. With intense activity SWAP might be using your HDD, see Problem #2 below.
You can force sleep a hard drive by issuing this command:
Code: Select all
hdparm -y /dev/sdb
Code: Select all
hdparm -C /dev/sdb
Code: Select all
/dev/sdb:
drive state is: active/idle
Code: Select all
/dev/sdb:
drive state is: standby
Here is how to edit your autorun on QNAP
https://wiki.qnap.com/wiki/Running_Your ... at_Startup
I also have a script, that rebuilds internal storage:
Code: Select all
[~]# cat rebuild_internal_raid.sh
#!/bin/bash
echo "Re-adding md9"
mdadm /dev/md9 --re-add /dev/sdd1
mdadm /dev/md9 --re-add /dev/sdc1
mdadm /dev/md9 --re-add /dev/sdb1
echo "Re-adding md13"
mdadm /dev/md13 --re-add /dev/sdd4
mdadm /dev/md13 --re-add /dev/sdc4
mdadm /dev/md13 --re-add /dev/sdb4
Code: Select all
mdadm -D /dev/md9
Code: Select all
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
34 8 17 1 spare rebuilding /dev/sdb1
32 8 33 2 spare rebuilding /dev/sdc1
33 8 49 3 spare rebuilding /dev/sdd1
Code: Select all
15 10 * * * /share/homes/admin/rebuild_internal_raid.sh
30 10 * * * /share/homes/admin/disconnect_internal_raid.sh
https://wiki.qnap.com/wiki/Add_items_to_crontab
Take note, where I keep my files: /share/homes/admin. If you put them in your admin home directory /root, they will disappear after a restart.
Also remember to make the files executable with chmod + x filename.
Problem #2 - SWAP partitions
In my case QNAP decided it will keep all SWAP partitions on my HDDs instead of SSD.
You can check where your SWAP is using this command:
Code: Select all
cat /proc/swaps
https://helpdesk.qnap.com/index.php?/Kn ... y-manually
But rather than increasing my SWAP size by moving away from RAID to individual partitions I simply created a SWAP file on my SSD, as this gives me grater flexibility without the need to reformat my drive. You can go a different route.
Create a SWAP file using this command:
Code: Select all
# dd if=/dev/zero of=/share/homes/admin/swapfile bs=1024 count=524288
https://www.cyberciti.biz/faq/linux-add ... ile-howto/
And one more entry to your autorun:
Code: Select all
[~]# cat move_swap_to_file.sh
#!/bin/bash
echo "Turning SWAP off"
swapoff -a
echo "Initializing file swap"
mkswap /share/homes/admin/swapfile
swapon /share/homes/admin/swapfile
You can verify your new SWAP size in QTS UI in [Resource Monitor -> System Resource -> Memory]
For me this was it - my NAS is now completely silent unless I specifically want to access my data or I manually set a scheduled process, like Plex refreshing it's library.