Last active
March 13, 2018 11:56
-
-
Save silvio-didonna/128e206115599275cf827eef64b36c8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| exec </dev/null </dev/null 2>/dev/null | |
| export LANG=C LC_ALL=C | |
| # In all cases, we want the media to be in quiescent, clean state. | |
| sync | |
| [ -x /sbin/mdadm ] && /sbin/mdadm --wait-clean --scan | |
| # Function used to park all SATA disks. | |
| function ParkDisks() { | |
| if [ -x /sbin/hdparm ]; then | |
| Wait=0 | |
| for Dev in /sys/block/sd* ; do | |
| # [ -e $Dev ] && /sbin/hdparm -y /dev/${Dev##*/} && Wait=2 | |
| [ -e $Dev ] && /sbin/hdparm -B127 /dev/${Dev##*/} && Wait=2 | |
| sleep $Wait | |
| echo 1 > /sys/class/block/${Dev##*/}/device/delete | |
| done | |
| sleep $Wait | |
| fi | |
| } | |
| case "$1" in | |
| # reboot|kexec) | |
| # Do not park disks when rebooting or switching kernels. | |
| # ;; | |
| *) | |
| ParkDisks | |
| ;; | |
| esac |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified code from https://wiki.odroid.com/odroid-xu4/troubleshooting/shutdown_script
Hard Drive Disk Parking Safely
There is sound “clack” you can hear from the HDD when the system almost the end of power-off process.
It is caused decrease lifecycle to your HDD and could be damaged in the worst case.
I think that it needs lots of time to fix that behavior. so I recommend using this script as a workaround.
This script makes your HDD safely to park. no sound, no increases the SMART attribute Power-Off_Retract_Count at all.
If you face that “The certificate” message when you try wget command, you can add the option to solve it.
–no-check-certificate -N