Advanced guide to how I completely silenced my TS-453A

Discussion about hard drive spin down (standby) feature of NAS.
damga
Starting out
Posts: 13
Joined: Fri Dec 30, 2016 4:41 am

Advanced guide to how I completely silenced my TS-453A

Post by damga »

You can skip my long ramblings and jump straight to "THE WHAT" section, but beware there are warnings below.

===== 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
At the end you will see something like this:

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
Telling you that all your drives are part of the system RAID md9. Same goes for md13.

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
And it will show a result like this:

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
 .
 .
 .
This tells you, that, part of md9 RAID partition is your sdb4 HDD partition. To look at all the partitions on a single HDD you can use this command:

Code: Select all

parted /dev/sdb print
Which will result in something like this:

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
 
Now, since it's just a RAID-1, you can simply remove all drives but one and the system will work fine, but will not disturb your other drives. You do it by failing partitions you want to remove:

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
And verify with

Code: Select all

mdadm -D /dev/md9

Code: Select all

mdadm -D /dev/md13
that drives are really disconnected.

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
And verify if the drive is active or not with this command:

Code: Select all

hdparm -C /dev/sdb

Code: Select all

/dev/sdb:
 drive state is:  active/idle
 
or

Code: Select all

/dev/sdb:
 drive state is:  standby
 
Hopefully you noticed in the previous section I have a script called disconnect_internal_raid.sh (if not CTRL+F for the name in the post), that I put into my autorun.
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
Just after running this file, when you issue

Code: Select all

mdadm -D /dev/md9
You will see that your RAID spares are rebuilding

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
So I would schedule a resync once a day with those crontab entries (15 minutes is more than enough for a rebuild, but feel free to customize it):

Code: Select all

15 10 * * * /share/homes/admin/rebuild_internal_raid.sh
30 10 * * * /share/homes/admin/disconnect_internal_raid.sh
And here is how to properly edit your crontab on QNAP NAS:
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
I followed this guide to combat my SWAP issues:
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
This creates 512MB file, look below for instructions on how to calculate a different file size:
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
It's basically turning all you current swap partitions off and initializes the newly created file as a new swap.

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.
Last edited by damga on Mon Apr 02, 2018 5:09 am, edited 1 time in total.
User avatar
Spider99
Experience counts
Posts: 1951
Joined: Fri Oct 21, 2011 11:14 pm
Location: UK

Re: Advanced guide to how I completely silenced my TS-453A

Post by Spider99 »

Interesting and creative

Couple of things
1) If you upgrade the firmware - i suspect all your hard work will be undone and/or it may corrupt the nas
2) As i think you state if the ssd dies you lose access to your data and setup of the nas - at least temporarily until you replace the disks etc

Hope it works longterm

PS - spindown works fine on my 853A - but i have stripped in back to minimal apps - but still cant use it in a quiet room :)
Tim

TS-853A(16GB): - 4.3.4.0483 - Static volume - Raid5 - 8 x 4TB HGST Deskstar NAS
Windows Server + StableBit Drivepool and Scanner ~115 TB Backup Server
TS-412 & TS-459 Pro II: Retired
Clients: 3 x Windows 10 Pro(64bit)
damga
Starting out
Posts: 13
Joined: Fri Dec 30, 2016 4:41 am

Re: Advanced guide to how I completely silenced my TS-453A

Post by damga »

Spider99 wrote: 1) If you upgrade the firmware - i suspect all your hard work will be undone and/or it may corrupt the nas
I don't think so. I'm basically doing 2 changes:
1. I "remove" parts of HDDs, that form internal RAID. I plug them back in once a day to sync data.
2. I disable swap partitions and replace them with swap file.

All those changes are lost on restart (and NAS behaves as I never did those modifications). I just keep them in autostart, so they stick.
I do agree, that upgrading firmware with my setup on might lead to issues. But going back to initial state is 3 scripts away, then I can safely upgrade and then back to my setup.
Spider99 wrote: 2) As i think you state if the ssd dies you lose access to your data and setup of the nas - at least temporarily until you replace the disks etc
Since I'm regularly backing up internal RAID I think SSD dying will only remove system applications, but NAS will still be accessible from a last internal RAID sync - there should be not much going on, but some inconsistencies might creep in, and it is possible, that whole NAS will fail.
Since I have all the backups, I am willing to risk few hours of my life in case of SSD failure to get the data back online.
User avatar
Moogle Stiltzkin
Guru
Posts: 11448
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: Advanced guide to how I completely silenced my TS-453A

Post by Moogle Stiltzkin »

thank you for the detailed guide and insight.

as a newbie i wish we could just set spindown during inactivity for 30mins, 1 hour etc... and be done with it.

but if that doesn't work as planned, the troubleshooting is a pain >-<;
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
moody_blue
Easy as a breeze
Posts: 266
Joined: Tue Jan 10, 2017 9:23 am

Advanced guide to how I completely silenced my TS-453A

Post by moody_blue »

Interesting. I've done something similar when I owned an ARM Syno and it's performance more that doubled, specially with Plex metadata on a SSD.
QNAP TS-253A 8G QTS 5.0.1.2145
Plex Media Server 1.29.0.6209
OpenHAB 3.4.0.M2
Unifi 7.2.92
Apache80 2454.8230
GLPI 10.0.3
navier
Starting out
Posts: 27
Joined: Sat Mar 18, 2017 11:56 pm

Re: Advanced guide to how I completely silenced my TS-453A

Post by navier »

moody_blue wrote:Interesting. I've done something similar when I owned an ARM Syno and it's performance more that doubled, specially with Plex metadata on a SSD.
Do you mean as SSD-Cache or SSD as System Drive (first Slot)?
User avatar
moody_blue
Easy as a breeze
Posts: 266
Joined: Tue Jan 10, 2017 9:23 am

Advanced guide to how I completely silenced my TS-453A

Post by moody_blue »

navier wrote:Do you mean as SSD-Cache or SSD as System Drive (first Slot)?
The important thing was to define volume1 on the SSD disk (alone) as a basic volume (no raid, no jbod). The SSD does not need to occupy slot1, it only needs to contain volume1.
QNAP TS-253A 8G QTS 5.0.1.2145
Plex Media Server 1.29.0.6209
OpenHAB 3.4.0.M2
Unifi 7.2.92
Apache80 2454.8230
GLPI 10.0.3
navier
Starting out
Posts: 27
Joined: Sat Mar 18, 2017 11:56 pm

Re: Advanced guide to how I completely silenced my TS-453A

Post by navier »

damga wrote: I do agree, that upgrading firmware with my setup on might lead to issues. But going back to initial state is 3 scripts away, then I can safely upgrade and then back to my setup.
Which 3? I thought it only will be necessary the rebuild_internal_raid.sh. I am wrong? Maybe the Swap thing should be changed to the initial state also? but how?

- - -

EDIT: I tried it and it works, thank you!

BUT I wanted to add, that the code:

Code: Select all

# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
is not correct as it it was copy-pasted from third source... in order to work with the 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
...it should be

Code: Select all

# dd if=/dev/zero of=/share/homes/admin/swapfile bs=1024 count=524288
(although I personally have set it in /share/ and not under homes/admin)
Last edited by navier on Thu May 04, 2017 11:57 pm, edited 5 times in total.
peter247
Getting the hang of things
Posts: 60
Joined: Sun Apr 16, 2017 5:55 am

Re: Advanced guide to how I completely silenced my TS-453A

Post by peter247 »

Very interesting bit of information damga about how to silence your nas.

I have the 6 bay version, the TS-653a which is soon to get a ram upgrade ( 8GB ) with at present 3 x WD red 8TB disks in raid 5 ( volume 1 ), a 1TB ssd ( not used as cache ) and a blank 3TB , plus a spare bay.

ALL DATA BACKED UP and waiting for the ram before I start again from scratch !!.

