{"id":311,"date":"2013-05-19T14:34:54","date_gmt":"2013-05-19T14:34:54","guid":{"rendered":"http:\/\/www.buildcube.com\/tech_blog\/?p=311"},"modified":"2025-08-21T12:34:59","modified_gmt":"2025-08-21T12:34:59","slug":"disk-spindown-in-linux-specifeying-spindown-idle-time","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2013\/05\/19\/disk-spindown-in-linux-specifeying-spindown-idle-time\/","title":{"rendered":"Disk spindown in linux, specifeying spindown idle time"},"content":{"rendered":"\n<p>Update\/2025: The old info below (Startiong with the title spindown) no longer works as what used to be expected back then, the new expected behavior changed, today, if you try this on your drives, it may or may not work due to a bug-fix that fixes a bug that is 15 years old !<\/p>\n\n\n\n<p>Note: &#8220;Gnome disk spindown&#8221; = If you are using gnome (GUI), this is all irrelevant to you, you will need to open the disks application, select the disk on the left menu, and from the three dots menu, go to drive settings, and enable spindown.<\/p>\n\n\n\n<p>So there are 2 conditions<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>the device is not attached via USB or Firewire<\/li>\n\n\n\n<li>supports APM<\/li>\n<\/ul>\n\n\n\n<p>For the impatient, a workaround is to use udev rules, you start by checking that the following command &#8220;grep . \/sys\/class\/block\/sdb\/device\/power\/*&#8221; to find out what&#8217;s currently set for autosuspend control, if it returns either &#8220;control:on&#8221; or &#8220;autosuspend_delay_ms as empty&#8221;, proceed, So let us get down to business<\/p>\n\n\n\n<p>So, to test this out, try it without making it perminent, the following line should spin down your disk after 1 minute<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo 5000 | sudo tee \/sys\/class\/block\/sdc\/device\/power\/autosuspend_delay_ms<br>echo auto | sudo tee \/sys\/class\/block\/sdc\/device\/power\/control<\/pre>\n\n\n\n<p>If the above worked for you, you can simply add the following rules file to make those settings permanent <\/p>\n\n\n\n<p>Create the file &#8220;\/etc\/udev\/rules.d\/99-spindown-disks.rules&#8221; and put the following contents in it<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ACTION==\"add\", SUBSYSTEM==\"block\", KERNEL==\"sd[a-z]\", TEST==\"device\/power\/autosuspend_delay_ms\", ATTR{device\/power\/autosuspend_delay_ms}=\"15000\"<br>ACTION==\"add\", SUBSYSTEM==\"block\", KERNEL==\"sd[a-z]\", TEST==\"device\/power\/control\", ATTR{device\/power\/control}=\"auto\"<\/pre>\n\n\n\n<p>A different work around is using the package &#8220;<a href=\"https:\/\/github.com\/adelolmo\/hd-idle\">https:\/\/github.com\/adelolmo\/hd-idle<\/a>&#8221; \ud83d\ude09<\/p>\n\n\n\n<p>Spinning the disks down manually (hdparm -Y \/dev\/sdc) works instantly, no problems there !<\/p>\n\n\n\n<p>Setting this directly with the &#8220;hdparm -S 240 \/dev\/sdb&#8221; for example should work (need to check), but not through hdparm.conf !<\/p>\n\n\n\n<p>So how do i know this criteria is what is stopping me from using the config file to spin things down ? i tried this command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hdparm -B \/dev\/sda<br><br>\/dev\/sda:<br> APM_level\t= not supported<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disk Spin down (Tested with Bullseye 2022)<\/h2>\n\n\n\n<p>Even though everything concerning block devices in linux has shifted to unique identifiers, hdparm has not, and will still use the old \/dev\/sdx system<\/p>\n\n\n\n<p>To control disk spindown, and to manually issue commands, you will need to have the package installed<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-get install hdparm<\/pre>\n\n\n\n<p>There is a probelm with disk spindown via hdparm, the problem is that you must address a disk as \/dev\/sdc , which changes in the case of USB media and other disks, even when you add slaves,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hdparm -Y \/dev\/sdb will spin a disk down instantly<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">hdparm -S 240 \/dev\/sdb will set this disk to sleep when idle for 20 minutes (5 second units here)<\/pre>\n\n\n\n<p>or adding at the bottom of the file \/etc\/hdparm.conf a section such as<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/dev\/sdc {<br>spindown_time = 240<br>}<\/pre>\n\n\n\n<p>to make those changes persistent across reboots.<\/p>\n\n\n\n<p>The new way of doing this is using the disk ID, to find the disk ID, run the command <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ls -l \/dev\/disk\/by-id<\/pre>\n\n\n\n<p>once you know your disk ID, the block should look like this<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># My 3TB WD green <br>\/dev\/disk\/by-id\/ata-WDC_WD30EZRX-00MMMB0_WD-WMAWZ0299541 {<br>        spindown_time = 240<br>}<\/pre>\n\n\n\n<p>To check the status of a disk, here is what you do<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hdparm -C \/dev\/sde<\/pre>\n\n\n\n<p>You could get one of the following results<br>When spun down&#8230;<br>drive state is: standby<br>When active<br>drive state is: active\/idle<\/p>\n\n\n\n<p>Don&#8217;t make your disks spin-down too often, 20 minutes is good for me almost in all circumstances.<\/p>\n\n\n\n<p>If the disks don&#8217;t spin down, chances are that selftest is enabled&#8230;<\/p>\n\n\n\n<p>Check if it is enabled with<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">smartctl -a \/dev\/sdb<br>if it reads<br>Auto Offline Data Collection: Enabled.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">then you need to disable it with<br>smartctl --offlineauto=off \/dev\/sdb<\/pre>\n\n\n\n<p>then wait for them to finish (if a test is running) then spin down.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update\/2025: The old info below (Startiong with the title spindown) no longer works as what used to be expected back then, the new expected behavior changed, today, if you try this on your drives, it may or may not work due to a bug-fix that fixes a bug that is 15 years old ! Note: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,215,9],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","hentry","category-hard-disks","category-hdparm","category-pc-hardware"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":18,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":5674,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions\/5674"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}