LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   What is the purpose of a Ramdisk. (https://www.linuxquestions.org/questions/linux-general-1/what-is-the-purpose-of-a-ramdisk-842425/)

theKbStockpiler 11-04-2010 05:05 PM

What is the purpose of a Ramdisk.
 
Why is Ram treated like a hard drive? Most data must be in RAM so why would the RAM need a file system when the data was put in by what ever is controlling RAM anyways. Is this some sort of a short cut to just import a file along with it's file system so the same file can be used for two different things?

Thanks in advance!

MS3FGX 11-04-2010 05:07 PM

A "RAM Disk" is used in place of a standard disk drive because it is many times faster, and data held in RAM is not retained after a reboot. This makes RAM drives perfect for things like /tmp, where you want fast access but don't necessarily want to keep the data around.

It has nothing to do with data actually going into and out of RAM and the CPU, that is a much lower-level concept.

theKbStockpiler 11-04-2010 05:35 PM

So.... RAM is RAM.
 
Either way the data would be in RAM so why the purpose of a RAMdisk? The CPU never gets data directly from the hard drive does it?

jschiwal 11-04-2010 06:46 PM

When you boot up, the initd file is loaded to into a cache file system in ram. The partitions aren't mounted yet, so the entire Linux filesystem exists in RAM.

The eeePC uses a unionfs which layers a cache ram file system on top of the file system on the SSD. This reduces the number of writes to the SSD drive, extending its life.

Without a cache layer, calls to write to a device would hang until the device signalled success. For some programs, this may be for each byte of data.

A pen drive or SD card operates on a section of data at once. First the entire section is read, then changes are made, then the section is written back. It is desirable to cache changes so the section can be modified in one operation.

A cache allows speed increases transparently, without coding writes to ram.

A program that explicitly uses a ram disk may be doing so to allow rapid modifications to the data, and may also be using the memory as a form of communication with a subprocess or another program. Access control would use file permissions. Imagine a program that uses plugins. You don't know what the plugin might be when writing the program. You write your data to file and leave it up to the plugin to read the data and do what it needs to do.

Back in the 80's I used an Amiga. It was standard practice to use the RAM disk in scripts. The first Amigas used floppies, so you can imagine the speedup obtained writing to a ramdisk instead of the floppy.

theKbStockpiler 11-04-2010 07:30 PM

Thanks for the Reply!
 
I can't use it though unless it is paraphrased.

syg00 11-04-2010 07:59 PM

RAMDISK is used to guarantee the filesystem is always in RAM (once loaded). It is not subject to page-out or page stealing.
Consequently of course it also reduces the amount of RAM available to the rest of the system.

jefro 11-04-2010 08:18 PM

In VERY simple terms.

Data in ram is not useable by programs that didn't put it there. There is no way to place and retrive data there easily. Ram is ram, but ram is not a hard drive.

A ram disk is a hard drive to the OS but since it is basically the original ssd one can expect way faster access to data. Every program knows how to access and use a hard drive.


All times are GMT -5. The time now is 12:26 PM.