Ram Drive or Disk

Howdy everyone

I’m wanting to setup a ram-drive/disk on my linux computers to try and speed my old computers up a bit. I have successfully done it on a friends windows 10 laptop which seems to have help that old laptop nicely. It was a simple process using IMDisk. For Manjaro and Linux in-general it’s seems to be a lot more convoluted.

I seem to have plenty of ram to use, at the time of writing this I have six programs running. I have Opera web browre, libreoffice with a 50 page document, KMahjongg, Pithos and task manager. I seem to be using only 31% of 8g of ram and the CPU’s hovering around 6%. I have never seen my ram usage even come close to 50% and I do have a swap file setup for the SSD.

So has anyone successfully set one up? and what was the process you used.

Looking forward to hearing some useful input
Dave C

What problem are you trying to solve?

If you have 8 GB of total available physical RAM, Linux will try to lessen the I/O on your storage devices by caching data and metadata. This not only yields better read and write performance, but it’s also healthier for your drives.

Don’t be fooled by the “so much wasted RAM” myth.

If you create a “RAM disk”, then you take away what the system can use for cache’d data, metadata, and of course working memory of tasks and applications.

What would this RAM disk be used for? How will it benefit the overall user experience? (Remember, it’s all flushed away after each reboot.)


If you really want to create one, you can use tmpfs to manually (or automatically) create a useable RAM disk at a particular path.

For example, to create a 2 GB RAM disk mounted at the location /mnt/ramdisk

mount -t tmpfs -o noatime,size=2G tmpfs /mnt/ramdisk

You can use ramfs instead of tmpfs, but I don’t recommend it, since tmpfs is more forgiving, in that it will dip into your swap if it runs out of space, rather than hanging the system or aborting in the middle of a write operation.

7 Likes

Hello @drcarlson :wink:

I fully agree with @winnie . Linux loads the files into the ram cache and then run it. If you want to speed that up for certain apps, I think vmtouch is a better approach.

pamac build vmtouch

Let’s say you want to speed up firefox and the profile by preloading the files into the ram cache.

# Unload files from cache
vmtouch -e -f $HOME/.mozilla/ $HOME/.cache/mozilla/ /usr/lib/firefox/ 
# Check Page Usage (buff/cache)
free -h
# Load files into cache
vmtouch -t -f $HOME/.mozilla/ $HOME/.cache/mozilla/ /usr/lib/firefox/
# Check again Page Usage (buff/cache)
free -h

You can even lock it with (parameter -l or -L), so that it never leaves the RAM. However, that is the natural method to speed up file access and Linux does it all the time. With vmtouch you force the kernel to do so.

There is also an AUR script for a systemd service:

pamac build vmtouch-systemd-git

It is pretty straight forward. Add full paths of files and folders to /etc/vmtouch.conf and re-/start the service. Now the called files and folders are locked to the cache and will never leave the RAM as long as the service runs.

4 Likes

I wish to thank both winnie and megavolt for getting back to me. their insight into the inner workings of the Manjaro Linux operating system has enlightened me more then a little. No doubt anyone else stumbling across this question will be saved sometime and effort chasing after some worthless preconceived notion.

But it did get me to checking some settings on my device and discovering that my swap file is not working. so I’m off like a herd of turtles to ponder and remedy the problem.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.