How to turn USB HDD properly off when shutting down OSMC

I have purchased a new USB HDD, a 1 TB Western Digital My Passport. It has a single NTFS partition and it works perfectly now both with my Raspberry Pi 3 B+ and the OSMC/Kodi, the playback is flawless and it mounts and works with the HDD out of the box. The question I have this time however is: how do I properly dismount and turn off the HDD when shutting down OSMC/Pi? I use the ‘Power off system’ option from Kodi in OSMC and it shuts down the Pi properly and with no errors, however when the Pi finally turns off (the green LED turns off and only the red one remains) I hear a click in the WD USB HDD as if the drive head was skipping or it was hitting something, a rather unpleasant metallic click. How do I make sure I’m dismounting and turning the HDD off properly when shutting down OSMC so I don’t damage the USB HDD?

The filesystem will be unmounted during the shut down process.

I would assume that it is the head parking

1 Like


I had this issue too did not like the sudden click from hard drive did not sound good. What did was run hdparm in a shutdown script now it powers down gracefully. Make a script file with the line

hdparm -y /dev/sda1

Your hard drive may not be sda1. Run blkid in ssh to see dev name for yours. (Usually is sda1 with one hard drive attached)

And place it in /lib/systemd/system-shutdown

Hope this helps :slightly_smiling_face:

1 Like

Thanks a lot for the suggestion, I’ll definitely try the hdparm scrip in system-shutdown and let you know!

I added a script with a single line in the system-shutdown folder with the hdparm command and it still makes that clicking noise when shutting down the Pi from the Kodi interface.

Did you reboot the pi after copying over the script as it won’t read it until a reboot.

Also make sure the script has read write permissions.

Can you paste the contents of your script file

I did restart it. Here is the info:

root@osmc:/lib/systemd/system-shutdown# ls -al
total 12
drwxr-xr-x 2 root root 4096 Oct 29 21:10 .
drwxr-xr-x 8 root root 4096 Aug  5 19:22 ..
-rwxrwxrwx 1 root root   20 Oct 29 21:10 shutdown_hdd
root@osmc:/lib/systemd/system-shutdown# cat shutdown_hdd
hdparm -y /dev/sda1

A couple of points:

First, you’re shutting down the disk device, not the partition, so strictly speaking that should be /dev/sda. (Not sure if it makes a difference.)

As good practice, I’d recommend that you use the fully-qualified path for hdparm, which is /sbin/hdparm. and, or completeness, add the line #!/bin/sh above your hdparm command. There’s also no need to make the script globally writable - or even globally executable.

1 Like

Does the hard drive shutdown if you run the hdparm command in ssh?

Add the #!/bin/sh command to top of sh file like @dillthedog said

So the file should look like

hdparm -y /dev/sda1

It would need to be unmounted first.

hdparm won’t work when unmounted I assume?

I added the #!/bin line and also explicited the hdparm path (/sbin…) and changed /dev/sda1 to dev/sda and restarted and now it seems to work. Shutting off from Kodi I hear absolutely no noise from the HDD anymore when it shuts down. For reference the script now is

/sbin/hdparm -y /dev/sda

and it seems to have done the trick.

Glad you got it working :+1:

1 Like