Spin down hard disk

I split the home partition into one part now residing on a 250 GB SSD and an archive (soft linked to the users’ home) residing on a 2TB HDD. The HDD is shared with SAMBA and predominantly accessed via the TV set only. With my computer running for months without reboot I want the HDD to spin down during normal operation and spin up only when accessed through the TV set or when rsyncing to HDD. How can I accomplish that, query and log the status of the HDD?

You could try using HDPARM, see here for a handy arch wiki guide:

https://wiki.archlinux.org/index.php/Laptop-mode-tools

eg:

hdparm -S 60 /dev/sdc

/dev/sdc:
setting standby to 60 (5 minutes)

Here are some of the options:

-S Set standby (spindown) timeout
-B Set Advanced Power Management setting (1-255)
-M Get/set acoustic management (0-254, 128: quiet, 254: fast)
-y Put drive in standby mode
-Y Put drive to sleep

Installed Laptop Mode Tools, but still unsure what to do. Currently smartd is enabled and active, displaying some message every 30 minutes for /dev/sdb (HDD). UEFI has both SMART and SATA ALPM disabled. Should I have UEFI or openSUSE options enabled or both?

On 2015-01-14 12:46, karlmistelberger wrote:
>
> Dragon32;2689085 Wrote:
>> You could try using HDPARM, see here for a handy arch wiki
>> guide:https://wiki.archlinux.org/index.php/Laptop-mode-tools Installed Laptop Mode Tools, but still unsure what to do.
> Currently smartd is enabled and active,

That’s not the same as hdparm.

> Should I have UEFI or openSUSE options enabled or both?

Irrelevant for the spin down issue.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Many thanks for commenting. Deinstalled Laptop Mode Tools, reconfigured and restarted smartd, set spin down time to one hour and idled disk. Three partitions are mounted, but /dev/sdb stays idle until accessed:

erlangen:~ # diff /etc/smartd.conf~ /etc/smartd.conf
26,27c26,27
< DEVICESCAN -d removable
< 
---
> /dev/sda
> /dev/sdc
erlangen:~ # hdparm -S 242 /dev/sdb 

/dev/sdb:
 setting standby to 242 (1 hours)
erlangen:~ # hdparm -y /dev/sdb

/dev/sdb:
 issuing standby command
erlangen:~ # hdparm -C /dev/sdb

/dev/sdb:
 drive state is:  standby
erlangen:~ # 

Two problems not yet dealt with:

  • not enumerating /dev/sdb in /etc/smartd.cfg works well when the disk is down. The corresponding helper will exit with code 2. But when the disk is up, it will exit with code 0 preventing the disk from spinning down:

2015-01-15T20:28:30.768596+01:00 erlangen org.freedesktop.UDisks[687]: **** Refreshing ATA SMART data for /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
2015-01-15T20:28:30.769984+01:00 erlangen org.freedesktop.UDisks[687]: helper(pid  1923): launched job udisks-helper-ata-smart-collect on /dev/sda
2015-01-15T20:28:30.770766+01:00 erlangen org.freedesktop.UDisks[687]: **** Refreshing ATA SMART data for /sys/devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdc
2015-01-15T20:28:30.771568+01:00 erlangen org.freedesktop.UDisks[687]: helper(pid  1924): launched job udisks-helper-ata-smart-collect on /dev/sdc
2015-01-15T20:28:30.772150+01:00 erlangen org.freedesktop.UDisks[687]: **** Refreshing ATA SMART data for /sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sdb
2015-01-15T20:28:30.773346+01:00 erlangen org.freedesktop.UDisks[687]: helper(pid  1925): launched job udisks-helper-ata-smart-collect on /dev/sdb
2015-01-15T20:28:30.780354+01:00 erlangen org.freedesktop.UDisks[687]: **helper(pid  1925): completed with exit code 2**
2015-01-15T20:28:30.784291+01:00 erlangen org.freedesktop.UDisks[687]: helper(pid  1924): completed with exit code 0
2015-01-15T20:28:30.792412+01:00 erlangen org.freedesktop.UDisks[687]: **** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdc
2015-01-15T20:28:30.837115+01:00 erlangen org.freedesktop.UDisks[687]: helper(pid  1923): completed with exit code 0
2015-01-15T20:28:30.849846+01:00 erlangen org.freedesktop.UDisks[687]: **** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
  • when searching for some way to issue the hdparm -S 242 /dev/sdb command at boot time I found no solution for openSUSE. What is the recommended method for doing that?

On 2015-01-15 20:56, karlmistelberger wrote:
>
> Two problems not yet dealt with:
>
> - not enumerating /dev/sdb in /etc/smartd.cfg works well when the disk
> is down. The corresponding helper will exit with code 2. But when the
> disk is up, it will exit with code 0 preventing the disk from spinning
> down:

Notice that those messages are not from the smartd daemon, but udisks.

> - when searching for some way to issue the hdparm -S 242 /dev/sdb
> command at boot time I found no solution for openSUSE. What is the
> recommended method for doing that?
>

boot.local.

>


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Had some reading: man 7 udisks, UDisks Reference Manual: UDisks Reference Manual, files in /etc but I am still clueless with regard to stopping udisks-daemon looking for /dev/sdb. :frowning:

On 2015-01-18 09:26, karlmistelberger wrote:
>
> robin_listas;2689578 Wrote:
>> Notice that those messages are not from the smartd daemon, but udisks.Had some reading: man 7 udisks,
> http://udisks.freedesktop.org/docs/latest/, files in /etc but I am still
> clueless with regard to stopping udisks-daemon looking for /dev/sdb. :frowning:

Me too, sorry.

Maybe post a new question with subject about what to do to stop udisks
from doing smart related checks. IF it is really udisk which triggers
them, I’m unsure this moment if it only listens.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Running daemons are:

erlangen:/etc # ps ax|grep udisk
  543 ?        Sl     0:16 /usr/lib/udisks/udisks-daemon
  544 ?        S      0:00 udisks-daemon: not polling any devices
 1166 ?        Ssl    3:49 /usr/lib/udisks2/udisksd --no-debug
 6384 ?        Sl     0:02 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
32585 pts/0    S+     0:00 grep --color=auto udisk
erlangen:/etc # 

I got the following information by invoking udisks --monitor-detail:

changed:     /org/freedesktop/UDisks/devices/sdb
Showing information for /org/freedesktop/UDisks/devices/sdb
  native-path:                 /sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sdb
  device:                      8:16
  device-file:                 /dev/sdb
    presentation:              /dev/sdb
    by-id:                     /dev/disk/by-id/ata-ST2000DM001-1CH164_W3408N5F
    by-id:                     /dev/disk/by-id/scsi-1ATA_ST2000DM001-1CH164_W3408N5F
    by-id:                     /dev/disk/by-id/scsi-SATA_ST2000DM001-1CH1_W3408N5F
    by-id:                     /dev/disk/by-id/wwn-0x5000c5003d25fc49
    by-path:                   /dev/disk/by-path/pci-0000:00:1f.2-scsi-1:0:0:0
  detected at:                 Fri Jan  9 21:28:29 2015
  system internal:             1
  removable:                   0
  has media:                   1 (detected at Fri Jan  9 21:28:29 2015)
    detects change:            0
    detection by polling:      0
    detection inhibitable:     0
    detection inhibited:       0
  is read only:                0
  is mounted:                  0
  mount paths:             
  mounted by uid:              0
  presentation hide:           0
  presentation nopolicy:       0
  presentation name:           
  presentation icon:           
  automount hint:              
  size:                        2000398934016
  block size:                  512
  job underway:                no
  usage:                       
  type:                        
  version:                     
  uuid:                        
  label:                       
  partition table:
    scheme:                    mbr
    count:                     4
  drive:
    vendor:                    ATA
    model:                     ST2000DM001-1CH164
    revision:                  CC29
    serial:                    W3408N5F
    WWN:                       5000c5003d25fc49
    detachable:                0
    can spindown:              1
    rotational media:          Yes, at 7200 RPM
    write-cache:               enabled
    ejectable:                 0
    adapter:                   Unknown
    ports:
    similar devices:
    media:                     
      compat:                 
    interface:                 ata
    if speed:                  (unknown)
    ATA SMART:                 Updated at Sun Jan 18 08:28:30 2015
      overall assessment:      Good
===============================================================================
 Attribute       Current|Worst|Threshold  Status   Value       Type     Updates
===============================================================================
 raw-read-error-rate         117| 99|  6   good    157113160   Pre-fail Online 
 spin-up-time                 94| 94|  0    n/a    0           Pre-fail Online 
 start-stop-count            100|100| 20   good    33          Old-age  Online 
 reallocated-sector-count    100|100| 10   good    0 sectors   Pre-fail Online 
 seek-error-rate              74| 60| 30   good    27800124    Pre-fail Online 
 power-on-hours               95| 95|  0    n/a    198.4 days  Old-age  Online 
 spin-retry-count            100|100| 97   good    0           Pre-fail Online 
 power-cycle-count           100|100| 20   good    34          Old-age  Online 
 runtime-bad-block-total      99| 99|  0    n/a    1           Old-age  Online 
 end-to-end-error            100|100| 99   good    0           Old-age  Online 
 reported-uncorrect          100|100|  0    n/a    0 sectors   Old-age  Online 
 command-timeout             100|100|  0    n/a    0           Old-age  Online 
 high-fly-writes             100|100|  0    n/a    0           Old-age  Online 
 airflow-temperature-celsius  58| 54| 45   good    42C / 108F  Old-age  Online 
 g-sense-error-rate          100|100|  0    n/a    0           Old-age  Online 
 power-off-retract-count     100|100|  0    n/a    7           Old-age  Online 
 load-cycle-count             97| 97|  0    n/a    7089        Old-age  Online 
 temperature-celsius-2        42| 46|  0    n/a    42C / 108F  Old-age  Online 
 current-pending-sector      100|100|  0    n/a    0 sectors   Old-age  Online 
 offline-uncorrectable       100|100|  0    n/a    0 sectors   Old-age  Offline
 udma-crc-error-count        200|200|  0    n/a    0           Old-age  Online 
 head-flying-hours           100|253|  0    n/a    189.5 days  Old-age  Offline
 total-lbas-written          100|253|  0    n/a    145263155323 Old-age  Offline
 total-lbas-read             100|253|  0    n/a    92829440807 Old-age  Offline

Thus I am pretty sure that udisks prevents /dev/sdb from spinning down by accessing it every half hour. Nothing happens when disk is standby.

On 2015-01-18 18:26, karlmistelberger wrote:
> Thus I am pretty sure that udisks prevents /dev/sdb from spinning down
> by accessing it every half hour.

Yes, that can be.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Rebooted the machine and these pesky messages from udisks are gone. /dev/sdb now is mounted at boot time, idles down after one hour, but readily spins up when accessed by TV set and others and goes down again when idle. :slight_smile: Messages since midnight:

erlangen:/var/log # grep 2015-01-19 messages|grep sdb
2015-01-19T04:55:04.481635+01:00 erlangen kernel:     0.685801] sd 1:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB)
2015-01-19T04:55:04.481636+01:00 erlangen kernel:     0.685803] sd 1:0:0:0: [sdb] 4096-byte physical blocks
2015-01-19T04:55:04.481639+01:00 erlangen kernel:     0.685829] sd 1:0:0:0: [sdb] Write Protect is off
2015-01-19T04:55:04.481640+01:00 erlangen kernel:     0.685830] sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
2015-01-19T04:55:04.481640+01:00 erlangen kernel:     0.685839] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
2015-01-19T04:55:04.481653+01:00 erlangen kernel:     0.733325]  sdb: sdb1 sdb2 < sdb5 sdb6 >
2015-01-19T04:55:04.481654+01:00 erlangen kernel:     0.733468] sd 1:0:0:0: [sdb] Attached SCSI disk
2015-01-19T04:55:04.481902+01:00 erlangen kernel:     2.434002] EXT4-fs (sdb6): Mount option "noacl" will be removed by 3.5
2015-01-19T04:55:04.481906+01:00 erlangen kernel:     2.469819] EXT4-fs (sdb6): mounted filesystem with ordered data mode. Opts: noacl
2015-01-19T04:55:04.722581+01:00 erlangen boot.local[682]: /dev/sdb:
erlangen:/var/log # 

