Almost every embedded Linux device being in development must finally be mounted "read-only" to avoid clobbering the file system when powering off immediately without doing a save shutdown. The problem in this case are the processes which want to create and write into files (log files, configuration files, temporary files).
An interesting way for making an embedded Linux "poweroff-save" is the use of a RAM disk and the mount option "bind". In an embedded Linux it is not too difficult to find all the processes, who want to write into files. Most times these files can be found in the directories /etc, /var and /tmp.
Procedure:
1) Creating a RAM-Disk
2) Mounting the RAM-Disk
mount -t $TMPFS rwfs /mnt/rwfs -o size=$TMPFS_SIZE
3) copying the affected directories into the RAM-Disk
RAMDIRS="$RAMDIRS /tmp /etc /var"
for i in $RAMDIRS
do
if [ ! -e /mnt/rwfs/$i ] ; then
cp -a $i /mnt/rwfs/
fi
done
4) Doing a binding mount of the new directory in the RAM-Disk.
for i in $RAMDIRS
do
if [ ! -e /mnt/rwfs/$i ] ; then
mount -o bind /mnt/rwfs/$i $i
fi
done
Doing this very early (e.g. with a startscript) would be very good to make the system not whining about unlucky tries to write.
Donnerstag, 12. November 2009
Abonnieren
Posts (Atom)