Posted: Thu May 21, 2020 1:47 Post subject: USB never mounting?
This is a never ending issue for me:
I have a usb with 2 labeled partitions attached: jffs, and opt. Those partitions automount successfully when I plug the thing. But the script pointed never runs automagically.
Ofc, manually giving the command "/opt/etc/init.d/S61stubby.sh start" after manually plug, Stubby runs perfect, but this is a problem each time light goes off and returns: router starts, usb is not detected, and stubby never start.
So every time that happens I have to manually unplug the thing, plug it again, telnet/ssh, "/opt/etc/init.d/S61stubby.sh start", which is stupid imo.
There's a way to truly automate the usb mounting without plug it again, and then run the script when automounting for real?
Pictures attached to illustrate.
Ooooobviously, the problem exists no matter which usb I plug with the same partitioning.
Maybe someone figured out how to make it work. Looking for a solution found more related to running the script later assuming the usb eventually will mount, but believe me, the thing never automounts without phisically interaction.
As I mentioned, there's 2 problems:
- After router reboot, usb is not automagically mounted.
- After manually reconnect usb, the script is not being triggered (however, if I ssh and paste exactly the same command, it works.. so there's no problemn with the script itself, but the router triggering the action after mounting).
The solution you mentioned was the first which came to my mind, but the problem is that the usb never automounts, so that script will never run since there's no valid path in which exists.
Hope that clarifies my problem.
If the problem is that the script does not run when the router reboots, maybe simply adding it as startup command will let it run?
Of course you will have to precede the command with sleep 30 to wait for the USB to be mounted
I use this script to wait for the USB drive to mount:
until [[ -f /jffs/usb-is-mounted ]]; do
if [[ $i -gt 30 ]]; then
logger "No USB mounted"
logger "USB $i seconds before mounted")
After this script which waits for the USB drive to be mounted I run other scripts from my USB drive.
On my R6400v2 it takes about 7 seconds before the stick is mounted, but it depends on the USB port, Router speed and USB drive speed.
Ok I solved it. And I wanted to leave the feedback here for someone who has a similiar or equal issue:
First: The USB automounting problem
Funny to know that the 2 usb are not treated in the same way by the firmware. I just plugged it into the USB 1 (the one which can act as eSATA). Seems that despite the UUID is given, well, usb 2 doesn't works the same way that usb 1... mega lol.
Second: The delayed script start (Stubby)
In this case the problem was a lil bit trickier, since I had to clear the "Run-on-mount Script Name" field and create a start script like this:
until [ -r /opt/etc/init.d/S61stubby.sh ]
What? until checks one condition until it's true, in this case, checks if the file is readable (you can check a directory also with -d), if it's not true, waits one second and checks again until the condition is true. Then, starts stubby.
You may ask why I did that stupid thing of sleep after the condition is met. WELL, after hours of angry I found that even the file is readable, there's some lil time until you can execute it. I can't tell exactly why, but this way works and without "sleep 3", it doesn't. If it works for you that way, perfect, not for me.
The other simple way is just leave it like this:
But this just works if the given time (in the example, 10) is enough to access the script and the minimal to archieve connection (in my setup, if stubby doesn't starts, I have no connection, cuz I wanted to ensure every request comes from stubby and only stubby).
So.. My way has the advantage that as soon you have access to the partition, you can run the script safely.