Friday, July 10, 2009

Easily create a RAM-disk in Linux

This command creates a 2GB RAM-disk and mounts it to /tmp/space.
$ mkdir /tmp/space
$ sudo mount -t tmpfs tmpfs /tmp/space -o size=2G,nr_inodes=200k,mode=01777
You should now have an extra 2GB storage device.
 $ df -h | grep space
$ tmpfs                 2.0G     0  2.0G   0% /tmp/space
You access the temporarily device by it's mountpoint /tmp/space. Needless to say, once you unmount this volume (for instance, with a reboot), the data on it will be gone. Use with care! :) Tested on Ubuntu, should work with any 2.4 or 2.6 kernel...

1 comment:

document storage said...

As a newbie in Linux, this core command script will serve me well. I may need to use this wisely and run it first on a virtual test environment.