USB never mounting?

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Author Message
7heblackwolf
DD-WRT Novice


Joined: 21 Nov 2019
Posts: 42

PostPosted: Thu May 21, 2020 1:47    Post subject: USB never mounting? Reply with quote
Quick question:

WRT3200ACM
r43192

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.

Cheers,

_________________
Linksys WRT3200ACM
Firmware: DD-WRT v3.0-r41954 std (01/09/20)

Dnsmasq / Unbound / VAP / DNSCrypt / DNSSEC / QoS WAN.HTB.FQ_CODEL_FAST (custom netmask and svc) / Custom port setups for subnet delegation

Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 6154
Location: Netherlands

PostPosted: Thu May 21, 2020 7:51    Post subject: Reply with quote
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:

Code:
(i=0
until [[ -f /jffs/usb-is-mounted ]]; do
   sleep 1
   i=$((i+1))
   if [[ $i -gt 30 ]]; then
      logger "No USB mounted"
      touch "/jffs/usb-is-mounted"
      exit
   fi
   done
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.

If the problem is that the drives do not mount correctly you can use @eibgrad's script to mount:
https://pastebin.com/VDZ32r2D

_________________
Routers:Netgear R7800, R6400v1, R6400v2, Linksys EA8500, EA6900 (XvortexCFE), E2000 (converted WRT320N), WRT54GS v1.
OpenVPN Policy Based Routing guide: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=321686
Install guide R6400v2:http://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
OpenVPN Server Setup:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318795
Install guide R7800: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Wireguard Server setup guide:https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1183135
Wireguard Client setup guide:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324624
Wireguard Advanced setup guide:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324787
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
7heblackwolf
DD-WRT Novice


Joined: 21 Nov 2019
Posts: 42

PostPosted: Thu May 21, 2020 14:15    Post subject: Reply with quote
Hi there,
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.

egc wrote:
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:

Code:
(i=0
until [[ -f /jffs/usb-is-mounted ]]; do
   sleep 1
   i=$((i+1))
   if [[ $i -gt 30 ]]; then
      logger "No USB mounted"
      touch "/jffs/usb-is-mounted"
      exit
   fi
   done
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.

If the problem is that the drives do not mount correctly you can use @eibgrad's script to mount:
https://pastebin.com/VDZ32r2D

_________________
Linksys WRT3200ACM
Firmware: DD-WRT v3.0-r41954 std (01/09/20)

Dnsmasq / Unbound / VAP / DNSCrypt / DNSSEC / QoS WAN.HTB.FQ_CODEL_FAST (custom netmask and svc) / Custom port setups for subnet delegation

egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 6154
Location: Netherlands

PostPosted: Thu May 21, 2020 14:24    Post subject: Reply with quote
Well you can use @eibgrad's script to mount but I never had problems just naming my ext2 partitions jffs and opt and not use the uuid.

Partitions named opt and jffs should be auto mounted to /opt and /jffs

Maybe worth a try

_________________
Routers:Netgear R7800, R6400v1, R6400v2, Linksys EA8500, EA6900 (XvortexCFE), E2000 (converted WRT320N), WRT54GS v1.
OpenVPN Policy Based Routing guide: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=321686
Install guide R6400v2:http://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
OpenVPN Server Setup:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318795
Install guide R7800: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Wireguard Server setup guide:https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1183135
Wireguard Client setup guide:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324624
Wireguard Advanced setup guide:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324787
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
7heblackwolf
DD-WRT Novice


Joined: 21 Nov 2019
Posts: 42

PostPosted: Thu May 21, 2020 21:20    Post subject: Reply with quote
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:

Code:
until [ -r /opt/etc/init.d/S61stubby.sh ]
do
    sleep 1
done
sleep 3
/opt/etc/init.d/S61stubby.sh start


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.

Why?
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:
Code:

sleep 10
/opt/etc/init.d/S61stubby.sh start


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.

I'll answer any question in which I could help. Cheers! Wink

_________________
Linksys WRT3200ACM
Firmware: DD-WRT v3.0-r41954 std (01/09/20)

Dnsmasq / Unbound / VAP / DNSCrypt / DNSSEC / QoS WAN.HTB.FQ_CODEL_FAST (custom netmask and svc) / Custom port setups for subnet delegation

Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum