Creating a RAM Disk on CentOS 6


Do take a look at clear and easy-to-understand article on the Difference between ramfs and tmpfs and Create a Ram Disk in Linux for more detailed information. The information of this blog is taken from Create a Ram Disk in Linux

There are many reasons to create a RAM Disk. One reason is to have a isolated latency test or throughput test between interconnect, but discounting the effects of the spinning disk I/O that might be the bottleneck to the test. Another case is to store temp files which require very fast I/O. Nothing beats memory.

Step 1: Check how much RAM you have. Display it in GB

# free -g
[root@n01 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         50276       1219      49056          0         83        555
-/+ buffers/cache:        580      49695
Swap:        25207          0      25207

You can also display with -m (MB) or -k (KB)

Step 2: Create and Mount a RAM Disk

# mkdir /mnt/ramdisk
# mount -t tmpfs -o size=16g tmpfs /mnt/ramdisk

Step 3: If you wish to create automatic mount, do place it at /etc/fstab

tmpfs       /mnt/ramdisk tmpfs   nodev,nosuid,noexec,nodiratime,size=16g   0 0
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.