I have a custom buildroot build with minimalistic kerenel for the RPi and busybox as init and shell. At the end of the boot process I start my own service which tries to access the usb drive. However at this moment the usb driver is still initializing the usb devices including the USB drive. Kernel boots in about 4 seconds, USB device recognition takes another 4-5 seconds. So actually I would like to know how to get the USB drive automatically mounted during boot and only if that happens start my service. I could also mount the disk before starting my service, but also here it has somehow to know if the USB disk is already recognized and the /dev/sda1 is created.
If you built your kernel with
inotify support you'd better use to wait for device creation using inotify. If not you can put this code to where before your service started by busybox init system:
# Waiting for device creation while true do test -e /dev/yournode if [ $? -eq 0 ]; then echo "Device created"; break; else echo "Waiting for device"; sleep 1; fi done