6

I've been wanting to make us of a ramdisk on my Ubuntu system for a while, and have done a bit of reading online. Most of the advice centres around using /dev/shm to move files into RAM.

I wanted to try this out so I copied six 1GB files to /dev/shm, but according to gnome-system-monitor my RAM usage did not budge above 1.4GB. Is this how /dev/shm operates, or is there something else I need to do/use to ensure that files are stored in RAM and not on the HDD.

The reason I'm after the ramdisk is to speed up the analyses I run on this machine. Currently it uses at most about 1.6GB of the 24GB installed in the machine, and all that extra RAM doing nothing seems a bit of a shame.

1 Answer 1

8

Don't use /dev/shm, that's for a special purpose.

Instead, do something like this if you want to experiment:

sudo mkdir /ram
sudo mount -t tmpfs none /ram

Files stored in tmpfs are stored in either ram or (if there's too much memory pressure) in swap.

I don't know why you don't see an increase. Please post the actual commands you used, plus the output of the free -m shell command before and after.

You might like to read this post about understanding free memory in Linux too.

The memory will be used to cache the files from disk, so it is actually in a sense helping, assuming your load has a multi-GB working set of files. However, even heavily cached files do do some hard IO, and a ramdisk can be faster.

2
  • That implementation works great. Oddly, gnome-system-monitor does not show any increase in system RAM in the history panel, but free -m does.
    – stjep
    Apr 21, 2011 at 2:57
  • 1
    This doesn't seem to be an answer to the question. "You shouldn't do that anyway, do this instead" remarks should go in comments.
    – timuçin
    Oct 16, 2021 at 3:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .