This recipe teaches you how to take advantage of RAM's low latency using a RAM disk, a section of memory made available as if it were a standard storage device. RAM disks often store volatile data that is constantly read and updated in memory. For example, on desktop systems they're used for storing a browser's cache to speed up web surfing. In server environments, RAM disks can store cache data for high-load proxy services to reduce latency.
This recipe requires a CentOS system with administrative privileges provided by logging in with the root
account or using sudo
.
Perform the following steps to create and use a RAM disk:
Check whether there is sufficient memory available for the RAM disk using
free
command (a practical RAM disk will need to be smaller than the amount of free memory):free -h
Use
mount
to mount atmpfs
filesystem at the desired mount point, giving the target size as a mount option:mount -t tmpfs -o size=512M tmpfs /mnt
When...