Re: Please help me setup ramdisk

Posted by cschanzle on 2012/1/19 15:39:14
Since the OP is asking for a ramdisk, that means the files are smaller than RAM, so it is also plausible to just pre-read them into cache by "cat file1 file2 > /dev/null" or if you have a whole directory tree of files, do something like:

find /dir -type f -exec cat '{}' + > /dev/null

If you put the "time" command in front of that, and then repeat it, you'll see on a second run, it will complete much faster because it's basically reading the file content from RAM. Also, you can watch your hard drive activity LED's basically be "off" on a second run.

You can also monitor the "cached" line from the "top" command to see how much of your RAM is used for disk caching.

Rather than reboot to clear your cache, you can: sync; echo 1 > /proc/sys/vm/drop_caches

That's documented in /usr/share/doc/kernel-doc-*/Documentation/sysctl/vm.txt

Finally, the mount(8) man page describes the options (e.g., size=) to mount tmpfs (ram-based filesystems, aka ramdisks) and you can use your system-provided /dev/shm mount in /etc/fstab as an example.

This Post was from: https://www.centos.org/newbb/viewtopic.php?forum=55&topic_id=35335&post_id=152547