Message ID | 20231012-ixp4xx-v3-10-e09c74712c0b@linaro.org |
---|---|
State | Accepted, archived |
Delegated to: | Linus Walleij |
Headers | show |
Series | Resurrect OpenWrt IXP4xx support | expand |
Linus Walleij <linus.walleij@linaro.org> wrote: > This script will make sure to spin down harddrives on IXP4xx > NAS devices such as the NSLU2 and siblings after 1 minute > of inactivity. Why not use hotplug events? > 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(+) [....]
On Fri, Oct 13, 2023 at 12:28 AM Andrey Jr. Melnikov <temnota.am@gmail.com> wrote: > Linus Walleij <linus.walleij@linaro.org> wrote: > > This script will make sure to spin down harddrives on IXP4xx > > NAS devices such as the NSLU2 and siblings after 1 minute > > of inactivity. > > Why not use hotplug events? Could be a good idea! Do you have a pointer to how we do these in OpenWrt? Yours, Linus Walleij
Linus Walleij <linus.walleij@linaro.org> wrote: > On Fri, Oct 13, 2023 at 12:28 AM Andrey Jr. Melnikov > <temnota.am@gmail.com> wrote: > > Linus Walleij <linus.walleij@linaro.org> wrote: > > > This script will make sure to spin down harddrives on IXP4xx > > > NAS devices such as the NSLU2 and siblings after 1 minute > > > of inactivity. > > > > Why not use hotplug events? > Could be a good idea! Do you have a pointer to how we do these > in OpenWrt? I'm use for external USB disk patched /etc/hotplug.d/block/00-media-change -- cut /etc/hotplug.d/block/00-media-change -- [ -n "$DISK_MEDIA_CHANGE" ] && /sbin/block info if [ "$ACTION" = "add" -a "$DEVTYPE" = "disk" ]; then case "$DEVNAME" in mtd*) : ;; *) echo 2000 > /sys/block/$DEVNAME/events_poll_msecs ;; esac case "$DEVNAME" in sd*) /sbin/hdparm -B 127 -S 120 /dev/$DEVNAME | /usr/bin/logger ;; esac fi -- cut -- PS: And 60 seconds timeout for NAS disks is low. Readahead+cache and serve small files (which fit in memory) - now disk's in spinup-read-spindown cycle.
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
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(+)