6

I am newbie to this. I have got dd-wrt , installed and configured in my router.

dd-wrt version : DD-WRT v24-sp2 (08/07/10) router version : D-Link DIR 600

I am trying setup bandwidth usage monitoring script in it.

Is there any way , I can store details in router , without getting deleted on reboot ?

I mean is there some kind of persistent storage I can get ?

Thanks
J

1
  • As far as I remember, DD-WRT splits the flash into part for the read-only partition with the system that gets loaded into RAM and decompressed and then used and a small part used for settings storage that could be written to. You could try using that for as storage space. The problem comes up if you need to install an additional program to the router to do the monitoring because there will be little space left. When I had such a problem, in the end I had to move to OpenWRT which doesn't use read-only filesystem.
    – AndrejaKo
    Jan 20, 2012 at 8:19

5 Answers 5

9

There should be nvram (i.e. non-volatile ram).

nvram show            # list all variables
nvram get name        # get variable
nvram set name=value  # set variable
nvram unset name      # delete variable
nvram commit          # save changes to flash
6

As Mika said: nvram is the name of the persistent storage. Unfortunately, it is not a file system. The file system of DD-WRT (at least the small ones) is a combination of squashfs and ramfs and is populated at boot time from values stored in nvram.

When you go to Administration->Commands, you can enter a script and save it as a Custom Script (bottom of the page). You can use this feature to implement several use cases, provided that they are all in this single script. I made something like this:

case "$1" in
  wificontrol)
    #here is code which turns off wlan after 30 mins of inactivity
    ;;

  wifion|wifi)
    wlanIF=ra0
    ifconfig $wlanIF up
    touch /tmp/wlan-online0
    ;;

  *)
    echo "$0 {wificontrol|wifi[on]}"
esac

Then, I run the script on command line:

/tmp/custom.sh wifion

And as a cron job (Administration->Management):

*/4 * * * * root /tmp/custom.sh wificontrol

I know, this is not a very nice solution, but it works. Tested on my v24-sp2 (rev 14896)

1

There is a small space that you can use. I don't know exactly because I didn't look up your router's specs. When you set a cron job you are writing to the filesystem are you not? I would SSH in and check out the /var directory. If you have a usb port you could place your log files there. Just be sure in your script to delete the logs once they get a certain size or your router will die.

This might interest you http://www.dd-wrt.com/wiki/index.php/Useful_Scripts or this forum thread. http://www.dd-wrt.com/phpBB2/viewtopic.php?t=81432

1

Usually there is some space you can use. For example read this answer: https://stackoverflow.com/questions/451638/list-free-flash-space-on-wrt54gl-with-dd-wrt-v24sp1-firmare. In my WAG200G I formated mtd2 or mtd3 for my purpose. But you need to be sure which flash block you can use otherwise you can turn your device to a brick.

1

Enable JFFS.

There are two instructions at the link:

  • using Web-GUI Interface
  • using Command-line Interface

In my case, only the Command-line Interface worked. The Web-GUI Interface did not.


my modified Command-line Interface instructions

These commands are easiest to run in a shell via ssh; ssh must be enabled.

First, check if jffs is already mounted:

mount

A mounted jffs partition looks like:

$ mount
...
/dev/mtdblock/4 on /jffs type jffs2 (rw)

$ df -h
Filesystem                Size      Used Available Use% Mounted on
...
/dev/mtdblock/4           4.3M    260.0K      4.0M   6% /jffs

If not available, then instruct DD-WRT to format and create one:

YOU SHOULD PROBABLY BACKUP YOUR DD-WRT CONFIGURATION BEFORE RUNNING THESE

nvram set jffs_mounted=1
nvram set enable_jffs2=1
nvram set sys_enable_jffs2=1
nvram set clean_jffs2=1
nvram set sys_clean_jffs2=1
nvram commit
reboot

After reboot, unset per-boot reformatting so files are not lost

nvram set clean_jffs2=0
nvram set sys_clean_jffs2=0
nvram commit

Test with

date | tee /jffs/test
cat /jffs/test

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .