0

I followed this post to create a ramdisk. After that, when I copy a file to the directory, the file was copied, but memory usage as shown in gnome-system-monitor does not increase. Also, I tried reading the copied file from that directory but the speed is still as slow as reading a disk file. What did I do wrong?

EDIT:

I was wrong and the ramdisk (with either tmpfs or ramfs) had the files in memory. The free -m command does show this, while the gnome-system-monitor will not show it. Also ramfs popup as a mounted drive in nautilus but tmpfs does not.

However, in my case I need to do chmod on the ramdisk folder before I can copy files in, even if the ramdisk mount folder is in my home directory.

shaoyl85
  • 103
  • 1
  • 6

2 Answers2

0

The post in question uses tmpfs, which means it uses a combination of ram and swap. You may want to look into ramfs instead as it only uses ram space. I would imagine the command is similar. You could also use ramdisk which creates a virtual device that you can apply a filesystem to and everything.

Sources:

"tmpfs will use swap space when neccessary"

source = https://stackoverflow.com/questions/7242484/can-i-over-run-the-tmpfs-size

"If you compare it to ramfs (which was the template to create tmpfs) you gain swapping and limit checking."

source = www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

"The memory used by tmpfs grows and shrinks to accommodate the files it contains and can be swapped out to swap space"

source = http://en.wikipedia.org/wiki/Tmpfs

"Tmpfs uses swap, where as Ramfs doesn't."

source = What is the difference between tmpfs and ramfs

mungo
  • 16
  • 2
  • Thank you! I tried mount -t ramfs -o size=5120M ramfs /media/ramdisk/ but it does not do anything. – shaoyl85 Mar 23 '14 at 03:46
  • I believe you need to drop the trailing backslash "mount -t ramfs -o size=512m ramfs /media/ramdisk" – mungo Mar 23 '14 at 03:49
  • I tried it and it does not work either... – shaoyl85 Mar 23 '14 at 03:52
  • "sudo mount -t ramfs -o size=20m ramfs /home/example/ram" works for me. Shows up as mounted in nautilus. You are using an existing directory right? – mungo Mar 23 '14 at 04:00
  • It works but in my case I believe it is still using the disk spaces rather than the memory because when I copy a large file into the directory, the memory usage does not increase accordingly. – shaoyl85 Mar 23 '14 at 04:11
  • you can use the command "free -m" to see the correct ram usage. For example my System Monitor says I have 500mb ram free, but free -m says I only have 100mb which makes sense since my ramfs is 400mb. – mungo Mar 23 '14 at 04:43
  • Thanks. The free -m command does show that the file is in ram. – shaoyl85 Mar 23 '14 at 13:07
0

In response to your edit you don't need to chmod to copy files to the ramfs, just use gksu nautilus to open nautilus as root then right click on the ramfs mounted folder and change the user permissions to allow your user full permissions. Then you can happily write files to it as a regular user no sudoing required.

  • Thank you, but this is the same as doing sudo chmod on the folder right? I found that every time I do sudo mount to mount the drive, the folder becomes unable to write and I need to chmod or do what you just mentioned again. – shaoyl85 Mar 23 '14 at 20:46