Run command on mounting storage device

Title is self explanatory, i want to run a command whenever my external Hard Disk gets mounted.

Since my hard disk can handle spinning down by it self, i dont want to use HD-Idle service, i prefer to use hdparm command and save some memory, cpu cycles and save space by uninstalling it. HD-Idle runs all the time in the background, so i want to use

hdparm -S 60 /dev/sda

whenever the HD is mounted. The problem is that the command is lost every time i turn disk off, so i need to execute it everytime i turn on/mount the device.

https://openwrt.org/docs/guide-user/base-system/hotplug
and in particular
https://openwrt.org/docs/guide-user/base-system/hotplug#the_usb_folder

(My opinion: I can see the need to run scripts when USB is plugged for more elaborate purposes, but I am not entirely sure replacing hd-idle is worth the time and effort. hd-idle service takes up virtually no space, CPU, or memory -- it's an 8 kb binary tool and some config files.)

1 Like

for some strange reason i dont have a usb folder in /etc/hotplug.d, should i create it?

OpenWrt simply doesn't come with USB sensitive hotplug scripts by default, so yeah, you will have to create it.

1 Like

Yup maybe it's too hardcore to do this, but i need to do something while being in quarantine :rofl:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.