Journalling Flash File System

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 01:55, 15 February 2007 (edit)
Whiteboy (Talk | contribs)

← Previous diff
Revision as of 12:56, 26 May 2007 (edit) (undo)
Dr. Ongo (Talk | contribs)
m
Next diff →
Line 1: Line 1:
The '''[[Glossary#Journalling Flash File System (JFFS)|Journalling Flash File System (JFFS)]]''' 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)]]''' 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>
-Since the WRT54G and other [[Installation#Supported_Devices|models]] contain too little memory(4MB), it is not usefull to activate normal jffs within them.<br>+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> As you might need the /jffs directory, take a look at [[#/jffs with little flash|/jffs with little flash]].<br>
Line 6: Line 6:
* use mini firmware on WRT54G (still doesn't leave much room...)<BR> * use mini firmware on WRT54G (still doesn't leave much room...)<BR>
-* get a WRT54GS with bigger flash (not much more expensive than WRT54G but gives quite a bit of room, 14MB free with VoIP) (in the WRT54GSv4 they have changed the memory sizes to the WRT54G sizes)<BR> +* 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)<BR>
* Non-JFFS: do the the [http://kiel.kool.dk/ SD card mod] (unlimited room using swapped multiple SD cards, but it's a really ugly and utterly nasty hack)<BR>* Non JFFS, but an alternative would be to go into setup and mount a samba share. Look at [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs this] for info on how. If you are a Linux newbie look at this [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs_sharing_in_a_Linux_server other] * Non-JFFS: do the the [http://kiel.kool.dk/ SD card mod] (unlimited room using swapped multiple SD cards, but it's a really ugly and utterly nasty hack)<BR>* Non JFFS, but an alternative would be to go into setup and mount a samba share. Look at [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs this] for info on how. If you are a Linux newbie look at this [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs_sharing_in_a_Linux_server other]
= JFFS with Flash = = JFFS with Flash =
-Given you use the mini-version or have more than 4MB of flash you can activate jffs.+Given you use the mini version or have more than 4&nbsp;MB of flash you can activate JFFS.
-Take care, that inspite 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.+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.
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 25: Line 25:
might reboot/hang after cleaning which might take long, so be patient might reboot/hang after cleaning which might take long, so be patient
-Maybe the options in the webinterface below work for you (they didn't for me):+Maybe the options in the web interface below work for you (they didn't for me):
Administration:<br> Administration:<br>
Line 31: Line 31:
Clean JFFS2: 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):
nvram set sys_enable_jffs2=0 nvram set sys_enable_jffs2=0
Line 39: Line 39:
reboot reboot
-Afterwards you can nvram unset this variables.+Afterwards you can delete this variables with "nvram unset <variable>".
=== Testing === === Testing ===
Line 50: Line 50:
To mount the samba share under /jffs you can either To mount the samba share under /jffs you can either
-* Use a Startup Script+* Use a startup script
-* Use Samba Startup Scripts+* 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: 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. 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:
umount /jffs umount /jffs
Line 70: Line 70:
Now here are instruction on how to do so: Now here are instruction on how to do so:
-1) disable jffs in the webgui if you had enabled it<br>+1) disable JFFS in the web GUI if you had enabled it<br>
2) enable [[Samba Filesystem|samba]] (see also [[Jffs_sharing_in_a_Linux_server]]).<br> 2) enable [[Samba Filesystem|samba]] (see also [[Jffs_sharing_in_a_Linux_server]]).<br>
Line 93: Line 93:
cd / cd /
- #make sure jffs is unmounted. Its recommended to run without jffs enabled though.+ #make sure JFFS is unmounted. Its recommended to run without JFFS enabled though.
echo "umounting /jffs if nescessary..." >> $SMBLOG echo "umounting /jffs if nescessary..." >> $SMBLOG
umount /jffs >> $SMBLOG 2>&1 umount /jffs >> $SMBLOG 2>&1
Line 101: Line 101:
smbmount $SMBSHARE /jffs -o username=$SMBUSER,password=$SMBPASS >> $SMBLOG 2>&1 smbmount $SMBSHARE /jffs -o username=$SMBUSER,password=$SMBPASS >> $SMBLOG 2>&1
- #hand over startup to the jffs part+ #hand over startup to the JFFS part
/jffs/$JFFS_SCRIPT & >> $SMBLOG 2>&1 /jffs/$JFFS_SCRIPT & >> $SMBLOG 2>&1
4) create a script called "startup.jffs.sh" on the share:<br> 4) create a script called "startup.jffs.sh" on the share:<br>
Line 112: Line 112:
umount /tmp/smbshare umount /tmp/smbshare
- #to enable ipkg, we fake jffs enabled.+ #to enable ipkg, we fake JFFS enabled.
- #since theres no commit, this wont actually enable jffs+ #since theres no commit, this wont actually enable JFFS
nvram set sys_enable_jffs2=1 nvram set sys_enable_jffs2=1
Line 122: Line 122:
6) reboot<br> 6) reboot<br>
<br> <br>
-Now you should have the share configured in the webinterface mounted at /jffs and should also be able to run 'ipkg' !+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 [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs_sharing_in_a_Linux_server this ] *NOTE: If you are a Linux newbie, and you have problems with file permissions, look at [http://wrt-wiki.bsr-clan.de/index.php?title=Jffs_sharing_in_a_Linux_server this ]

Revision as of 12:56, 26 May 2007

The Journalling Flash File System (JFFS) 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.
Since the WRT54G and other models contain too little memory (4 MB), it is not usefull to activate normal JFFS within them.
As you might need the /jffs directory, take a look at /jffs with little flash.

If you really need or want to use JFFS with a WRT54G you have to first enable JFFS under the Administration page,
and either:

  • use mini firmware on WRT54G (still doesn't leave much room...)
  • get a WRT54GS with bigger flash (not much more expensive than WRT54G but gives quite a bit of room, 14 MB free with VoIP) (in the WRT54GSv4 they have changed the memory size to the WRT54G size)
  • Non-JFFS: do the the SD card mod (unlimited room using swapped multiple SD cards, but it's a really ugly and utterly nasty hack)
    * Non JFFS, but an alternative would be to go into setup and mount a samba share. Look at this for info on how. If you are a Linux newbie look at this other

Contents

JFFS with Flash

Given you use the mini version or have more than 4 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.

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

Maybe the options in the web interface below work for you (they didn't for me):

Administration:
JFFS2 enabled: X Enable Disable
Clean JFFS2: X Enable Disable

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 this variables with "nvram unset <variable>".

Testing

Log in and run:
ipkg update
ipkg list

/jffs with little flash

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

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

#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