So as I posted here...http://www.plugpbx.org/?p=367
I’ve got a special idea
Boot the system from SD card read-only – map to a RAM disk what needs read/write access (like the SQL database, and logs, and /etc).
Make some changes? No problem, just click a ’snapshot’ button on the PlugPBX web interface and the system remounts read/write and syncs whats changed back to your SD card – when done, mount it read only again.
Bullet proof. No SD card wear outs, lock your setup down – power interruption survivability. Use a cron script to sync changes back to SD card as you wish perhaps?
Need to apply an update? Flip the SD card back to read/write – do your apt-get fun and then throw it back to read-only with a single command.
Its called flashybrid (set of scripts). Some issues, but found some clever work arounds. I’m playing with this on my own phone system (eat the dog food) and if I can make this work safe, Its where I’m taking things – there is far too much risk with SD card media being used heavily, and this makes for a rock solid system.
SO.. Patience as I tinker away. I will release the same system with this add on for now, along with a roll up of fixes and bugs found to date when time and tests permit. Backup your setups and be sure to use quality media for now.
I am looking for some testers of this idea. The risk is that you could blow up. SO you'd backup your SD card to a spare before doing this. I'm trying this out tonight at home myself in about 10 minutes after this worked on a test bed)
1) apt-get install flashybrid
2) add "ENABLED=yes" to /etc/default/flashybrid
3) mkdir /ram (root of system)
4) Configure the three following files as follows:/etc/flashybrid/config
# This is the main configuration file for the flashybrid system./etc/flashybrid/
# The mount point of your flash memory.
# You probably want a ramdisk to be set up with directories that the system
# needs to write data to frequently, so that your flash disk can be mounted
# read-only. Flash memory can only be written to several thousand times over
# its lifetime, so setting up a ramdisk will extend the lifetime of your
# flash a lot. This is the location to mount the ramdisk. Comment out the
# line to not set up a ram disk.
# Commands to run to enter full mode. The disk will be mounted before
FULL_CMDS="mount -o remount,rw /"
# Commands to run to enter embedded mode. The disk will be unmounted before
# this. If you wanted to spin a disk down, you could add a hdparm -y
EMBED_CMDS="mount -o remount,ro /"
# This controls the maximum ammount of memory you want to allocate
# to the tmpfs RAM drive
# This parameter is optional, and if you do not supply if, tmpfs will
# occupy up to 50% of your available memory (ram+swap)
# You may also want to edit the other files in this directory:
# ramtmp, ramstore
# This is a list of directories that are used to store variable data/etc/flashybrid/ramtmp
# that is written to during normal operation of the system, and that should
# be preserved across reboots.
# On boot, the listed directories on your flash disk will be copied to the
# ram disk, and then bind mounts will be used to make the directories on
# the ram disk replace them.
# On shutdown, the contents of those directories on the ramdisk will be
# rsynced back to the flash disk.
# Directories listed here that are not present will be silently ignored.
# Do not put the trailing slash on directories!
# Should always be in ram disk.
# If you don't use devfs/udev, you will want /dev in ram, since many things
# need to modify it when the system is running. Not needed on systems
# running udev.
# Necessary if the system is to be able to send mail while in embedded
# This is a list of directories that should be set up as temporaryAnd then finally this dirty hack for now in /etc/rc.local
# directories in the ramdisk. On boot, the directories listed will be
# created on the ramdisk, mode 1777. Their contents will not be saved
# across reboots. The equivilent directories on your flash will be
# removed and replaced with symlinks to these directories.
# Do not put the trailing slash on directories!
# This could go in ramstore if you prefer for its contents to persist
# across reboots.
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
#We have to restart syslog and cron to force them to start using our
#ramdisk binded mount points with flashybrid - it does not create them soon enough during init startup
#We then set the system to run the root filesystem read only
Then, take a deep breath, and reboot. The mount points to ram don't happen soon enough for the four services restarted in rc.local, hence restarting them which then has them open files in the ram disk. The "mountro" and its friend the "mountrw" are flashybrid scripts that set the root filesystem read only or read/write (so you can make changes dummy!)
Should bootup readonly, just type "mount" in ssh once fully booted up and see the following first line. Yah its gonna be messy, lots of stuff is binded to the ram disk mounts
/dev/mmcblk0p2 on / type ext2 (ro,errors=remount-ro)
SO in theory when you shutdown, changes are rsynced from ramdisk back to your SD card (not sure how reliable flashybrids stuff is) and you can trigger a sync with the 'fh-sync' script command anytime.
Looking for some testers, I think this or something close is the way to go. Makes unreliable SD card lifetimes fixed, gets us closer to a linksys router type of embeded setup, but you can still work with it like a normal server at a flick of a switch.
Idea is to perhaps sudo fh-sync and put a 'save now' button on the PlugPBX web page.
If anyone wanted to help me out, this is the big one I need feedback on from testers. Roll up and dive in.