My understanding is that
fadvise will tell the system that the indicated files should be stored in the file system cache (RAM).
What is the purpose of mounting a directory in a ramdisk when you can just
fadvise --willneed the directory?
Let us read the manual page for the underlying library call:
Programs can use posix_fadvise() to announce an intention to access file data in a specific pattern in the future, thus allowing the kernel to perform appropriate optimizations.
The advice applies to a (not necessarily existent) region starting at offset and extending for len bytes (or until the end of the file if len is 0) within the file referred to by fd. The advice is not binding; it merely constitutes an expectation on behalf of the application.
Everything on a RAM disk is guaranteed to be in RAM, by design (though tmpfs can be swapped out). But fadvise is merely advisory; the kernel is not required to preload the data into RAM, nor to always keep it in RAM.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.