Version 0 of memory file system

Updated 2004-05-29 01:14:41 by GPS

GPS: It's often useful for developers to run a memory file system that is contained in RAM. This is usually much faster, and easier on busy disks. With my Fed Builder and ProcMeUp projects which save to the disk automatically I've found it helps the applications stay responsive when the disk is busy.

Here are some techniques I use for creating a memory file system to work on my Tcl projects.

In NetBSD and OpenBSD you can use the mount_mfs command to associate memory with a directory. First create the /work directory and then add this to your /etc/rc.local (or edit your /etc/fstab):

 mount_mfs -s 20m swap /work

Caveat: It doesn't actually use the swap space when you use that command. You may find that using some sizes results in strange error messages upon creation. This is due to the ulimit being reached/surpassed. If you need a bigger file system you can increase the ulimit. /etc/login.conf may need to be added/changed in some cases too.

What if the power goes out? Well, you will of course lose the files, unless you have a battery backup/UPS. Here's a script I created that automatically makes backups of my /work directory every 4 minutes:

 $ cat sync_work.sh                                                             
 #!/bin/sh 

 while true
 do
  day=`date +%A`
  p=/home/gps/src/automated_backups/$day
  mkdir -p $p
  cd $p
  d=`date +%s`
  tar -cPf work_$d.tar /work 
  #60 * 4 = 240
  sleep 240 
 done

Category Dev. Tools