Creation and use of RAM Disk in Linux

December 29, 2005
In an earlier post, I had written about a very cool Linux distribution called Damn Small Linux whose size is just 50 MB. What I failed to mention was that, if you have enough memory, you can load this whole OS into memory which will make it blazingly fast. This can be achieved by using a RAM disk. But for that, you have to first know how to create a ram disk.

A RAM disk is a virtual disk which resides entirely in the memory of your PC. It is fixed in size and act like regular disk partitions. On the positive side, the access times of a ram disk are much faster than a physical disk but the data stored on a ram disk is lost once the system is powered down. There are some advantages to this. One being, you can use a ram disk to store and view your decrypted files and once your system is turned off, all traces of the decrypted file are lost.

So the big question is how do you create a ram disk ? Well, Van Emery has put together a Linux Ram Disk mini-How-To detailing just that. He walks you through the steps needed to create a ram disk on Linux. Just make sure that you have a Linux kernel with built-in support for ram disks. Any kernel equivalent to 2.4 or above should be fine.

2 comments:

  • Thanks. This is a cool link you have provided today.

    Now I might just as well try it out. :)

  • Jeff Schroeder

    There is a much easier way to create a ramdisk in 2.6 based kernels thanks for tmpfs.

    Example:
    mount -t tmpfs tmpfs /home/jeff/stuff

    That will create a variable sized ramdisk
    based upon the size of the files I put
    into it. Careful what you put into it
    though, if you run out of ram and start
    swapping, things could get ugly. See
    this page for a reference:
    http://gentoo-wiki.com/TIP_Speeding_up_portage_with_tmpfs