HD Spin down

On new RPI4 image, I cannot spin down hd.
On previous versions of RPI, I could spin down disks with:

osmc@rpi4:~$ hdparm -S 241 /dev/sda1

/dev/sda1:
setting standby to 241 (30 minutes)
HDIO_DRIVE_CMD(setidle) failed: Inappropriate ioctl for device

Now it doesn’t work.
What is suggested method for spinning down mechanical disks?

Same hard drive and caddy?

Did you try sudo hdparm -S 241 /dev/sda1?

It executes with sudo.

osmc@rpi4:/mnt$ sudo hdparm -S 241 /dev/sda1

/dev/sda1:
setting standby to 241 (30 minutes)
osmc@rpi4:/mnt$

But still, there is no spin down.
On osmc@RPI3 and thi the same disk, it worked with no problems.

Then likely something is keeping IO to the disk open.

Is the Pi 3 on the same version of OSMC as the Pi 4?

Pi 3:

osmc@rpi3:~$ cat /etc/os-release
PRETTY_NAME=“Open Source Media Center”
NAME=“OSMC”
VERSION=“November 2020”
VERSION_ID=“2020.11-1”
ID=osmc
ID_LIKE=debian

ANSI_COLOR=“1;31”
HOME_URL=“https://www.osmc.tv
SUPPORT_URL=“https://www.osmc.tv
BUG_REPORT_URL=“https://www.osmc.tv

Pi 4:
osmc@rpi4:~$ cat /etc/os-release
PRETTY_NAME=“Open Source Media Center”
NAME=“OSMC”
VERSION=“August 2021”
VERSION_ID=“2021.08-1”
ID=osmc
ID_LIKE=debian

ANSI_COLOR=“1;31”
HOME_URL=“https://www.osmc.tv
SUPPORT_URL=“https://www.osmc.tv
BUG_REPORT_URL=“https://www.osmc.tv

On PI 3 I used to run hdparm from /etc/rc.local and everything worked well.

The devices are clearly on different versions.

I suspect that Kodi v19 may behave differently or your skins / add-ons may be different.

Sam, we could test your theory in a way to bring down mediacenter, run hdparm and wait for spin down.
If it spins down, you theory is correct.
I will do it right now, and report back results here.

osmc@rpi4:~$ systemctl stop mediacenter
osmc@rpi4:~$ sudo hdparm -S 2 /dev/sda1

/dev/sda1:
setting standby to 2 (10 seconds)
osmc@rpi4:~$

But the disk is still running (after much more than 10 seconds). :smirk:

Looks like it is not kodi related or I am missing something.

I found that I can spin down disk with:
osmc@rpi4:~$ sudo hdparm -y /dev/sda1

and if it helps:

osmc@rpi4:~$ sudo hdparm -B /dev/sda1

/dev/sda1:
APM_level = not supported

Run

sudo lsof | grep /media/

(/media/ assuming you use the automounter). That would show if there are files being opened on the disk.

Looks like you already in the past needed to use a manual approach

My disk is WD Green 4TB as well.
I have put it back on PI 3 for comparison, and I found that spin down is not working on it.
Looks like I have lost this feature with some osmc update. I am sure it worked in the past.

on PI 3 the disc is mounted as:
/dev/sda1 on /mnt/wde4tb type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)

root@rpi3:/mnt# hdparm -B /dev/sda1

/dev/sda1:
APM_level = not supported
root@rpi3:/mnt# hdparm -S 2 /dev/sda1

/dev/sda1:
setting standby to 2 (10 seconds)

  • not spinning down

On PI 4 it is mounted as:
/dev/sda1 on /mnt/wde4tb type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)

On PI 3 or PI 4, lsof doesn’t return anything:
root@rpi4:/home/osmc# lsof | grep wde4tb
root@rpi4:/home/osmc#

Looks like after some osmc upgrade from the past I don’t have this option anymore.

I also saw hdparm option:
-J Get/set Western DIgital “Idle3” timeout for a WDC “Green” drive (DANGEROUS)

Has enyone used it, or have some experience with it?

Well, I have found the solution for the problem.
Long time ago, in year 2016, I had a similar discussion in this forum.
In mean time, I thought that osmc has solved this problem for us, so I forgot about it.
Now when I installed PI 4, as the disc was always on, looks like I was wrong.

Anyway, at one point in year 2016, @cocomic (thanks again) suggested a solution in his reply External USB HDD is not spinning down - #22 by cocomic

So, all you have to do is:
in /etc/rc.local put:

hdparm -S241 /dev/sdx (value 241 is for 30 minutes)

in /etc/udev/rules.d/80-udisks.rules put:

KERNEL==“sd*[!0-9]”, ATTR{removable}==“0”, ENV{ID_BUS}==“usb”, ENV{DEVTYPE}==“disk”, ENV{UDISKS_DISABLE_POLLING}=“1”
KERNEL==“sd*[!0-9]”, ATTR{removable}==“0”, ENV{ID_BUS}==“ata”, ENV{DEVTYPE}==“disk”, ENV{UDISKS_DISABLE_POLLING}=“1”
KERNEL==“sd*[!0-9]”, ATTR{removable}==“0”, ENV{ID_BUS}==“scsi”, ENV{DEVTYPE}==“disk”, ENV{ID_VENDOR}==“ATA”, ENV{UDISKS_DISABLE_POLLING}=“1”

That’s all.
Enjoy jour quite time.
HTH

Please post a log from your system – I suspect you have additional packages installed which are causing interference.

Sam which log do you need?

As I proof that everything works well, I have created a cron script that reads disk state (hdparm -C /dev/sdx) every 5 minutes and puts it into the log. Here is the output:

root@rpi4:~# tail -f hdparm.log | grep "drive state is"
 drive state is:  standby
 drive state is:  standby
 drive state is:  standby
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  standby
 drive state is:  standby

As you can see there are 6 (5*6=30 min) active/idle, and than disk goes into standby.

Full system logs – because I suspect something like smartmontools is installed, which will intefere…

You mean from kodi osmc add-on?
At the moment I don’t have access to the TV, but I have an access ot PI over ssh.
Please, give to me a shell command whose output you heed.

grab-logs -A