HC1/HC2 - properly park harddisk on shutdown
-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
HC1/HC2 - properly park harddisk on shutdown
With the firmware utility the harddisk no longer autoparks constantly when not in use -> very good.
However, on HC1 shutdown the harddisk is not properly parked.
Observed on both official xenial 4.9. as well as Armbian.
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.
Workaround:
Unmount all filesystems from /dev/sda.
Give disk command to spin-down itself in a controlled way, e.g. by "hdparm -y /dev/sda".
Then do shutdown.
"Power-Off_Retract_Count" does not increase.
The HC1 is special in that the disk hangs of a USB/SATA bridge, so maybe this case is not properly handled in default shutdown scripts?
Ideally, something needs to check during shutdown that the disk is still spinning (e.g. hdparm -C) and if yes, park the disk.
However, on HC1 shutdown the harddisk is not properly parked.
Observed on both official xenial 4.9. as well as Armbian.
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.
Workaround:
Unmount all filesystems from /dev/sda.
Give disk command to spin-down itself in a controlled way, e.g. by "hdparm -y /dev/sda".
Then do shutdown.
"Power-Off_Retract_Count" does not increase.
The HC1 is special in that the disk hangs of a USB/SATA bridge, so maybe this case is not properly handled in default shutdown scripts?
Ideally, something needs to check during shutdown that the disk is still spinning (e.g. hdparm -C) and if yes, park the disk.
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
It seems to be working.fvolk wrote:Unmount all filesystems from /dev/sda.
Give disk command to spin-down itself in a controlled way, e.g. by "hdparm -y /dev/sda".
Then do shutdown.
"Power-Off_Retract_Count" does not increase.
Code: Select all
root@odroid:~# alias poweroff='udisksctl unmount -b /dev/sda1 && udisksctl power-off -b /dev/sda && poweroff'
root@odroid:~# poweroff
-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
While a custom poweroff command alias is a workaround, I think most users don't know or are even aware of this problem.
This should be handled in the shutdown scripts after fs unmounts from sda. Does anyone know where is the proper location in the shutdown scripts?
Especially SSD users do not "hear" a difference, but I read SSDs are even more sensitive to hard power cuts than mechanical disks. On a Samsung SSD I found the SMART attribute "POR_Recovery_Count" that records unclean shutdowns. Anyone with an SSD can report whether they see increases?
This should be handled in the shutdown scripts after fs unmounts from sda. Does anyone know where is the proper location in the shutdown scripts?
Especially SSD users do not "hear" a difference, but I read SSDs are even more sensitive to hard power cuts than mechanical disks. On a Samsung SSD I found the SMART attribute "POR_Recovery_Count" that records unclean shutdowns. Anyone with an SSD can report whether they see increases?
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
POR_Recovery_Count increases with a Samsung EVO 840 regardless of using internal JMS578 or external (ROCK64 SATA cable), it also doesn't matter whether I use firmware v173.01.00.01 or the SATA cable's original v0.4.0.5)
Sending the disk to sleep manually prior to shutting the board down prevents increasing the counter.
Sending the disk to sleep manually prior to shutting the board down prevents increasing the counter.
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
I tested now with an ASM1153 enclosure (no problems at all, serial number reported correctly, no SAT / spindown problems, no POR increase at shutdown) and another JMicron. JMS567 with different firmware showing exactly same symptoms:
Attribute 235 value increases with every shutdown when the disk hasn't been sent to sleep/standby before. So this smells like an issue that has to be adressed at the firmware layer?
Code: Select all
root@odroidxu4:~# smartctl -a -d sat /dev/sdb | grep POR_Recovery_Count
235 POR_Recovery_Count 0x0012 099 099 000 Old_age Always - 607
root@odroidxu4:~# JMS578FwUpdater/JMS578FwUpdate -d /dev/sdb -v
Bridge Firmware Version: v46.3.0.2
- odroid
- Site Admin
- Posts: 39399
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 2622 times
- Been thanked: 1432 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
I think so. We may need to contact Jmicron people again.
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
I got a beta firmware from JMicron but can not test currently. So anyone curious might try it and report back:
http://kaiser-edv.de/tmp/mUCIx3/JMS578_ ... 1_beta.zip (ZIP MD5 hash is 9ce5c93b2f8ba501606c46b2dbcc9d9d)
http://kaiser-edv.de/tmp/mUCIx3/JMS578_ ... 1_beta.zip (ZIP MD5 hash is 9ce5c93b2f8ba501606c46b2dbcc9d9d)
-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1 - properly park harddisk on shutdown
fvolk wrote:This should be handled in the shutdown scripts after fs unmounts from sda. Does anyone know where is the proper location in the shutdown scripts?
/lib/systemd/system-shutdown/*.shutdown
.We should use
blkid -o device
to obtain the list of devices to unmount and power-off (in a loop, discarding errors), rather than hard-code sda. For example, we might use /lib/systemd/system-shutdown/poweroff-unmount.shutdown
(untested):Code: Select all
#!/bin/sh
exec >/dev/null 2>/dev/null
for dev in $(blkid -o device) ; do
udisksctl unmount -b $dev
done
for dev in $(blkid -o device) ; do
udiskctl power-off -b $dev
done
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
I've tested some commands with no issues.tkaiser wrote:I got a beta firmware from JMicron but can not test currently. So anyone curious might try it and report back:
http://kaiser-edv.de/tmp/mUCIx3/JMS578_ ... 1_beta.zip (ZIP MD5 hash is 9ce5c93b2f8ba501606c46b2dbcc9d9d)
1. hdparm -C /dev/sda
2. hdparm -y /dev/sda
3. hdparm -S 20 /dev/sda
4. smartctl -x /dev/sda -d sat
5. fstrim /media/hdd/
6. Copy 8G file to /media/hdd/samba folder via SAMBA
Code: Select all
root@odroid:~/JMS578FwUpdater# ./JMS578FwUpdate -d /dev/sda -v
Bridge Firmware Version: v255.1.0.1
root@odroid:~/JMS578FwUpdater#
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
Good to know but this firmware version should additionally fix the Power-Off Retract Count issue (cutting the power too early on shutdown/poweroff which leads to a noticable 'clack' sound with connected HDDs and increasing the appropriate SMART value). Any news here?neal wrote:tkaiser wrote:I've tested some commands with no issues.
-
- Posts: 3
- Joined: Tue Nov 28, 2017 4:23 am
- languages_spoken: english
- ODROIDs: Odroid HC1
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1 - properly park harddisk on shutdown
this fix did not change anythingGood to know but this firmware version should additionally fix the Power-Off Retract Count issue (cutting the power too early on shutdown/poweroff which leads to a noticable 'clack' sound with connected HDDs and increasing the appropriate SMART value). Any news here?
.... when switching off HC1
then you can hear a sudden clicking of the HDD ..
Code: Select all
root@odroidxu4:~/JMS578FwUpdater# ./JMS578FwUpdate -d /dev/sda -v
Bridge Firmware Version: v255.1.0.1
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
Did your JMS578 device go through a full power cycle (completely powered off for some seconds after applying the firmware update)?kris777 wrote:this fix did not change anything
-
- Posts: 3
- Joined: Tue Nov 28, 2017 4:23 am
- languages_spoken: english
- ODROIDs: Odroid HC1
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1 - properly park harddisk on shutdown
Yes ...Did your JMS578 device go through a full power cycle (completely powered off for some seconds after applying the firmware update)?
I had to disconnect HC1 for a moment from the power supply because otherwise it showed me the old version of JMS578 Firmware : v173.01.00.01
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
Yes, same herekris777 wrote:this fix did not change anythingGood to know but this firmware version should additionally fix the Power-Off Retract Count issue (cutting the power too early on shutdown/poweroff which leads to a noticable 'clack' sound with connected HDDs and increasing the appropriate SMART value). Any news here?
.... when switching off HC1
then you can hear a sudden clicking of the HDD ..
Code: Select all
root@odroidxu4:~/JMS578FwUpdater# ./JMS578FwUpdate -d /dev/sda -v Bridge Firmware Version: v255.1.0.1

-
- Posts: 1
- Joined: Wed Jan 17, 2018 9:38 pm
- languages_spoken: french, english
- ODROIDs: odroid-XU
odroid-HC1
odroid-W - Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1 - properly park harddisk on shutdown
Hi folks !Nominal Animal wrote:fvolk wrote:This should be handled in the shutdown scripts after fs unmounts from sda. Does anyone know where is the proper location in the shutdown scripts?/lib/systemd/system-shutdown/*.shutdown
.
We should useblkid -o device
to obtain the list of devices to unmount and power-off (in a loop, discarding errors), rather than hard-code sda. For example, we might use/lib/systemd/system-shutdown/poweroff-unmount.shutdown
(untested):Code: Select all
#!/bin/sh exec >/dev/null 2>/dev/null for dev in $(blkid -o device) ; do udisksctl unmount -b $dev done for dev in $(blkid -o device) ; do udiskctl power-off -b $dev done
I managed to build a little script following these instructions and it works !!
My HDD do not "CLICK!" any more at poweroff.
/lib/systemd/system-shutdown/stop-sd
Code: Select all
#!/bin/sh
exec >/dev/null 2>/dev/null
stop_disk()
{
/sbin/hdparm -Y $1
sleep 5s
}
stop_all_disks()
{
#Partition selection...
# for dev in $(blkid -o device) ; do
# umount -b $dev
# done
#Disk selection without duplicates...
for dev in $(blkid -o device | grep /dev/sd | sed -re 's/(\/dev\/sd[a-z])[0-9]/\1/' | sort -u) ; do
stop_disk $dev
done
}
case $1 in
halt)
stop_all_disks
;;
poweroff)
stop_all_disks
;;
esac
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
I wouldn't rely on blkid since this wakes up sleeping disks (only to send them to sleep directly after again). Directly querying the kernel seems to be more straightforward (same with waiting only if the device in question understands the hdparm command):
Code: Select all
#!/bin/bash
exec >/dev/null 2>&1
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
case $1 in
halt|poweroff)
awk -F" " '/sd[a-z]$/ {print $4}' /proc/partitions | while read ; do
hdparm -Y /dev/${REPLY} && sleep 2.5
done
;;
esac
-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1 - properly park harddisk on shutdown
Good point. Perhaps the following would be even better?tkaiser wrote:I wouldn't rely on blkid since this wakes up sleeping disks (only to send them to sleep directly after again).
Code: Select all
#!/bin/bash
export LANG=C LC_ALL=C >/dev/null 2>/dev/null
case "$1" in
halt|poweroff)
# Ensure unwritten data is synced to disk.
sync
# Sync md arrays, if any
[ -x /sbin/mdadm ] && /sbin/mdadm --wait-clean --scan
# Put known SATA/IDE devices to sleep
wait=0
for dev in /sys/block/sd* ; do
[ -e $dev ] && hdparm -Y /dev/${dev##*/} && wait=3
done
sleep $wait
;;
esac
sd
to sleep. If at least one accepted the command, we'll sleep for three seconds, just to be sure.- odroid
- Site Admin
- Posts: 39399
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 2622 times
- Been thanked: 1432 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Very nice ideas indeed.
I've changed this topic "STICKY".
I've changed this topic "STICKY".
-
- Posts: 772
- Joined: Mon Nov 09, 2015 12:30 am
- languages_spoken: english
- ODROIDs: C1+, C2, XU4, HC1
- Has thanked: 2 times
- Been thanked: 24 times
- Contact:
Re: HC1 - properly park harddisk on shutdown
That's exactly what the regex '/sd[a-z]$/' does (skipping all partitions and only taking care about devices. /sys/block/sd* should work of course too but I try to avoid /sys/ when possible since I have to deal with some Linux systems where CONFIG_SYSFS=n is set for whatever weird reasons).Nominal Animal wrote:Instead of looking at the partitions the kernel knows about, let's put all block devices the kernel knows that begin withsd
to sleep.
Anyway... those users who tested the new firmware... with which kernel version did you give it a try? Asking since I experienced different behaviour with different kernel versions (on different platforms -- eg. an ASM1153E that worked pretty well with XU4/HC1 and 4.14 kernel showed same power-off retract count behaviour with RK3328 4.4 BSP kernel).
-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1 - properly park harddisk on shutdown
The situation I'm worried about, is when a user has an an external USB drive, and has it unmounted, and then powers off the machine.tkaiser wrote:That's exactly what the regex '/sd[a-z]$/' does (skipping all partitions and only taking care about devices.
/proc/partitions
won't list it or its partitions, but it'll still be visible in /sys/block/
. I would like to handle those situations, too.-
- Posts: 3
- Joined: Tue Nov 28, 2017 4:23 am
- languages_spoken: english
- ODROIDs: Odroid HC1
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
thanks @sebsan / @ Nominal Animal
I checked this fix works ..... there is no more clicking !
but it takes a long time to disconnect power from HC1 .... but it's not a problem
regards!
I checked this fix works ..... there is no more clicking !
but it takes a long time to disconnect power from HC1 .... but it's not a problem

regards!
-
- Posts: 4
- Joined: Thu Jan 11, 2018 11:53 pm
- languages_spoken: english
- ODROIDs: HC1
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
So, I installed OMV_3_0_92_Odroidxu4_4.9.61.img.xz on my HC1 and updated the installation. Do I have to worry about HDD parking on shutdown from the OMV web interface of my installation or do I have do fix something or wait for a new release? Sorry, this is not clear for me.
-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
First of all, thanks to everyone for contributing to solve this issue.
I copied the script from viewtopic.php?f=97&t=29069#p211653
to /lib/systemd/system-shutdown/stop-sd.shutdown,
made it chmod +x, hdparm is installed, and.... doesn't work.
Do I have to do anything else? Or enable it explicitly somehow?
I copied the script from viewtopic.php?f=97&t=29069#p211653
to /lib/systemd/system-shutdown/stop-sd.shutdown,
made it chmod +x, hdparm is installed, and.... doesn't work.
Do I have to do anything else? Or enable it explicitly somehow?
-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Can you show the output offvolk wrote:doesn't work.
ls -laF /sys/block/ /lib/systemd/system-shutdown/
?It's probably a typo in the scriptlet I made; I cannot test it myself, because I'm still working on my power supply and microcontroller board for HC1, and stalled due to lack of test equipment. (A friend with those has offered to help me, though!)fvolk wrote:Do I have to do anything else? Or enable it explicitly somehow?
If you don't mind, I can walk you through the steps to make sure it works right.
Otherwise, consider using this simplified version,
/lib/systemd/system-shutdown/simple.shutdown
:
Code: Select all
#!/bin/bash
exec </dev/null >/dev/null 2>/dev/null
export LANG=C LC_ALL=C
sync
[ -x /sbin/mdadm ] && /sbin/mdadm --wait-clean --scan
Wait=0
for Dev in /sys/block/sd* ; do
[ -e $Dev ] && hdparm -Y /dev/${Dev##*/} && Wait=3
done
sleep $Wait
-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Tried this one, commented the line with mdadm because I don't have that, and this one works.
Tried two different cases:
1) Call "/lib/systemd/system-shutdown/stop-sd.shutdown" manually, then type "reboot"
2) Just type "reboot".
Both cases seems to spin-down the harddisk properly, SMART counter does not increase, the hard *clack* noise is gone. Yay!
However, when after reboot the disk spins up again I hear a difference: In case 1 the disk spins up normally, in case 2 the disk spins up, seems to loose power for a fraction of a second and struggles, and then continues its spin up. So something is different here, depending how you send the disk to sleep on reboot, manually first or in a system shutdown process/script.
Tried two different cases:
1) Call "/lib/systemd/system-shutdown/stop-sd.shutdown" manually, then type "reboot"
2) Just type "reboot".
Both cases seems to spin-down the harddisk properly, SMART counter does not increase, the hard *clack* noise is gone. Yay!

