11

Kindly tell me the difference between ramdisk and ramfs.

0

3 Answers 3

6

"RAM disk" is a device driver that merely creates block devices that store their data in memory (fixed max size, allocated gradually by need), which you can use for any purpose, e.g. create ext2 filesystem on it and then mount to some location in filesystem. Many Linux distributions are by default configured to automatically create and present these devices as /dev/ram0, /dev/ram1, ...

"ramfs" is a filesystem driver. To utilize it, you use "mount" command, just specify filesystem type (ramfs) and target directory; device is not required (e.g. "none" can be used): mount -t ramfs none /path/to/location

Regarding usage, the major difference between two is that "ramfs" reuses existing kernel caching mechanisms to store its data. In other words, when you write to "ram disk" your data is saved to memory allocated by that ram disk, plus that data is saved in RAM by kernel caching mechanism, so we get duplication here. When using ramfs, no duplication happens, as ramfs directly uses those caching mechanisms as its own (ramfs) implementation.

See also: https://www.kernel.org/doc/Documentation/blockdev/ramdisk.txt https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt

5

A RAM disk implements a virtual disk in volatile memory. A RAM filesystem implements a virtual filesystem in volatile memory.

In other words: the difference between a RAM disk and a RAM filesystem is the difference between a disk and a filesystem.

2
  • So what then is the difference between a disk and a filesystem? To me it sounds like a box and a crate -- different word, same thing. Please elaborate. Danke! Dec 1, 2010 at 18:35
  • 3
    @torbengb: a disk is a physical device, i.e. hardware that stores unstructured 0s and 1s, without meaning. A filesystem is a data structure, i.e. software (very much like a database, actually -- in fact, a filesystem arguably is a database) that stores structured directories and files (and file metadata such as permissions, ownership, creation date etc.) which have actual meaning. Dec 1, 2010 at 19:17
1

Ram disk is a fixed size disk in memory. RamFS is a File system in memory that can use up all the memory and cause a system crash. Other than that the performance of the 2 is very similar.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .