256
Logo

Linux Memory/Temporary File System (FS)

I've always fought with creating a memory filesystem under linux. Too many possibilies: ramfs, romfs, cramfs, tmpfs and not enough (read no) documentation or help on how to do it. So here we go.

So I'm running the 2.6.18 kernel under Debian right now. YMMV. To create a temporary filesystem you do something like the following.

# make the mount point for our temporary filesystem
mkdir /mnt/tmpfs
# create and mount a 100 megabyte (100M) temporary memory filesystem
sudo mount -osize=100m tmpfs /mnt/tmpfs -t tmpfs

What Is It?

A filesystem is the underlying storage that allows programs to read and write files. A temporary filesystem is a filesystem that is not persisted to any physical media -- it only lives in memory. When you turn off your computer, it goes away -- USER BEWARE. So why use a filesystem that doesn't store your files? Because it is very fast. For systems which need space to keep temporary files, store logs, or other short-term space, temporary filesystems can be a big win.

Of course, temporary filesystems use system memory leaving less for the kernel disk-cache as well as program space. The size of a temp filesystem should be carefully selected and you may was to run some performance tests with different sizes to see how your application performs.

Linux Documentation Sucks

So linux documentation has always sucked. One of the problems with operating system design and implementation by committee is that there are always too many chiefs and no indians. The BSD-clan has always had better documentation. Good for them.

Free Spam Protection   ORMLite Java ORM   Android ORM   Simple Java Magic   JMX using HTTP