Journalling Flash File System

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 06:34, 15 September 2006 (edit)
Lukrass (Talk | contribs)
(Category:Advanced HOWTO)
← Previous diff
Revision as of 10:00, 15 September 2006 (edit) (undo)
Lukrass (Talk | contribs)
(corrected the topic and introduced a little guide)
Next diff →
Line 38: Line 38:
Tested on pre5<br><br> Tested on pre5<br><br>
-==jffs on WRT54G==+==/jffs with little flash==
-Since the WRT54G contains too little memory, jffs will always report 'full'. If you dont need the extra stuff from 'normal you can reflash using the 'mini' distro and use jffs<br>+Since the WRT54G contains too little memory(4MB), jffs will always report 'full'.
-However if you need 'normal' functionality but also want to use jffs (eg for ipkg) you can use samba to accomplish this.+You have two possibilities:
 +* Use [[What_is_%22DD-WRT%22%3F#v23_File_Versions|'mini' distro]]
 +* Use [[Samba Filesystem|Samba]] and mount the share under /jffs
 + 
 +To mount the samba share under /jffs you can either
 +* Use [[Startup Scripts]]
 +* Use Samba Startup Scripts
 + 
 +The second method uses 2 scripts: The first will mount the Samba share under /jffs and the second will unmount /tmp/sambashare
 + 
 +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 webgui if you had enabled it<br>

Revision as of 10:00, 15 September 2006

Contents

Introduction

journaled flash file system (jffs) is used to store user programs and data into otherwise inaccessible flash memory. Inspite of general purpose read/write one must take care not to store frequently changed files on it as this can cause flash wear out. Journal file is used to minimize frequent overwrites.

Instructions

To enable jffs (please read note about "flash wear out" above!) enter the following commands (when you're connected via ssh or telnet on a shell):

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

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):

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

Testing

Log in and run:
ipkg update
ipkg list

Tested on pre5

/jffs with little flash

Since the WRT54G contains too little memory(4MB), jffs will always report 'full'. You have two possibilities:

To mount the samba share under /jffs you can either

The second method uses 2 scripts: The first will mount the Samba share under /jffs and the second will unmount /tmp/sambashare

Now here are instruction on how to do so:

1) disable jffs in the webgui if you had enabled it
2) create a network share on windows or linux (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 webinterface mounted at /jffs and should also be able to run 'ipkg' !

If everything else fails

If you can't write to /jffs but need it for example for "ipkg" then you can umount it and then, if have a NAS or a share on a pc, mount a networkt share to /jffs.

I personally use a startup script to unmount/mount /jffs everytime the router starts up.. Works perfectly.


My boot script to mount the jffs partition is:

umount /jffs
smbmount //<server's IP>/jffs /jffs -o username=<your username, guest if hosted on windows>,password=<your password>


  • 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!
  • OTHER NOTE: To save you the steep learning curve experienced by many users, if you're getting full errors and you're using a WRT54G, reflash with the mini distro. The normal version is too big!
  • EXTRA 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)