This tutorial will teach you how to create a ram disk on a Linux distribution and unmount it when needed. This lesson can be used to reduce the data processing bottleneck.
1. The components of the Ram Disk
In the computer world, which is more in the hardware world, we often hear about RAM.
RAM (for Random Access Memory) is random access memory found in all computers. It allows data to be temporarily stored. What is it for? Why is it so important? Here is everything you need to know about this computer component that is RAM.
1.1. What is RAM?
RAM is a type of memory, in this case, random access memory, as opposed to read-only memory. Extremely fast compared to a computer’s hard drive, RAM is essential for the smooth use of any PC. From a hardware standpoint, it comes in the form of a small rectangular circuit board. Then there are RAM sticks, which are plugged into the computer’s motherboard. These modules come in two formats, DIMMs for desktop computers and SO-DIMMs for laptops. The RAM is erased automatically when the computer turns off.
1.2. What is a computer’s RAM used for?
This RAM is simply essential for your computer: it is what allows the processor to store the data it needs to start a program temporarily. The operating system (Windows, Mac OS) is loaded into the RAM. Each application used is thus launched on the RAM. This is why the larger the RAM, the faster and smoother the computer will be, as well as the ability to run a large number of software or applications at the same time.
1.3. RAM storage and measurement.
RAM size is expressed in gigabytes. It is capable of transmitting information at more than 10 GB per second. The higher the RAM capacity of a computer, the faster and more multitasking it will be. If 4 GB of RAM is sufficient for office use, it is advisable to choose eight or even 16 GB of RAM for a PC-oriented video game or graphics.
1.4. RAM against ROM.
RAM is opposed to read-only memory (ROM). ROM is non-volatile memory, unlike RAM. Its content is fixed during its programming. ROM is not cleared when the system is turned off, which is beneficial when the computer starts up. The BIOS, in particular, uses read-only memory to be able to keep a certain number of parameters.
This sounds natural, but you are making changes to a file without saving it to the hard drive. The proof when you reopen, it hasn’t changed. It’s not magic; it’s the action of your RAM. Indeed, when you make changes to the file, these are stored temporarily in your RAM; we say that they are loaded on the RAM. Only when you ask to save it will these changes be applied to the hard drive.
So that’s great; RAM brings speed, but what if you run out of it? There are two cases, either the system erases “old” files to make room. Or it is really running out of space, and it will then use a small piece of the hard drive to serve as memory; this partition is called “SWAP”; we say “often” that the system will SWAP. This, of course, has a significant impact on the speed of access, as you can imagine.
Memory RAM is much faster compared to the fastest solid-state drive (SSD). One of the main bottlenecks in data analysis today is the speed of the hard drive; thus, moving files into the RAM disk may guarantee a much faster execution time as observed in bioinformatics (1, 2, and 3 – look for RamDisk).
2. Creating a RamDisk on Linux
Creating a RamDisk is easy and can be done by executing the commands below:
# create ramdisk directory
$ mkdir /ramdisk
# mount ramdisk of 100G
$ mount -t tmpfs -o size=100G tmpfs /ramdisk
# change directory permissions
$ chmod a+rwx /ramdisk/
3. Umount a RamDisk on Linux
Unmount a ramdisk on Linux is simple: all you need to do is to call the command unmount and the directory where the ramdisk resides; please see below
$ umount /ramdisk
Conclusion
This tutorial teaches how to mount and unmount a ramdisk on Linux. The ramdisk can be handy to speed up some data analysis in fields like bioinformatics.