mounting usb 3 partitions to run scripts and save data

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Author Message
LRCbns
DD-WRT Novice


Joined: 22 Jan 2017
Posts: 7

PostPosted: Fri Jun 07, 2019 11:03    Post subject: mounting usb 3 partitions to run scripts and save data Reply with quote
Archer C8 rev 1
build: v3.0-r39944 std
Now I used my linux debian pc to format a usb with a 1GB swap. 4 GB jffs, 4 GB opt and 5 GB data.
in the webpage it had a line for jffs with the uuid that I entered and repeated the same for opt. There was no other line for another partition which I called data even though I did see an example with a data partition possible. I did toggle the automount drive to on. when I first filled in the info ddwrt recognized it as correct and promptly ran its script setting up jffs and opt. but then a few moments later it unmounted and has not mounted again.
Looking around almost all info is related to k2.4 I am on k3.x and so somethings have changed a lot. How do I get jffs and opt to be mounted all the time so that I can run an install script and that it can be used. I intend to setup an adblock, but other how the script works there is very little help as far as getting the usb to work as they want it to work.
Could I be missing a step in making sure the usb is always mounted?
Or could there be a bug in this version and I need to use and older one?
Also is there a way to mount a data partition so more scripts can use that to store they're files?
Sponsor
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8022

PostPosted: Fri Jun 07, 2019 12:37    Post subject: Reply with quote
Might want to look at a script I recently wrote that allows you to completely bypass the GUI and the automount feature, and manually bind all your partitions to whatever mounting points you prefer. The GUI's automount feature is limited, and makes certain assumptions (e.g., if it sees a partition named opt or optware, it mounts it to /opt, and likewise anything named jffs gets mounted to /jffs). But beyond that, it's of no help. You can't bind any other partitions to the mounting points of your choice. Also, afaik, the script options are all *post* mounting.

Using my script, you can mount any partition of any usb drive to whatever mounting point you prefer, and can call your own scripts, both pre-mounting and post-mounting.

https://pastebin.com/VDZ32r2D

Sometimes just doing it yourself using scripts provided a lot more flexibility than relying on the GUI.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
LRCbns
DD-WRT Novice


Joined: 22 Jan 2017
Posts: 7

PostPosted: Fri Jun 07, 2019 13:09    Post subject: Reply with quote
Many thanks for your hard work. I am going to try it as soon as I can. The instructions that were given for setting things up ended in failure because somewhere alone the line one of the settings broke all my connections with my laptop. My viop provider phone was fine and my roku was fine. Could be an issue with the fact I am running debian.
I do agree with your assessment about scripts. I do not have the brains for doing my own scripts, but usually can figure out what is going on enough to do modifications. I have been using linux for almost 20 years now and I can tell you scripting has made linux from a geek to a point the everyday person can handle linux.
Again many thanks.
vroemm
DD-WRT Novice


Joined: 13 May 2019
Posts: 11

PostPosted: Mon Jun 17, 2019 16:22    Post subject: Reply with quote
eibgrad wrote:
The GUI's automount feature is limited, and makes certain assumptions

..
Quote:
But beyond that, it's of no help.


Nice.. Smile
I like dd-wrt since long. Thats why i could not belief the above was true. I kept running around, like a rat in a maze looking for food. I could not belief there was no solution.

Now i see you came to the same conclusion as me.
It is a big relief for me. There is no solution.

I do not know much about these things.
So i have a question about your script.

If i leave the BEGIN OPTIONS.. to END OPTIONS unchanged, would that be OK ?

I would not know what to do with this part..

Thanks you very much, although i still have to try it, hope it works for me Smile

vroemm
vroemm
DD-WRT Novice


Joined: 13 May 2019
Posts: 11

PostPosted: Mon Jun 17, 2019 16:38    Post subject: Reply with quote
I get a error:

root@DD-WRT:~# curl -kLs bit.ly/ddwrt-installer|tr -d '\r'|sh -s VDZ32r2D startup
warning: /jffs not mounted; using /tmp
info: script installed: /tmp/ddwrt-mount-usb-drives.startup

Can the ddwrt-mount-usb-drives.startup script be run from this /tmp/ folder ?