However, when after reboot the disk spins up again I hear a difference: In case 1 the disk spins up normally, in case 2 the disk spins up, seems to loose power for a fraction of a second and struggles, and then continues its spin up. So something is different here, depending how you send the disk to sleep on reboot, manually first or in a system shutdown process/script.
-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
The line should be completely safe to leave in. If you don't have an executablefvolk wrote:commented the line with mdadm because I don't have that
/sbin/mdadm
, the line does nothing.That is to be expected of the simplified version. The script should get called with a parameter, that describes the situation:fvolk wrote:the disk spins up, seems to loose power for a fraction of a second and struggles, and then continues its spin up.
halt
, poweroff
, reboot
, or kexec
. We want to avoid running the script in the reboot
and kexec
cases, as otherwise there will be that three-second hiccup then.Perhaps this one will perform better?
/lib/systemd/system-shutdown/odroid.shutdown
:
Code: Select all
#!/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=3
done
sleep $Wait
fi
}
case "$1" in
reboot|kexec)
# Do not park disks when rebooting or switching kernels.
;;
*)
ParkDisks
;;
esac
If you save the above in a file called
temp.txt
, you can install it (ensuring correct owner and file mode) by runningsudo install -o root -g root -m 0755 temp.txt /lib/systemd/system-shutdown/odroid.shutdown
.If you used another name for the previous version, you'll also want to remove the old version, of course.
-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
When doing nothing on reboot, meaning typing just "reboot" in console and no proper parking script run, the harddisk is parked audibly "hard", a short delay of wait, and on boot up again it spins up again. So ignoring reboot is not the solution....
On reboot USB/bridge power is always cut/reset for a short time, so keeping the disk running during reboot is not possible? @Odroid?
Edit: I just noted, this is on an Armbian install, because my USB Wifi does (still?) not work on Ubuntu from Odroid (see viewtopic.php?f=97&t=28743).
Do Armbian and Odroid Ubuntu differ in their reboot processes? :-/
On reboot USB/bridge power is always cut/reset for a short time, so keeping the disk running during reboot is not possible? @Odroid?
Edit: I just noted, this is on an Armbian install, because my USB Wifi does (still?) not work on Ubuntu from Odroid (see viewtopic.php?f=97&t=28743).
Do Armbian and Odroid Ubuntu differ in their reboot processes? :-/
-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Ah, okay; I didn't know that.fvolk wrote:So ignoring reboot is not the solution
I don't think so. If Armbian also hasfvolk wrote:Do Armbian and Odroid Ubuntu differ in their reboot processes? :-/
/lib/systemd/system-shutdown/
, then the two are compatible in this particular regard. Does Armbian have any other files there?Assuming there are no other files in that directory, could you try the following version of
/lib/systemd/system-shutdown/odroid.shutdown
?
Code: Select all
#!/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=3
done
sleep $Wait
fi
}
case "$1" in
reboot|poweroff|shutdown|halt)
ParkDisks
;;
esac
case .. esac
part.-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
As a summary:
1) no shutdown script at all -> harddisk parked hard with power cut -> bad, SMART counter increases
2) with shutdown script for all cases, run "shutdown -h now" -> clean shutdown -> disconnect power -> reconnect power -> startup is fine
3) with shutdown script for all cases, run "reboot" -> clean shutdown -> on coming up again harddisk spins up, makes noise like it loses half a sec the power, then continues spin-up - does this hurt the disk?
Harddisk is a HGST Z5K1.
Tested with Armbian and now also with 4.14 based Odroid minimal image.
In my observation Armbian and Odroid behave the same way.
However, I had to stop testing now as the Odroid image all of a sudden does no longer come up, the blue LED blinks but network link LED is off - bad package in last updates?
And everytime I hurt my disk I feel a little bit like a bad Odroids herder :-/
So for me the lesson is I'll use the script - thank you - and I won't do any reboots.
Looking forward to a 4.14 based image with up-to-date Docker version
1) no shutdown script at all -> harddisk parked hard with power cut -> bad, SMART counter increases

2) with shutdown script for all cases, run "shutdown -h now" -> clean shutdown -> disconnect power -> reconnect power -> startup is fine
3) with shutdown script for all cases, run "reboot" -> clean shutdown -> on coming up again harddisk spins up, makes noise like it loses half a sec the power, then continues spin-up - does this hurt the disk?
Harddisk is a HGST Z5K1.
Tested with Armbian and now also with 4.14 based Odroid minimal image.
In my observation Armbian and Odroid behave the same way.
However, I had to stop testing now as the Odroid image all of a sudden does no longer come up, the blue LED blinks but network link LED is off - bad package in last updates?

And everytime I hurt my disk I feel a little bit like a bad Odroids herder :-/
So for me the lesson is I'll use the script - thank you - and I won't do any reboots.
Looking forward to a 4.14 based image with up-to-date Docker version

-
- Posts: 73
- Joined: Sat Sep 16, 2017 12:51 pm
- languages_spoken: English, Finnish
- ODROIDs: C1+, HC1
- Location: Finland
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
It's definitely not good for it.fvolk wrote:run "reboot" -> clean shutdown -> on coming up again harddisk spins up, makes noise like it loses half a sec the power, then continues spin-up - does this hurt the disk?
I should be getting my HC1 in operation with a WD HDD soon-ish, so I can find out exactly what is the cause of the restart hiccup. (My setup is a bit weird, because I use a custom microcontroller carrier board connected to the serial connection via level shifters. I need some time with an oscilloscope to characterize the power supplies I have, to make sure they work and won't burn the HC1. I have a couple of DC-DC ones that can provide 8A comfortably, that also have a inhibit pin, meaning the microcontroller, powered using a separate 5V DC-DC converter, can then turn off the power from HC1. Testing is required, because these are off eBay, and I'm worried about their noise and stability at a variable load. I do have a set of power resistors I'll test the supplies with, at different loads. If I only had basic testing equipment -- oscilloscope, electronic load, and a programmable supply...

It could be that adding a longer delay for the reboot case, for examplefvolk wrote:So for me the lesson is I'll use the script - thank you - and I won't do any reboots.
Code: Select all
case "$1" in
poweroff|shutdown|halt)
ParkDisks
;;
reboot)
ParkDisks
sleep 10
;;
esac
Unfortunately, it is also possible that the way the script shuts down the HDD causes the HDD to spin up immediately after the reboot sequence ends (since HC1 does not actually power-cycle at reboot), and that the hiccup occurs during the bootup process, after u-boot starts the kernel. If that is the case, we need to try to fix that using a different method of turning off the drive at reboot. That means trying
udiskctl
instead of hdparm
, at least for the reboot case. It might not be solvable at all. I would like to do that testing with the absolute minimum number of "hiccuping" reboots, because it is true it might harm the drive; there is quite a bit of energy in the spinning platter, and having the motor power turn off and then back on while it is already rotating is not good for the motor control electronics. All sorts of back-EMF -- and quote likely the drive electronics are not designed or tested to do that at all.-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
This sounds more like what I'm hearing.Nominal Animal wrote: Unfortunately, it is also possible that the way the script shuts down the HDD causes the HDD to spin up immediately after the reboot sequence ends (since HC1 does not actually power-cycle at reboot), and that the hiccup occurs during the bootup process, after u-boot starts the kernel.
When powering down "hard" the harddisk-is-stopped phase is longer than a "nice" power-down and then sooner the disk spins up again - and then at the actual reboot(?) receives a power jolt.
But maybe it is specific to my HGST disk - unfortunately I have no other available to test with currently.
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
When I using the script by @Nominal Animal on my HC1, I can't hear "hiccup" sound and doesn't increase "Power-Off_Retract_Count".Nominal Animal wrote:That means trying udiskctl instead of hdparm, at least for the reboot case.
but, I once see "[sda] I/O error" when I tried the reboot, that is I'm not sure caused by the script.
Anyway, the above quote is a hint. so I just added my idea to the @Nominal Animal's script.
I hope that kernel fell for that trick "poweroff" with any of shutting down cases.
Code: Select all
#!/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
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
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
It seems to be working. but...I'm not 100 percent sure.
Could you please anyone checks that this script works or not?
Could you please anyone checks that this script works or not?
Nominal Animal wrote:If you save the above in a file called temp.txt, you can install it (ensuring correct owner and file mode) by runningCode: Select all
sudo install -o root -g root -m 0755 temp.txt /lib/systemd/system-shutdown/odroid.shutdown
neal wrote:When I using the script by @Nominal Animal on my HC1, I can't hear "hiccup" sound and doesn't increase "Power-Off_Retract_Count".Nominal Animal wrote:That means trying udiskctl instead of hdparm, at least for the reboot case.
but, I once see "[sda] I/O error" when I tried the reboot, that is I'm not sure caused by the script.
Anyway, the above quote is a hint. so I just added my idea to the @Nominal Animal's script.
I hope that kernel fell for that trick "poweroff" with any of shutting down cases.
Code: Select all
#!/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 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
-
- Posts: 700
- Joined: Sun Jun 05, 2016 11:04 pm
- languages_spoken: english
- ODROIDs: C4, H2
- Has thanked: 0
- Been thanked: 91 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
I don't know about any sda I/O error, but with this scriptneal wrote: Could you please anyone checks that this script works or not?
on reboot the disk still has the spin-up half-a-second-pause problem,
whereas on shutdown, disconnect power, reconnect power and boot it does not.
I'm not doing reboots anymore, even if SMART counters do not increase I don't think it's healthy for the disk.
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
I want more people to use the script @Nominal Animal's idea to park HDD safely. so I made the wiki page.
https://wiki.odroid.com/odroid-xu4/trou ... own_script
Thank you, guys
https://wiki.odroid.com/odroid-xu4/trou ... own_script
Thank you, guys

