What is the difference between ramdisk and ramfs?

7

1

Kindly tell me the difference between ramdisk and ramfs.

LinuxPenseur

Posted 2010-11-15T10:33:37.133

Reputation: 191

Answers

4

"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

Alex

Posted 2010-11-15T10:33:37.133

Reputation: 41

3

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.

Jörg W Mittag

Posted 2010-11-15T10:33:37.133

Reputation: 1 236

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! – Torben Gundtofte-Bruun – 2010-12-01T18:35:14.070

2@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. – Jörg W Mittag – 2010-12-01T19:17:07.027

0

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.

A Vil

Posted 2010-11-15T10:33:37.133

Reputation: 1