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 ?


  • 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 '12 at 8:19

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

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
    #here is code which turns off wlan after 30 mins of inactivity

    ifconfig $wlanIF up
    touch /tmp/wlan-online0

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

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)


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


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.


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:


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:


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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.