On 2015-01-19 07:56, karlmistelberger wrote:
>
> robin_listas;2689910 Wrote:
>> On 2015-01-18 18:26, karlmistelberger wrote:
>>> Thus I am pretty sure that udisks prevents /dev/sdb from spinning down
>>> by accessing it every half hour.
>>
>> Yes, that can be.

> Rebooted the machine and these pesky messages from udisks are gone.
> /dev/sdb now is mounted at boot time, idles down after one hour, but
> readily spins up when accessed by TV set and others and goes down again
> when idle. :slight_smile: Messages since midnight:

Good!

I wonder what changed :-?


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

smartd.conf, see post #5

On 2015-01-20 06:46, karlmistelberger wrote:
>
> robin_listas;2690045 Wrote:
>> I wonder what changed :-?smartd.conf, see post #5

And later you said the problem was not solved, you got messages from
udisks showing and triggering activity.

Then you say that after a reboot, udisks is not interfering.

So why is not udisk interfering now? smartd.conf does not alter udisks
behaviour.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

I checked messages since install of openSUSE. There were no udisks messages until I activated smartd. Upon changing smartd.conf and rebooting the messages were gone. I verified that smartd is enabled and running now.

On 2015-01-21 09:16, karlmistelberger wrote:

>> So why is not udisk interfering now? smartd.conf does not alter udisks
>> behaviour.

> I checked messages since install of openSUSE. There were no udisks
> messages until I activated smartd. Upon changing smartd.conf and
> rebooting the messages were gone. I verified that smartd is enabled and
> running now.

Interesting…

Maybe smartd was triggering tests or checks, and udisks was noticing.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Added a disk and enumerated them in smartd.cfg as follows:

erlangen:~ # grep -v '^#' /etc/smartd.conf
/dev/disk/by-id/scsi-SATA_Samsung_SSD_840S1DBNSCFA21657V
/dev/disk/by-id/scsi-SATA_ST2000DM001-1CH_W3408N5F -n standby
/dev/disk/by-id/scsi-SATA_Samsung_SSD_850S21PNXBGA67584B
/dev/disk/by-id/scsi-SATA_WDC_WD40EZRX-22_WD-WCC4E2FYXSNV -n standby
erlangen:~ #

All disks spin down on hdparm -y. The problem is with the last entry: This disk will never go down on issuing even when not accessed by any process:

erlangen:~ # mount /dev/sde1 /mnt
erlangen:~ # hdparm -y /dev/disk/by-id/scsi-SATA_WDC_WD40EZRX-22_WD-WCC4E2FYXSNV

/dev/disk/by-id/scsi-SATA_WDC_WD40EZRX-22_WD-WCC4E2FYXSNV:
 issuing standby command
erlangen:~ # hdparm -C /dev/disk/by-id/scsi-SATA_WDC_WD40EZRX-22_WD-WCC4E2FYXSNV

/dev/disk/by-id/scsi-SATA_WDC_WD40EZRX-22_WD-WCC4E2FYXSNV:
 drive state is:  active/idle
erlangen:~ # 

Any idea to fix this?

Hey, Mr. k, you might get spotted quicker if you start a new thread as that is probably a new problem? Just suggesting. I am heading out soon, but maybe my response might bring it to the attention of some of my forum friends.:wink:

My solution is to permanently freeze the udsiks2 process.>:( This lets all my disks spin down reliably, no matter their timeout:

/etc/cron.d/freeze-udisksd

* * * * * root pkill -SIGSTOP udisksd

The drawback is that the KDE open/save dialogs will freeze immediately until you unfreeze udisksd2. Same when starting KDE. Thankfully, this doesn’t spin the disks up again:

sudo pkill -SIGCONT udisksd

This method is reliable, but cumbersome. Just wanted to share it since I just uninstalled udisks2, and with it KDE – I can’t take it anymore.:’( I want to use KDE, but what does that matter when I’ve used Weston instead the last couple of years (mainly because X often won’t start).