[lug] RAM based files, file systems

Jeff Schroeder jeff at neobox.net
Tue Jan 27 23:47:23 MST 2004


Steve asked:

> Is it possible to create files, or file systems,
> that exist only in RAM?  Long ago Solaris supported
> such a feature, but I don't find it in Linux.

Are you talking about a RAM disk?  Or something more complicated?

To create a RAM disk in Linux, you need to have support for it compiled 
into the kernel-- but I suspect almost every kernel worth its salt does 
so. ;)

Then just create your filesystem, say ext2:

mke2fs /dev/rd/0

And mount it:

mount /dev/rd/0 /mnt/ramdisk

Voila, you can now do whatever you want in /mnt/ramdisk, because it's a 
regular filesystem.  Naturally all the data will go away on power-down.

(Note that /dev/rd/0 is the devfs designation for RAM disk #0; if you 
have an old-style /dev directory it might be named differently.)

(Also note that by default, the kernel allocates 4MB per RAM disk.  You 
can change this at boot time with an append option like 
"ramdisk_size=16384".)

HTH,
Jeff




More information about the LUG mailing list