Journalling Flash File System

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 06:14, 18 November 2007 (edit)
S2s2 (Talk | contribs)
m (Structure cleanup.)
← Previous diff
Revision as of 09:30, 18 November 2007 (edit) (undo)
S2s2 (Talk | contribs)
(Grammar and Structure. Updated to bring current.)
Next diff →
Line 1: Line 1:
-= Introduction and Overview =+== Introduction and Overview ==
-The '''[[Glossary#Journalling Flash File System (JFFS)|Journalling Flash File System]]''' (JFFS/JFFS2) allows you to have a writable Linux File System on a DD-WRT enabled router. It is used to store user programs like [[Ipkg]] and data into otherwise inaccessible flash memory. This allows you to save custom configuration files, host custom Web pages stored on the router and many other things not capable without JFFS.<br>+The '''[[Glossary#Journalling Flash File System (JFFS)|Journalling Flash File System]]''' (JFFS/JFFS2) allows you to have a writable Linux File System on a DD-WRT enabled router. JFFS is used to store user programs and data into otherwise inaccessible, read-only flash memory. This allows you to save custom configuration files, run [[Ipkg|ipkg]], host custom Web pages stored on the router and many other things not capable without JFFS.
-Since the WRT54G and other [[Installation#Supported_Devices|models]] contain too little memory (4&nbsp;MB), it is not usefull to activate normal JFFS within them.<br>+
-As you might need the /jffs directory, take a look at [[#/jffs with little flash|/jffs with little flash]].<br>+
-If you really need or want to use JFFS with a WRT54G you have to first enable JFFS under the Administration page, and either:+Except for early versions of some Linksys routers (no longer available), most routers contain 4MB of total internal Flash memory, a few contain more. See [[Installation#Supported_Devices|models]]. When using 4MB models, JFFS is only useful or usable with a Mini version of DD-WRT, which leaves about 700KB of available space in /jffs. Standard DD-WRT takes up the entire 4MB.<br>
-* Use mini firmware on WRT54G (still doesn't leave much room...)+Creating a read-write /jffs space, without using (much) space on the internal Flash memory:
-* Non-JFFS: add the [[SD/MMC mod|flash memory]] card modification - unlimited room using a swappable SD card. In this case, JFFS is used simply to load drivers to gain access to external storage media.+* 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). On older firmware (v2.3), limited JFFS can be used to hold the drivers to load support for the SD card.
-* As a non-JFFS alternative, go into setup and mount a [[Samba]] share. See [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs this] for info. If you are a Linux newbie [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs_sharing_in_a_Linux_server see this].+* On Standard firmware or larger, one option is to use a [[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 may be useful if you have a NAS or an always-on server, so the share is continuously available. Also see [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs this] for more info. To setup your /jffs share to point to a Linux box and you are a Linux newbie [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs_sharing_in_a_Linux_server see this].
 +* 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 offloaded to one or more external USB devices.
 +* [[ipkg]] requires a /jffs directory, so take a look at using [[#JFFS with little flash|JFFS with little flash]].
-If you have the option to do so, it would be far easier (at a relatively minor difference in initial price) to work with a more powerful device:+== Enable JFFS when Flash Space is Available (i.e. Mini on 4MB, or >4MB Internal Flash) ==
-* get a WRT54GS with bigger flash (not much more expensive than WRT54G but gives quite a bit of room, 14&nbsp;MB free with VoIP) (in the WRT54GSv4 they have changed the memory size to the WRT54G size; the -GL version is a possible alternative.)+
-* get a [[Linksys WRTSL54GS]] or [[ASUS WL-500g Premium]]; as these devices have USB capability, a small amount of JFFS space is used simply to load any needed [[USB storage]] drivers and startup files, so that other storage-intensive tasks can then be offloaded to one or more external USB devices.+
-= JFFS with Flash =+Take care not to store frequently changed files on Flash as this can cause flash wear out over time. A journal file system is used to minimize frequent overwrites.
-Given you use the mini version or have more than 4&nbsp;MB of flash you can activate JFFS.+
-Take care, that in spite of general purpose read/write not to store frequently changed files on it as this can cause flash wear out. Journal file is used to minimize frequent overwrites.+
 +''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.'' On the router web page click on Administration. Scroll down until you see JFFS2 Support. Click Enable JFFS. Click Save. Wait couple seconds, then click Apply. Wait again. Go back to the Enable JFFS option, click Clean JFFS. '''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): Enter the following commands (when you're connected via ssh or telnet on a shell):
Line 30: Line 29:
might reboot/hang after cleaning which might take long, so be patient might reboot/hang after cleaning which might take long, so be patient
-* WARNING: I tried these command under La Fonera firmware v24 RC4 and corrupted all my setting. 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 below and it works for me.+* WARNING: 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.
- +
-Maybe the options in the web interface below work for you (they didn't for me):+
- +
- Administration:<br>+
- JFFS2 enabled: X Enable Disable <br>+
- Clean JFFS2: X Enable Disable <br>+
To unmount the JFFS (in case it was too small): To unmount the JFFS (in case it was too small):
Line 46: Line 39:
reboot reboot
-Afterwards you can delete this variables with "nvram unset <variable>".+Afterwards you can delete these variables with "nvram unset <variable>".
-=== Testing ===+== JFFS with little flash (i.e. Standard firmware on 4MB) ==
-Log in and run:<br>+
-ipkg update<br>+
-ipkg list<br>+
- +
-=/jffs with little flash=+
If you have too little flash memory but need some memory under /jffs you can use [[Samba Filesystem|Samba]] and mount the share under /jffs If you have too little flash memory but need some memory under /jffs you can use [[Samba Filesystem|Samba]] and mount the share under /jffs
Line 64: Line 52:
NOTE 2: You might not be able to use symbolic links when using windows-hosts. Rename(mv) could work. NOTE 2: You might not be able to use symbolic links when using windows-hosts. Rename(mv) could work.
-==Use a Startup Script==+===Use a Startup Script===
Read first, howto use [[Startup Scripts]]. Then place the following into your startup script to mount the JFFS partition: Read first, howto use [[Startup Scripts]]. Then place the following into your startup script to mount the JFFS partition:
Line 70: Line 58:
smbmount //<server's IP>/jffs /jffs -o username=<your username>,password=<your password> smbmount //<server's IP>/jffs /jffs -o username=<your username>,password=<your password>
-*NOTE: username is guest if hosted on Windows when 'Simple File Sharing' is enabled.+*NOTE: username is guest if hosted on Windows XP & 'Simple File Sharing' is enabled.
-==Use Samba Startup Scripts==+=== Use Samba Startup Scripts ===
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. 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.
Line 159: Line 147:
* '''/tmp/smbshare''' located in a shared folder on my NAS called '''ddwrt''', which contains scripts (including '''startup.sh''' containing the above commands), yet to be installed packages and other static data * '''/tmp/smbshare''' located in a shared folder on my NAS called '''ddwrt''', which contains scripts (including '''startup.sh''' 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 * '''/jffs''' located in a shared folder called '''jffs''', which contains program data for installed packages
 +
 +
 +== Testing ==
 +Log in to the shell (Telnet or SSH) and run:<br>
 +
 + mkdir /jffs/tmp
 + mkdir /jffs/tmp/ipkg
 + ipkg update
 + ipkg list
[[Category:English documentation]] [[Category:English documentation]]
[[Category:Advanced tutorials]] [[Category:Advanced tutorials]]

Revision as of 09:30, 18 November 2007

Contents

Introduction and Overview

The Journalling Flash File System (JFFS/JFFS2) allows you to have a writable Linux File System on a DD-WRT enabled router. JFFS is used to store user programs and data into otherwise inaccessible, read-only flash memory. This allows you to save custom configuration files, run ipkg, host custom Web pages stored on the router and many other things not capable without JFFS.

Except for early versions of some Linksys routers (no longer available), most routers contain 4MB of total internal Flash memory, a few contain more. See models. When using 4MB models, JFFS is only useful or usable with a Mini version of DD-WRT, which leaves about 700KB of available space in /jffs. Standard DD-WRT takes up the entire 4MB.

Creating a read-write /jffs space, without using (much) space on the 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). On older firmware (v2.3), limited JFFS can be used to hold the drivers to load support for the SD card.
  • On Standard firmware or larger, one option is to use a 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 may be useful if you have a NAS or an always-on server, so 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.
  • 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 offloaded to one or more external USB devices.
  • ipkg requires a /jffs directory, so take a look at using JFFS with little flash.

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

Take care not to store frequently changed files on Flash as this can cause flash wear out over time. A journal file system is used to minimize frequent overwrites.

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. On the router web page click on Administration. Scroll down until you see JFFS2 Support. Click Enable JFFS. Click Save. Wait couple seconds, then click Apply. Wait again. Go back to the Enable JFFS option, click Clean JFFS. 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
reboot

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

  • WARNING: 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.

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
reboot

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

JFFS with little flash (i.e. Standard firmware on 4MB)

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: Even though you are not using the JFFS partition on the router, you must still have JFFS enabled in order to use ipkg. Disabling jffs also disables ipkg! See further instructions.

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

Use a Startup Script

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

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 "startup.smb.sh" on the share:

#!/bin/sh

#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
JFFS_SCRIPT=startup.jffs.sh

#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 "startup.jffs.sh" on the share:

#!/bin/sh

#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 "startup.smb.sh" 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 (Alternative Method)

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

Procedure:

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

#!/bin/sh
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 startup.sh 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


Testing

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

mkdir /jffs/tmp
mkdir /jffs/tmp/ipkg
ipkg update
ipkg list