What is the difference between ramdisk and ramfs?

Kindly tell me the difference between ramdisk and ramfs.


"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


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.