[GUIDE, Raspberry Pi]: Safely turn off external hard drive on shutdown

  • Hi,


    This tutorial is for everyone who is using an external hard drive with the Raspberry Pi and wants to use a safe method to power the drive down when rebooting/shutting down the Pi.


    The problem: When powering down/rebooting the Pi, the connected hard drive won't spin down before Pi's power off. Instead power to the drive is abruptly cut off, resulting in an unpleasant clicking noise from the drive as it tries to jam the head to its parking position before the platter stops spinning.


    Tutorial

    To solve this issue we can use a small script which gets called right before shutdown (more specifically system halt).

    Simply create a new script inside /lib/systemd/system-shutdown:

    Code
    cd /lib/systemd/system-shutdown
    sudo nano safe_spindown.sh


    I'm using the drive /dev/sda with a partition called /dev/sda1. Replace it with your setup.

    Insert this into the script:

    Save it (CTRL+O) and exit nano (CTRL+X).


    Don't forget to make the new script executable:

    Code
    sudo chmod +x safe_spindown.sh


    That's it! Now the drive will spin down before the Pi cuts off power to it. It should definitely be better for the drive compared to just cutting power to it while it's still running.


    For more info on systemd-shutdown/halt see:

    https://www.freedesktop.org/so…systemd-halt.service.html

    https://www.freedesktop.org/software/systemd/man/bootup.html


    Or using man in shell:

    Code
    man systemd-halt.service
    man bootup
  • ryecoaaron

    Hat das Thema freigeschaltet.
  • ryecoaaron

    Hat das Thema freigeschaltet.

Jetzt mitmachen!

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