Debian on WRAP: STEP 4


Posted by Ed on 07/12/2005 @ 7:12 PM

first, if you didn't already, read steps 1-3
STEP 1
STEP 2
STEP 3

/etc/fstab :

/dev/hda1 / ext2 defaults,ro,noatime 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
devpts /dev/pts devpts defaults 0 0
tmpfs /dev/shm tmpfs defaults,size=16m 0 0
tmpfs /tmp tmpfs defaults,size=10m 0 0
tmpfs /rw/var tmpfs defaults,size=50m 0 0
tmpfs /rw/root tmpfs defaults,size=10m 0 0
tmpfs /rw/etc tmpfs defaults,size=6m 0 0
tmpfs /rw/home tmpfs defaults,size=4m 0 0


I'll describe what's going on here. in my CF fs I have a directory used simply for mountpoints (rw) of tmpfs "partitions" I gave them arbituary max limits (tmpfs will only use what it needs for the files up to the size you give it). You can change those max sizes to your liking.

now for the script that we'll use for setting up the tmpfs directories and for updating back the changed contents to the RO CF fs.

/etc/init.d/copytoram

#!/bin/bash
case "$1" in
start)
echo -n "copying contents of writable directories to ram... "
cp --preserve=all -P -r /var /rw
cp --preserve=all -P -r /root /rw
cp --preserve=all -P -r /etc /rw
cp --preserve=all -P -r /home /rw
echo "done"
echo "binding tmpfs's over /.... "
mount --bind /rw/etc /etc
mount --bind /rw/var /var
mount --bind /rw/root /root
mount --bind /rw/home /home
echo "var, etc, home, and root have been binded"
;;
restart)
echo -n "unmounting tmpfs directories ... "
umount /root
umount /home
umount /var
umount /etc
mount -o remount,rw /
echo "Done."
echo -n "Copying updated files back to CF..."
cp -r -u /rw/etc /
cp -r -u /rw/var /
cp -r -u /rw/root /
cp -r -u /rw/home /
sync
echo "Done."
mount -o remount,ro,noatime /
mount --bind /rw/etc /etc
mount --bind /rw/var /var
mount --bind /rw/root /root
mount --bind /rw/home /home
echo "tmpfs remounted. Update complete"
;;
*)
exit 1;
esac
exit 0


Ok, hopefully that looks really simple to you. All we're doing is copying the contents of the CF directories that we want write access to, to the tmpfs directories then binding those directories back over the / so that no PATHS or links need to be changed.
in the restart function, we are updating the CF disk. This is the function you'll want to copy to another bash script and place in a cron directory of your choice for updating either daily, weekly, monthly or hourly if you wish, otherwise this will only occur when you execute it manually.

You'll need to make a symlink to rcS.d named S37copytoram so that copytoram's start function is executed directly after all the filesystems are mounted and before anything else is started.

Finally, before any network config files, we'll want to write the lilo config. You'll remember back in the much better written tutorial linked on Step 1, that lilo.conf appeared there. Copy that and edit it for your system, depending on the CF reader or adapter you're using, you'll need to change the device it'll appear as on your host system. set the kernel image name to 2.6.12.2 and save it.

So now the last thing you should need to do is set up the network config files and any programs you installed yourself like ssh and such. Network config will be covered in STEP 5



problems? Contact the site Administrator