Journalling Flash File System

From DD-WRT Wiki

Revision as of 22:10, 30 April 2008 by S2s2 (Talk | contribs)
Jump to: navigation, search


Introduction and Overview

The Journalling Flash File System (JFFS/JFFS2) is a (root) user re-writable area in the Linux File System on a DD-WRT-enabled router. Located at /jffs, the re-writeable folder [directory] contents are:

  1. directly in the remaining space of the onboard read-only flash memory,
  2. or through a mount command, the contents of /jffs can be somewhere else.

Examples of the kind of programs and data are: custom configuration files, run ipkg, hosting custom Web pages stored on the router and many other things not capable without enabling JFFS.

Except for very old versions of some Linksys routers which contained 8MB of Flash and 32MB of RAM, most DD-WRT-capable (i.e. Decent) routers today contain 4MB of Flash memory; a few models from certain manufacturers contain more. See models. On 4MB routers, enabling JFFS is considered generally useful and usable with the DD-WRT Standard-NoKaid builds. NoKaid removes a specific XBOX module, leaving room for JFFS. The Mini builds of DD-WRT also work. This leaves between about 320KB - 700KB+ of available re-writable space in /jffs.

Enable JFFS when Flash Space is Available (i.e. Mini on 4MB, or >4MB Internal Flash)

Note: Take care not to store frequently changed files on Flash as this can cause flash wear out over time. While a journal file system minimizes frequent overwrites, it is not a good idea to store frequently changed files on the main flash memory anyway because of flash wear.

For Web Interface Users:
The steps to enable JFFS through the router web page are very specific. To avoid having to reset and reprogram your router, it's smart to make a backup here of your settings. If you follow these steps exactly, it should not lock up.

  1. On the router web page click on "Administration".
  2. Scroll down until you see "JFFS2 Support".
  3. Click "Enable JFFS".
  4. Click "Save".
  5. Wait couple seconds, then click "Apply".
  6. Wait again. Go back to the "Enable JFFS" option, click "Clean JFFS".
  7. Do not click "Save". Click "Apply" instead.

The router formats the available space, which is now shown in the JFFS2 Support box.

For Linux Gurus:
Enter the following commands (when you're connected via ssh or telnet on a shell):

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

might reboot/hang after cleaning which might take long, so be patient


I tried the previous commands under La Fonera firmware v24 RC4 and corrupted all my settings. I had to recover my unit with the procedures on La Fonera flashing page. I am not sure if this is a bug or these commands are not suited for La Fonera. Please try to use the web interface above. It works for me.


On my install of DD-WRT (DD-WRT v23 SP2 (09/15/06) vpn - build 3932 - and also when I tried DD-WRT v24) on a WRT54GS (1.1), I found that after mounting the JFFS, I only had 320kb free. I noticed that the mounted partition was /dev/mtdblock/4. I tried mounting the other three block devices, and found that /dev/mtdblock/1 had 3.7MB [Added: DO NOT consider using /dev/mtdblock/1 as free space unless you like catastrophic system corruption. /dev/mtdblock/4 has all the unused flash space of your router; in the above example with 320kb, there was only 4Mb flash to begin with].

To unmount the JFFS (in case it was too small):

nvram set sys_enable_jffs2=0
nvram set sys_clean_jffs2=0
nvram set jffs_mounted=0
nvram commit

Afterwards you can delete these variables with "nvram unset <variable>".

Enable JFFS when little flash (i.e. Standard firmware on typical Router with only 4MB of Main Flash)

Add a 1GB flash memory card (more r/w storage directly on the router)

Creating a read-write /jffs space, using little space on the Main internal Flash memory:

  • Add the SD/MMC mod - up to 1GB storage using common swappable SD memory cards (built-in support in DD-WRT v2.4 and above). Ext2FS driver [[1]] can be used within Windows 2K/XP to r/w SD cards. WinSCP can be used to transfer files to and from the router, eliminating the need to pull the card out and put it in a card reader on a PC.
  • On older firmware (v2.3), the limited JFFS space can be used to hold the drivers to load support for the SD card.
  • Routers with USB storage: A Linksys WRTSL54GS or ASUS WL-500g Premium device has USB capability. Drivers and startup files are stored in a small amount of JFFS space. Any other storage-intensive tasks can then be accomplished on one or more external USB devices.

Using Samba/CIFS, General info (additional storage on a NAS or wire-networked computer)

  • One option is to use a CIFS/Samba share on the network. In the Web GUI mount a Samba share at /jffs. This creates a read-write directory which is not stored on the router, instead the contents are stored on the Network-Attached Storage (NAS) or computer. The option uses more electricity ($$$ or €€€), but may be useful if you already have a low-power NAS, or an always-on server, when the share is continuously available. Also see this for more info. To setup your /jffs share to point to a Linux box and you are a Linux newbie see this.

If you have too little flash memory but need some memory under /jffs you can use Samba and mount the share under /jffs

To mount the samba share under /jffs you can either

  • Use a startup script
  • Use Samba startup scripts

NOTE 2: You might not be able to use symbolic links when using windows-hosts. Rename(mv) could work.

Use a Startup Script to Samba Example 1

Read first, howto use Startup Scripts. Then place the following into your startup script to mount the JFFS partition:

umount /jffs
smbmount //<server's IP>/jffs /jffs -o username=<your username>,password=<your password>
  • NOTE: username is guest if hosted on Windows XP & 'Simple File Sharing' is enabled.

Use Samba Startup Scripts 2

This method uses 2 scripts: The first will be started from /tmp/smbshare, mount the samba share under /jffs and start the other script. The second will be started from /jffs and unmount /tmp/sambashare.

Now here are instruction on how to do so:

1) disable JFFS in the web GUI if you had enabled it
2) enable samba (see also Jffs_sharing_in_a_Linux_server).

3) create a script called "" on the share:


#smb settings: same as the settings in the webgui
# change these to mount a different share than the current at /jffs
SMBSHARE=`nvram get samba_share`
SMBUSER=`nvram get samba_user`
SMBPASS=`nvram get samba_password`

#script to start in /jffs once we're done mounting

#where to log what is happening
export SMBLOG=/tmp/smblog

####### ok, here we go... ;) #######
echo "" > $SMBLOG
cd /

#make sure JFFS is unmounted. Its recommended to run without JFFS enabled though.
echo "umounting /jffs if nescessary..." >> $SMBLOG
umount /jffs >> $SMBLOG 2>&1

#mount our smbshare at /jffs
echo "mounting $SMBSHARE at /jffs..." >> $SMBLOG
smbmount $SMBSHARE /jffs -o username=$SMBUSER,password=$SMBPASS >> $SMBLOG 2>&1
#smbmount ist not working in v23 SP3, so i changed the line above:
#mount.cifs $SMBSHARE /jffs -o username=$SMBUSER,password=$SMBPASS >> $SMBLOG 2>&1

#hand over startup to the JFFS part
/jffs/$JFFS_SCRIPT & >> $SMBLOG 2>&1

4) create a script called "" on the share:


#wait a sec, just to be sure the smb startup script has quit
sleep 1

#unmount the smbshare, its identical to /jffs now anyway :)
umount /tmp/smbshare

#to enable ipkg, we fake JFFS enabled.
#since theres no commit, this wont actually enable JFFS
nvram set sys_enable_jffs2=1

#ready to do specific stuff, like starting services
#or other commands from /jffs

5) in the webinterface, enable Samba with appropriate share/user/pass settings from step 2. Enter "" as the script
6) reboot

Now you should have the share configured in the web interface mounted at /jffs and should also be able to run 'ipkg' !

  • NOTE: If you are a Linux newbie, and you have problems with file permissions, look at this
  • BONUS NOTE OF HAPPINESS: You need to save the script files in UNIX format, not DOS. One text editor that can do this is UltraEdit. Or Crimson Editor, which is free :o)

Use Samba Startup Scripts 3

This method requires 2 shares available for DD-WRT, but allows you to have 2 different areas of storage for the router. Some might find it useful. It is an amalgamation of the previous 2 methods.

Things you need:

  • 2 writeable shares on another computer/server


  1. Enable JFFS
  2. Enable Samba
  3. Create a shell script in the Samba share, as follows:

umount /jffs
smbmount //<server's IP>/<jffs share name> /jffs -o username=<your username>,password=<your password>

  4. Enter the name of the script in the Samba startup script box in the GUI
  5. Reboot

As an example, my DD-WRT has these shares:

  • /tmp/smbshare located in a shared folder on my NAS called ddwrt, which contains scripts (including containing the above commands), yet to be installed packages and other static data
  • /jffs located in a shared folder called jffs, which contains program data for installed packages


NOTE: Though not using the JFFS partition on the router, you must still have JFFS enabled in order to use ipkg. Disabling jffs also disables ipkg!


Log in to the shell (Telnet or SSH) and run:

mkdir -p /jffs/tmp/ipkg
ipkg update
ipkg list