#!/bin/bash case "$1" in start) echo -n "copying contents of writable directories to ram... " cp --preserve=all -P -r /root /rw cp --preserve=all -P -r /var/log /rw # Add any other directories you wish to have write access to # Make sure fstab has the last dir in source path mounted in /rw #cp --preserve=all -P -r /source/dirname /rw echo "done" echo -n "binding tmpfs's over /.... " mount --bind /rw/log /var/log mount --bind /rw/root /root # Any additions you made in /rw should be mount binded here #mount --bind /rw/dirname /source/dirname ;; restart) # Write access to the underlying filesystem is required here, we also want atimes updated mount -o remount,rw / echo -n "Copying updated files back to CF..." mkdir /tmp/root_fs_copy mount --bind / /tmp/root_fs_copy cp -u -r /var/log /tmp/root_fs_copy/var cp -u -r /root /tmp/root_fs_copy # Any tmpfs data you wish to keep over restarts must be synced # to underlying fs #cp -u -r /source/dirname /tmp/root_fs_copy/source sync echo "Done" umount /tmp/root_fs_copy rmdir /tmp/root_fs_copy # remount the root fs back to the way you had it mount -o remount,rw,noatime / ;; esac exit 0