Read-Only Filesystems
Linux can operate using a read-only filesystem as long as /etc, /home, /tmp, and /var are writeable. This can be accomplished at boot time by mounting these directories as RAM disks, and restoring their saved contents (with the exception of /tmp, which can be empty). Here’s an example script to do this:
#! /bin/sh # create file systems on the ramdisks /sbin/mke2fs -q -m 0 /dev/rd/1 /sbin/mke2fs -q -m 0 /dev/rd/2 /sbin/mke2fs -q -m 0 /dev/rd/3 /sbin/mke2fs -q -m 0 /dev/rd/4 # mount over read-only area with ram disks # do etc first, as sometimes mount wants to write to /etc/mtab mount -n /dev/rd/4 /etc cd /etc tar xf /staging/etc.tar mount -n /dev/rd/1 /home mount -n /dev/rd/2 /var mount -n /dev/rd/3 /tmp # from the staging area, restore cached copies of the dirs cd /var tar xf /staging/var.tar cd /home tar xf /staging/home.tar # transfer control to the rest of the init /etc/init.d/rcS
For more information on restoring directory contents, refer to Creating a Bootable CD Using a TimeSys RFS.