Wednesday 7 March 2007

Create a Linux ram disk to use with an application

If you have plenty of RAM memory, it may be useful to create a temporary RAM disk to use for fast file read-write of an application. Often guides tell you how to create an initial ram disk for the Linux boot, but what about building a ramdisk for everyday use?



It's matter of just four commands. First, create the device:

mknod -m 660 /dev/ram b 1 1

Then, give the dimension you want to the new ramdisk, let's say, 4k. You do it by filling it with the right amount of zeroes:
dd if=/dev/zero of=/dev/ram bs=1k count=4k

Then it's just matter of creating your mountpoint:

mkdir /mnt/ramdisk

and mounting it as an ext2:
mount -t ext2 /dev/ram /mnt/ramdisk
That's it.

1 comment:

yuce said...

I guess you forgot to create the filesystem, this one works:

> mke2fs -m 0 /dev/ram