diff mbox series

[v2,7/9] ixp4xx: Add hdparm script

Message ID 20230928-ixp4xx-v2-7-ce011eef8239@linaro.org
State Superseded
Headers show
Series Resurrect OpenWrt IXP4xx support | expand

Commit Message

Linus Walleij Sept. 28, 2023, 1:28 p.m. UTC
This script will make sure to spin down harddrives on IXP4xx
NAS devices such as the NSLU2 and siblings after 1 minute
of inactivity.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 target/linux/ixp4xx/base-files/etc/board.d/03_hdparm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/target/linux/ixp4xx/base-files/etc/board.d/03_hdparm b/target/linux/ixp4xx/base-files/etc/board.d/03_hdparm
new file mode 100644
index 000000000000..27f2b760420e
--- /dev/null
+++ b/target/linux/ixp4xx/base-files/etc/board.d/03_hdparm
@@ -0,0 +1,14 @@ 
+# SPDX-License-Identifier: GPL-2.0-only
+# Spin down drives after one minute if inactive
+
+if [ ! -n "$(command -v hdparm)" ]; then
+	exit 0
+fi
+
+DISKS=$(find /dev/sd[a-z] 2>/dev/null)
+for DISK in $DISKS
+do
+	if [ -b $DISK ] ; then
+		hdparm -S 12 $DISK > /dev/null
+	fi
+done