I have the same problem all the drives NEVER going to sleep .
The 3TB drive is totally blank no data or swaps on it , but still never goes to sleep , all volumes are been access all the time , every couple of seconds you can hear the drives been accessed for no reason.
I`m a bit of a Linux newbie , so will have to do some reading on the MD commands ,

Thinking about :-

A : Get a extra 8TB drive and go for 2 x raid 1s or a raid 10 volume
B : Get a extra ssd and have raid 1 ssd volume 1
C : Remove the 3TB drive and go for A and B , when I can afford it .
GGavan
New here
Posts: 2
Joined: Mon Mar 05, 2018 11:24 pm

Re: Advanced guide to how I completely silenced my TS-453A

Post by GGavan »

Thank you, damga!! Your workaround saved QNAP from a return of product (refund)
I hope that QNAP will solve this but not too soon I think :(
damga
Starting out
Posts: 13
Joined: Fri Dec 30, 2016 4:41 am

Re: Advanced guide to how I completely silenced my TS-453A

Post by damga »

Thanks navier for pointing out the mistake - fixed.
GGavan - glad I was of help. I was desperate and it did take me many hours to get there.
bridgey
New here
Posts: 3
Joined: Sat Dec 09, 2017 6:46 am

Re: Advanced guide to how I completely silenced my TS-453A

Post by bridgey »

Hi All,
Great post! I had done something similar and your post should be recommended reading before buying and configuring a QNAP.

I have noticed that just running the swapoff -a command has worked in getting rid of the swap file and an update later and a few reboots the swapfile hasn't returned. I'll keep an eye out.

In addition to putting in an SSD as cache disk, I also put small felt pads on the disk trays and on the base of the overall unit to dampen any vibrations. This has helped tremendously. I would caution people on using the felt internally to use sparingly and make sure not stopping any of the air flow. So keep an eye on temp of disks. Though I did notice by raising the unit height a little with the felt, the air flow was better through the unit and the disks are running a few degrees cooler.
chris129
First post
Posts: 1
Joined: Mon Sep 03, 2018 11:37 pm

Re: Advanced guide to how I completely silenced my TS-453A

Post by chris129 »

Hi,

Could anyone using this method provide a feedback, now that we are a few months later, please?
Do you still use it? Is it transparent and doing fine with no harm done?

I discovered those weird "system" RAIDs as well on my TVS1282 when trying to understand how all my 8 disks could be working all the time all together when nothing was expected to be accessing my HDDs (but only the SSDs for the VMs and the system, or so I thought...). It is actually due to the virtualization station, doing stuff every 10 seconds or so on that md13, for some unclear reason. Obviously not a single disk ever goes to sleep due to that.

I then found this post, but I wonder how this is working in case of a reboot, if that annoying md13 is not synced on ALL the disks, but only two of them for instance (I'd liked to use only my 2x M.2 SSD for this only, and for sure no HDD) ?
Do you force a RAID resync as well right before a reboot, to make sure everything is consistent when the RAID is created again at the reboot time? (then what about "unexpected" reboots?)
Or is it not an issue? In that case, which disk will be used as the "master" one to resync all others, if their content is not consistent? The first one installed? A random one?
GGavan
New here
Posts: 2
Joined: Mon Mar 05, 2018 11:24 pm

Re: Advanced guide to how I completely silenced my TS-453A

Post by GGavan »

Hi chris129,

I'm still using this workaround. I'm not using the swap script, it seems to be enough for me.
I lost the power energy few times but still no problem with this.

I have 2 small SSDs in raid 1 as primary volume special for this issue and 2 x 10 TB as storage. I hope that QNAP will solve sometime this big problem because, I would like to use another 10 TB disk but with 453A I don't have other slots available :(, I can't to take the chance with one SSD and 3 HDDs

Thank you again, damga for sharing your idea and your effort with us!

I'm analyzing Synology DS918+ as replacement for this 453A because I don't see chances to be solved by QNAP. I will survive with 10TB and damga's workaround a period but then I have to do something. Does anybody knows if Sysnology has this spin down problem?
EsEnZeT
Getting the hang of things
Posts: 58
Joined: Sun Sep 30, 2018 2:43 am

Re: Advanced guide to how I completely silenced my TS-453A

Post by EsEnZeT »

Thank you for this article, it was very good read and important stuff! :)
Locked

Return to “HDD Spin Down (HDD Standby)”