Lewati ke isi

overview

A ramdisk is a volatile storage space defined in the RAM memory. Using this feature increases file processing performance ten times over the best SSD hard disks. Implementing a ramdisk is very advantageous for users whose tasks require significant amounts of hardware resources. In addition, media editors and gamers can enjoy this implementation. A ramdisk is a volatile space, all information stored in it will be lost if the device is turned off or reboots.

In Linux, ramdisks can be created using the command mount and the filesystems tmpfs and ramfs. This tutorial shows how to create a ramdisk in Linux using both of them.

Tmpfs and Ramfs:

Tmpfs and Ramfs: Tmpfs: Tmpfs is a temporary file system stored in the RAM memory (and/or swap memory). By specifying this file system with the argument -t of the command mount, you can assign limited memory resources to a temporary file system. As a result, applications stored in this filesystem will perform several times faster than they would on conventional storage devices, including cssd devices.

Ramfs: Ramfs is similar to Tmpfs, but the user can’t ensure a limit, and the allocated resource grows dynamically. If the user doesn’t control the ramfs consumption, ramfs will keep using all the memory until hanging or crashing the system.

Tmpfs vs. Ramfs: There is no notable difference between the performance of tmpfs and its predecessor ramfs. The reason behind ramfs being replaced by tmpfs is the unlimited RAM consumption risk by ramfs which may lead to a system crash.

Another advantage of tmpfs over ramfs is the ability to use the swap space while ramfs are limited to hardware memory.

How to Create a Ramdisk in Linux Using Tmpfs:

sudo mkdir /tmp/ramdisk
sudo chmod 777 /tmp/ramdisk
sudo mount -t tmpfs -o size = 128mb myramdisk /tmp/ramdisk

Conclusion

Creating a ramdisk is a one-minute process with significant benefits for any user who needs to process big files. The reading and writing speed increase exponentially over the best hard disks in the market. Portable software can be executed from a ramdisk, though changes won’t be persistent. This implementation is being highly appreciated by media editors whose tasks require long periods of media conversion.

Using ramfs may be risky if the system runs out of resources. That’s why tmpfs became the first method.