Flashybrid - minimizing flash writes

Overview

Reducing flash writes on the Sheevaplug is often required for many applications.
With a combination of Debian/Wheezy and Flashybrid, flash writes can be reduced to a minimum amount. Fewer flash writes implies a longer lifetime for your SDHC or NAND.
If you are using a plug as a router, proxy, access point or PBX then Flashybrid is a handy way to keep you flash memory healthy.
We have tested Flashybrid in a number of scenarios with Debian/Wheezy on both the plug flash and SD card. The results have been good.

SheevaPlugs with Flashybrid and SD cards, configured with uBoot 3.4.27, UBIFS, Debian Wheezy and a 2.6.3*.* kernel) are available from the shop.


This document summarizes the work of others in enabling Flashybrid on Debian.

References

The reference links are as follows:
Plug forum 1 - Flashybrid
Plug forum 2 - Flashybrid
Plug Wiki - Installing Debian to flash
Plug Wiki - Reduce Flash Writes
http://www.lesswatts.org/tips/disks.php
http://www.cyrius.com/debian/nslu2/linux-on-flash.html
http://blog.bofh.it/debian/id_265
http://forums.plugpbx.org/index.php/topic,32.msg117/topicseen.html#msg117

Prerequisites


Setup

Update /etc/sysctl.conf
Consult the references. Some iteration over the supplied values is recommended.
# See: http://plugcomputer.org/plugwiki/index.php/Reduce_Flash_Writes
#      http://www.cyrius.com/debian/nslu2/linux-on-flash.html
vm.swappiness=0
# the following values can be as high as 100, 12000, 12000
vm.laptop_mode=5
vm.dirty_writeback_centisecs=1500
vm.dirty_expire_centisecs=1500
# defaults shown, suggested values of 10 and 1
#vm.dirty_ratio = 20
#vm.dirty_background_ratio = 10
Fix fstab
Change /etc/fstab to look something like the following. For NAND boots
# NAND root
/dev/root       /       ubifs   defaults,noatime,rw     0 0
# SDHC root
#/dev/root      /       ext2    rw,relatime,errors=continue 0 0
tmpfs   /lib/init/rw    tmpfs   size=16K,rw,nosuid,relatime,mode=0755 0 0
tmpfs   /var/run        tmpfs   size=1M,rw,nosuid,mode=0755     0 0
tmpfs   /var/lock       tmpfs   size=512K,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs   /var/tmp        tmpfs   size=512K,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs   /tmp    tmpfs   defaults,nosuid,nodev,mode=1777 0 0
For SD boots
# NAND root
#/dev/root      /       ubifs   defaults,noatime,rw     0 0
# SDHC root
/dev/root       /       ext2    rw,relatime,errors=continue 0 0
tmpfs   /lib/init/rw    tmpfs   size=16K,rw,nosuid,relatime,mode=0755 0 0
tmpfs   /var/run        tmpfs   size=1M,rw,nosuid,mode=0755     0 0
tmpfs   /var/lock       tmpfs   size=512K,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs   /var/tmp        tmpfs   size=512K,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs   /tmp    tmpfs   defaults,nosuid,nodev,mode=1777 0 0
Install Flashybrid
# apt-get install flashybrid
Apply the patch
/etc/init.d/flashybrid needs to be changed. You can download the patch.
# cd /
# patch --verbose -p0 </path to patch/flashybrid.patch
# rm /etc/rc{0,1,2,3,4,5,6}.d/*flashybrid
# insserv -v flashybrid
Configure flashybrid
create the directory /ram
# mkdir /ram
Modify /etc/flashybrid/ramtmp
# vi /etc/flashybrid/ramtmp

/var/lib/dhcp3
/var/lib/php5
/var/lib/misc
/var/lib/ntp
/var/lib/urandom
Modify /etc/flashybrid/ramstore
# vi /etc/flashybrid/ramstore

/etc
/var/backups
/var/lib/dbus
/var/lib/logrotate
/var/log
/root
/var/spool/cron
modify the value ENABLED in /etc/default/flashybrid
# vi /etc/default/flashybrid

ENABLED=yes
or use
# echo 'ENABLED=yes'>/etc/defaults/flashybrid
reboot
# shutdown -r now
Flashybrid commands
Flashybrid sets the rootfs to read only, so to change something you need to make the rootfs writeable (Directories listed in ramstore are mounted read/write).

To make things writeable:
# mountrw

To make things read only:
# mountro

To sync the ram store with the rootfs:
# fh-sync

Diagnostics

Given the above setup. mount looks something like:

/dev/root on / type ext2 (ro,relatime,errors=continue)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,relatime,mode=755)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=10240k,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
tmpfs on /var/run type tmpfs (rw,nosuid,relatime,size=1024k,mode=755)
tmpfs on /var/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1024k)
tmpfs on /var/tmp type tmpfs (rw,nosuid,nodev,noexec,relatime,size=512k)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /ram type tmpfs (rw,relatime,size=94208k)
tmpfs on /var/lib/misc type tmpfs (rw,relatime,size=94208k)
tmpfs on /var/lib/urandom type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/etc.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /etc type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/var/backups.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /var/backups type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/var/lib/dbus.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /var/lib/dbus type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/var/lib/logrotate.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /var/lib/logrotate type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/var/log.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /var/log type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/root.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /root type tmpfs (rw,relatime,size=94208k)
/dev/root on /ram/var/spool/cron.flash type ext2 (ro,relatime,errors=continue)
tmpfs on /var/spool/cron type tmpfs (rw,relatime,size=94208k)

Back
 
Spinifex Computing Copyright © 2011 Spinifex Computing Pty. Ltd. All rights reserved.