Safely Power Down USB HDD's on System Shutdown

  • Hi


    I have quite a severe problem in which USB HDDs connected to a USB hub are not spinning down when the computer shuts down. This of course leaves me to forcefully power off the drives while they are still spinning. I've seen on other forums mentioning the Power-Off_Retract_Count attribute within S.M.A.R.T goes up and an audible clanking noise is heard. The quote from ODROID forums explains this too.

    Zitat

    "Symptom:

    With my mechanical harddisk everytime I shutdown I hear a noticeable *clack* sound from the disk.

    Everytime this happens this increases the SMART attribute "Power-Off_Retract_Count" by 1.

    This is indicative of a "hard" power cut to the disk, meaning emergency head parking is performed, which reduces the lifespan of the disk faster than normal head parking."

    Users on the ODROID forum have managed a workaround by using 'hdparm'. They come up with a script like the one below which runs through all the block storage devices and issues the 'put drive to sleep' command.

    Now while this script powers down the HDD's I'm having a difficult time trying to get this to work when the system shuts down. I'm fairly good with Linux but I have no idea how to get shutdown scripts to work. I've done some reading on SysVinit versus Systemd I understand creating scripts in '/etc/init.d/' and making a symbolic links to found at '/etc/init.d/' to 'rc.d/'. Most Unix systems use 'systemd' so I've tried to create a shutdown service such as the one below. For testing purposes I've disconnected all but one HDD and targeted a specific HDD I can use to constantly spin up and down within the script as I rather not do damage to drive with my data on.

    Bash: /root/hdd-shutdown.sh
    #!/bin/sh  
    hdparm -Y /dev/sdb && sleep 3  

    I would have liked to use udisksctl as this a dedicated power-off command. Unfortunately it doesn't work with shutdown scripts according to a forum I found somewhere. Someone was saying it has something to do wit D-Bus shutting too early therefore when the shutdown script tries to run the dependencies are not there.


    Any ideas how I can a working shutdown script that will shutdown my HDDs safely?

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!