Since it happened to me to have this task as my homework assignment in the Telerik’s software academy Linux administration course, I decided to have this valuable knowledge shared here.
For starters lets first define RAM disc: basically we might refer to this as a RAM memory turned into a storage device instead of random access memory.
What are the pros and cons: If we have to point the good sides of RAM memory when used as storage device there’s a point that always matters: Performance. Yes, RAM is the fastest performing memory if you need to read fast and write fast from your discs, and by fast I mean way faster than any HDD configuration, even SSD.
Here’s a small figure showing some numbers:
Obviously results speak for themselves.
Bad sides: Well as we all know life’s unfair and every performance gain we have, comes on a high price, including RAM discs, too. Being a volatile memory, RAM will be completely erased and all your data – lost, if your computer powers off. So be careful keep that in mind and be prepared to store all your valuable data on your hard drives if you have plans to power off.
Here’s some quick steps to create a RAM disc on Linux.
First you need a spare RAM, that’s for sure and as you can guess if are going to make the RAM disc bigger than 4 GB you will need 64 bit OS. You can easily check the amount of free memory with the ‘free’ command with parameters ‘-m’ for megabytes or ‘-h’ for human readable format.
Lets say we want to create a 2 GB RAM disk. We first witch to Root:
# mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
# mount -t tmpfs -o size=2048M tmpfs /tmp/ramdisk/
2048 here stands for the size of RAM we want to relocate as RAM disc. Needless to say, the amount of RAM should be less than your free RAM, otherwise you will include swap memory, and that will be the end of your performance.
As a conclusion we might say using a RAM disc is really a good choice when it comes to performance and low cost but we need to be careful about what data we put in there if our machine is not powered on 24/7.
1 thought on “Creating RAM disc – Linux”
Reblogged this on Sutoprise Avenue, A SutoCom Source.