-
- Posts: 74
- Joined: Fri Nov 03, 2017 6:16 am
- languages_spoken: english, german
- ODROIDs: none (plans for XU4)
- Has thanked: 1 time
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Is this also working when I reboot my HC2 or only when I use shutdown?neal wrote:I want more people to use the script @Nominal Animal's idea to park HDD safely. so I made the wiki page.
https://wiki.odroid.com/odroid-xu4/trou ... own_script
Thank you, guys
- rooted
- Posts: 9569
- Joined: Fri Dec 19, 2014 9:12 am
- languages_spoken: english
- Location: Gulf of Mexico, US
- Has thanked: 761 times
- Been thanked: 499 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
The script specifically doesn't park when rebooting.
-
- Posts: 74
- Joined: Fri Nov 03, 2017 6:16 am
- languages_spoken: english, german
- ODROIDs: none (plans for XU4)
- Has thanked: 1 time
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
So what's the sense of this script then? I hardly ever shutdown the board, I reboot it.
Ok, and after shutdown, could I savely unplug power and plug it in again, or do I get the clacking sound also after unplugging?
Ok, and after shutdown, could I savely unplug power and plug it in again, or do I get the clacking sound also after unplugging?
- rooted
- Posts: 9569
- Joined: Fri Dec 19, 2014 9:12 am
- languages_spoken: english
- Location: Gulf of Mexico, US
- Has thanked: 761 times
- Been thanked: 499 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
This one from above deals with reboot.
Code: Select all
#!/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=3
done
sleep $Wait
fi
}
case "$1" in
reboot|poweroff|shutdown|halt)
ParkDisks
;;
esac
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Hi, @trohn_javoltatrohn_javolta wrote:Is this also working when I reboot my HC2 or only when I use shutdown?neal wrote:I want more people to use the script @Nominal Animal's idea to park HDD safely. so I made the wiki page.
https://wiki.odroid.com/odroid-xu4/trou ... own_script
Thank you, guys
Did you apply the shutdown script on your HC2?
if so, Could you please feedback on your result?
In my case, I have tested many times with my HC2. and there is no issue with poweroff and reboot.
-
- Posts: 74
- Joined: Fri Nov 03, 2017 6:16 am
- languages_spoken: english, german
- ODROIDs: none (plans for XU4)
- Has thanked: 1 time
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Thx. So could I combine the two?
Install it this way right?
Name one odroid.reboot and one odroid.shutdown and I'm set.
Edit: Oh, I see.. is there also /lib/systemd/system-reboot where I can put the reboot script?
Install it this way right?
Code: Select all
sudo install -o root -g root -m 0755 temp.txt /lib/systemd/system-shutdown/odroid.shutdown
Edit: Oh, I see.. is there also /lib/systemd/system-reboot where I can put the reboot script?
Last edited by trohn_javolta on Tue Feb 27, 2018 5:10 pm, edited 1 time in total.
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
You can just copy & paste into your HC2 shell.
Code: Select 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
-
- Posts: 74
- Joined: Fri Nov 03, 2017 6:16 am
- languages_spoken: english, german
- ODROIDs: none (plans for XU4)
- Has thanked: 1 time
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Yeah, but this doesn't handle safe park on reboot, right?neal wrote:You can just copy & paste into your HC2 shell.Code: Select 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
- neal
- Posts: 281
- Joined: Fri Apr 14, 2017 10:02 am
- languages_spoken: Korean, English
- Has thanked: 13 times
- Been thanked: 26 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
I guess It handles safely to park on both poweroff and reboot.trohn_javolta wrote:Yeah, but this doesn't handle safe park on reboot, right?
-
- Posts: 17
- Joined: Sun Feb 25, 2018 3:40 am
- languages_spoken: english
- ODROIDs: Hc-1
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Hello,
have running OMV (OMV_3_0_92_Odroidxu4_4.9.61.img.xz) on my HC1, this "Klack" noise I have already heard while shutting down the HC1. I'm not an expert as many other user here, so I have no clear picture how to solve this issue. I understood that the lifetime of the HDD can be reduced, but for me it's not clear which steps are necessary to get rid of it. May someone make the picture clearer for me and eventually for other too?
have running OMV (OMV_3_0_92_Odroidxu4_4.9.61.img.xz) on my HC1, this "Klack" noise I have already heard while shutting down the HC1. I'm not an expert as many other user here, so I have no clear picture how to solve this issue. I understood that the lifetime of the HDD can be reduced, but for me it's not clear which steps are necessary to get rid of it. May someone make the picture clearer for me and eventually for other too?
-
- Posts: 17
- Joined: Sun Feb 25, 2018 3:40 am
- languages_spoken: english
- ODROIDs: Hc-1
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Have found in WIKI the description to apply the script. Will try it. Have never doe it but should work...hopefully 

-
- Posts: 27
- Joined: Mon Jan 22, 2018 7:50 am
- languages_spoken: english, français
- Has thanked: 0
- Been thanked: 2 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
quick question,
what about deleting the disk from the system ? I think on recent disk this will park the head of the disk. On older disk it might not do it thought.
It would prevent issue with your spindown/spinup on reboot.
Also for the script, it would be useful to a a proper systemd service file. I'll leave this task to someone else; or if it's not done when I do it I'll post; probably need defaultdependencies=false.
what about deleting the disk from the system ? I think on recent disk this will park the head of the disk. On older disk it might not do it thought.
Code: Select all
# echo 1 > /sys/class/block/sda/device/delete
# dmesg
[ 621.156409] sd 0:0:0:0: [sda] Synchronizing SCSI cache
Also for the script, it would be useful to a a proper systemd service file. I'll leave this task to someone else; or if it's not done when I do it I'll post; probably need defaultdependencies=false.
-
- Posts: 185
- Joined: Thu Apr 10, 2014 6:16 pm
- languages_spoken: english, hungarian, romanian
- Location: Romania
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Hi!
Can anybody please post a version of this script which also works on reboot? I've tried the official version form the odroid wiki and the version posted above, all of them are supposed to handle reboot too (that's what the code tells me), but they don't. When I shut down my Odroid HC1 units, the HDDs do not clack, but on reboot (which is what I use almost all the time) they clack. Western Digital Black 1TB.
Thanks!
Can anybody please post a version of this script which also works on reboot? I've tried the official version form the odroid wiki and the version posted above, all of them are supposed to handle reboot too (that's what the code tells me), but they don't. When I shut down my Odroid HC1 units, the HDDs do not clack, but on reboot (which is what I use almost all the time) they clack. Western Digital Black 1TB.
Thanks!
- odroid
- Site Admin
- Posts: 39399
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 2622 times
- Been thanked: 1432 times
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Did you try the script in this WiKi page?
https://wiki.odroid.com/odroid-xu4/trou ... own_script
Did you check the number of wrong shutdown counter via S.M.A.R.T. information?
https://wiki.odroid.com/odroid-xu4/trou ... own_script
Did you check the number of wrong shutdown counter via S.M.A.R.T. information?
-
- Posts: 185
- Joined: Thu Apr 10, 2014 6:16 pm
- languages_spoken: english, hungarian, romanian
- Location: Romania
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: HC1/HC2 - properly park harddisk on shutdown
Yes, the script from the Wiki is the first one I tried, doesn't work for reboot.
I don't know how to check the number of wrong shutdown via SMART.
I don't know how to check the number of wrong shutdown via SMART.
Who is online
Users browsing this forum: No registered users and 1 guest