Skip to content

Instantly share code, notes, and snippets.

@silvio-didonna
Last active March 13, 2018 11:56
Show Gist options
  • Select an option

  • Save silvio-didonna/128e206115599275cf827eef64b36c8b to your computer and use it in GitHub Desktop.

Select an option

Save silvio-didonna/128e206115599275cf827eef64b36c8b to your computer and use it in GitHub Desktop.
#!/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
@silvio-didonna
Copy link
Author

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.

root@odroid:~# wget https://dn.odroid.com/5422/script/odroid.shutdown
root@odroid:~# sudo install -o root -g root -m 0755 ./odroid.shutdown /lib/systemd/system-shutdown/odroid.shutdown

If you face that “The certificate” message when you try wget command, you can add the option to solve it. –no-check-certificate -N

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment