How to gracefully power down HDDs on shutdown

  • Hi


    I have a scheduled job that automatically shuts down my Rock64 running OMV 5 at a specific time at night. Sadly my Rock64 doesn't support automatic startup so the only way to power it on is manually either using the physical power button or removing complete power (also pulling out the power barrel connector) and restoring the power. To get around this I use smart plugs to wake it up again.


    Now, powering on and off the equipment with the smart plugs isn't a problem except that when OMV shutdowns it's not safely powering off the HDDs too. This means when my smart plugs eventually power off the powered, USB 3 hub a couple of minutes later with the HDDs connected to it, it is forcefully cutting the power to fully spinning HDDs.


    I can rule out the hub not being the problem because safely ejecting the device in Windows gracefully spins down the HDDs.


    The automatic shutdown feature found at `System > Power Management` is very basic. Obviously first of all it's not spinning down the HDDs properly and secondly when a data transfer on SMB for example is in progress the automatic shutdown proceeds anyway without checking for system activity.


    I thought about using an additional Cron job to unmount and sleep the drives using `sudo hdparm -y /dev/sda1` but that caused issues when rebooting just the Rock64 alone. The HDDs seemed to be stuck in an infinite sleep and the Rock64 was unreachable until I completely power cycled the HDDs off and back on.


    The interesting thing is if I connect the external HDDs directly to the Rock64 eliminating the USB 3 hub, when I shutdown the Rock64 the HDDs do in fact power off but they don't do it gracefully and it's as though I'm just ripping the power out while they are running at full RPM, very much like what the smart plug does. Conversely, I would expect the shutdown stage to spin the HDD down then power off. All of this sudden powering off to the HDDs won't do the HDD heads any good.


    Any ideas how to get this working please?

  • The first thing to realize is, OMV does not shutdown the system. OMV is application that is layered onto Debian. OMV controls Debian and may trigger a shutdown, but the shutdown command itself is part of Debian.

    except that when OMV shutdowns it's not safely powering off the HDDs too.


    The days of manually "parking heads" before shutdown are long over. If power is removed from modern hard drives, as in the PC's cord is yanked from the wall or a power of is forced with the power button, hard drives are designed to autopark their heads while gliding on the cushion of air created by the still spinning platters. It works quite well.

    Power off Retract's are tracked by SMART attribute 192 - . One of my older drives has this count at 1216 and, thus far, it has been error free.


    Obviously first of all it's not spinning down the HDDs properly and secondly when a data transfer on SMB for example is in progress the automatic shutdown proceeds anyway without checking for system activity.

    I'm not sure what you mean by shutting down without checking system activity. On a shutdown, running programs are flushed and any writes to the disk, in progress, are finished.

    If programs are hung and refuse to respond to a graceful shutdown, in that case, data may be lost. However, the fault lays with the application. Not the operating system.

  • The days of manually "parking heads" before shutdown are long over. If power is removed from modern hard drives, as in the PC's cord is yanked from the wall or a power of is forced with the power button, hard drives are designed to autopark their heads while gliding on the cushion of air created by the still spinning platters. It works quite well.

    That sounds relieving. Is there a way I can diagnose why my USB switch that has the HDDs attached to it doesn't spin the HDDs down when my SoC shuts down?

  • Is there a way I can diagnose why my USB switch that has the HDDs attached to it

    This is a matter of the chipset used for the SATA to USB bridge. Different bridges have different behaviors and some actually filter out ATA drive commands.


    For example, without setting drives to spin down (HD-PARM or HD-IDLE), my drive docks spin them down on the their own. The dock "idle" the drives by themselves on what seems like a time interval. And, like you, when I shut down my R-PI the drives are still spinning. Still, it's nothing to worry about. At that point, with the host powered down, drives can be powered off with no ill effects.

  • This is a matter of the chipset used for the SATA to USB bridge. Different bridges have different behaviors and some actually filter out ATA drive commands.

    It is interesting that when safely ejecting on a Mac or Windows PC the drives do spin down. It is weird that Linux doesn't do this a part of its shut down procedure.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!