RAM can be used as a temporary storage in Linux and performance wise it is much faster than your traditional hard drives . Since it is a volatile memory , this storage won’t sustain a shutodwon or a sudden power drop on your system . Nowdays, there are ways to handle this by keeping a copy of this storage in a sperate hardrive and do a restore or sync once the systems comes back online . Also, in production enviornment you might need the RAM disk to dump temporay data without interrupting the actual drives .
Fisrt create the mount point ,
mkdir /mnt/ramdisk
Now mount the ramdisk to the created mount point . You can sepecify the disk size depends upon what is available from your total memory
mount -t tmpfs -o rw,size=2G tmpfs /mnt/ramdisk
That’s now created and you can very it from :
df -h
If you need to release the RAM for any reason :
umount /mnt/ramdisk
This is a temporay mount and inroder to make this permanent you need add the fstab entry . Fstab is one of the important file and its better to take a backup before making any changes to it .
cp -v /etc/fstab /etc/fstab.backup
nano /etc/fstab
You will see the fstab entries there and you can add the RAM disk at the very bottom:
tmpfs /mnt/ramdisk tmpfs rw,size=2G 0 0
Exit the editor and try a reboot .