How to run a startup script very early in boot process?

I need to run a startup script very early in the boot process, preferably just after root mount. This script will wait a few seconds for 2 USB devices to become available, then mount a RAID1 btrfs to /var. No services must start before it finishes, including the system logger (logd).
How do I do this?
Thanks.

put it with a low Sxxnameofservice in etc/init.d/

1 Like

I think those scripts are run in parallel. Am I wrong?

trial and error ?

you can put a sleep in all startup scripts but yours, or disable all autostarts, except for yours, then manually start them via local start up script.

Sounds like you want to hook into preinit. Use package/system/urandom-seed/files/lib/preinit/81_urandom_seed as example. Mount root happens at 80_* so name it 81_* if you want to install it in the overlay without building a custom image.

It won't run from overlay.