Using: DD-WRT v3.0-r37495M kongat (10/28/1Cool
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8022

PostPosted: Mon Jun 17, 2019 17:18    Post subject: Reply with quote
vroemm wrote:
If i leave the BEGIN OPTIONS.. to END OPTIONS unchanged, would that be OK ?


In most cases, it makes sense to change the location to where your various partitions will be mounted. In the script, I provide an example of a single USB drive w/ two partitions, one intended for use w/ optware (e.g., Entware), the other for something I call "dropbox", which is just a general purpose partition.

In order to mount any partition, you need to define a mounting point (i.e., a folder/directory). In the case of the script, those are /opt (for the optware partition) and /mnt/dropbox (for the dropbox partition). For your own purposes, you would do likewise.

So let's say you have a single USB drive w/ three partitions. You could change the script to say…

Code:
mkdir -p /mnt/part1
mkdir -p /mnt/part2
mkdir -p /mnt/part3


You can name them anything you like, but I just choose part# since I have no idea what is the purpose of each of your partitions.

Now you use the blkid utility to identify the UUID of each of those partitions and mount them to their respective mounting points.

Code:
mount $(findfs UUID=c3f789d8-8782-4626-b1f7-f8b94bf454c3) $OPT /mnt/part1
mount $(findfs UUID=b9705da6-3de2-4d81-b607-49ae31233b5e) $OPT /mnt/part2
mount $(findfs UUID=ye836512-4541-6788-9901-dfgs2s9g28s1) $OPT /mnt/part3


vroemm wrote:
I get a error:

root@DD-WRT:~# curl -kLs bit.ly/ddwrt-installer|tr -d '\r'|sh -s VDZ32r2D startup
warning: /jffs not mounted; using /tmp
info: script installed: /tmp/ddwrt-mount-usb-drives.startup

Can the ddwrt-mount-usb-drives.startup script be run from this /tmp/ folder ?

Using: DD-WRT v3.0-r37495M kongat (10/28/1Cool


Normally you need jffs enabled so that the script is both persistent and available at bootup. When the script doesn't find jffs enabled, it does the only thing left as an option; it writes the script to /tmp. However, /tmp is NOT persistent. Upon a reboot, anything in /tmp is lost.

If you don't have jffs available to you, then you'll need to take the contents of the script in /tmp, modify it as described above, and finally copy it into the startup script (Administration->Commands). Or else save it as a Custom Script and then call the custom script from the startup script.

Code:
/tmp/custom.sh


So ideally, you should use jffs. If you don't, then you have to use the startup script using one of the two methods above to make the script persistent and available at bootup.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
vroemm
DD-WRT Novice


Joined: 13 May 2019
Posts: 11

PostPosted: Tue Jun 18, 2019 18:32    Post subject: Reply with quote
For some unknown reason "findfs" is missing on my version of dd-wrt.

The solution is in this thread:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317108&postdays=0&postorder=asc&start=30

Your script :
mount $(findfs UUID=<the UUID> ) $OPT /opt

Becomes:
mount $(blkid | grep <the UUID> | cut -d ':' -f 1) $OPT /opt

And now it works..

Thanks for your script.
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8022

PostPosted: Tue Jun 18, 2019 19:08    Post subject: Reply with quote
vroemm wrote:
For some unknown reason "findfs" is missing on my version of dd-wrt.

The solution is in this thread:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=317108&postdays=0&postorder=asc&start=30

Your script :
mount $(findfs UUID=<the UUID> ) $OPT /opt

Becomes:
mount $(blkid | grep <the UUID> | cut -d ':' -f 1) $OPT /opt

And now it works..

Thanks for your script.


Thanks for the feedback. Maybe I'll update the script to use this technique if it's the case not all builds support findfs. Seems more likely to be compatible.

Just another example of why it's difficult to support scripting on dd-wrt. It has to cover a wide variety of routers w/ widely varying builds.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
vroemm
DD-WRT Novice


Joined: 13 May 2019
Posts: 11

PostPosted: Thu Jun 20, 2019 7:37    Post subject: Reply with quote
You could use the same check you used for modprobe.
And then put both findfs and blkid in the script.

if [ "$(which findfs)" ]; then
< the findfs way >
else
< the blkid way >
fi

Or would this not work ?

Vroemm.
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8022

PostPosted: Thu Jun 20, 2019 13:38    Post subject: Reply with quote
That's basically what I'm thinking. I can create a conditional function at the top of the script called findfs that fully mimics the actual findfs utility, so it supports finding the filesystem based on UUID and LABEL.

Code:
if [ ! "$(which findfs)" ]; then
    findfs() { blkid | sed 's/"//g' | grep -wm1 "$1" | cut -d ':' -f 1; }
fi


Now the lack of a findfs utility in the OS/firmware is completely transparent to the user. Or else just forgo the use of the one in the OS/firmware in favor of the function.

Note, using the label should work as well provided the partitions are labeled (of course) and unique across all usb drives and partitions. So that may be preferred in some cases over using UUID.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
vroemm
DD-WRT Novice


Joined: 13 May 2019
Posts: 11

PostPosted: Thu Jun 20, 2019 16:48    Post subject: Reply with quote
Hmm.
It would worry me a bit to give users the illusion they are using findfs.
Maybe this can lead to false assumptions somehow.

I wonder, how difficult is it to change the source code of dd-wrt ?
Make selection based on UUID or LABEL possible in dd-wrt and the problem is solved..

A few days ago i tried to find the place in the dd-wrt source code where the service->usb stuff is done.

Found the adv_usb.webusb file with the html code for the service->usb page.
Thats as far as i got.

But the thought keeps itching me a little bit Smile

Vroemm.
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8022

PostPosted: Thu Jun 20, 2019 17:26    Post subject: Reply with quote
vroemm wrote:
Hmm.
It would worry me a bit to give users the illusion they are using findfs.
Maybe this can lead to false assumptions somehow.


Unfortunately, this is nothing new for dd-wrt. Having to deal w/ missing functionality is routine. And the idea of having to recompile the source to include it simply isn't practical for most users. Esp. for something this trivial. The utility doesn't do anything more or less than the function. I doubt most users have ever even heard of these utilities (blkid, findfs, etc.). But even so, I could just rename the function and eliminate any possible confusion.

Code:

find_dev() { blkid | sed 's/"//g' | grep -wm1 "$1" | cut -d ':' -f 1; }
...
mount $(find_dev UUID=df6c31d7-eb40-4361-8856-f8824b75ef8c) $OPT /opt


The more important point is to make sure the script works reliably. Or at least as reliably as possible. Heck, I'm not even sure blkid will be available in every build! I'll just have to wait until someone reports it missing, like you did w/ findfs.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8022

PostPosted: Thu Jun 20, 2019 22:28    Post subject: Reply with quote
FYI, updated the script to v1.1.0. Let's see how this works out.
_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware 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 can attach files in this forum
You can download files in this forum