Often, what you call RAM disks are on Linux tmpfs file systems. Today, ramfs
is obsolete, so there is no reason to use ramfs
; better use tmpfs
(But indeed, you have been able in the past to buy real RAM "disk" hardware; AFAIK this is obsolete technology; today you'll better buy SSD).
A tmpfs
file system on Linux uses virtual memory, not RAM. So if you have enough swap space, and if RAM is tight (e.g. because some process is allocating a lot of memory using mmap(2) with MAP_ANONYMOUS
, perhaps thru malloc
...) the kernel would move some of the the tmpfs
data to swap space in its paging subsystem.
Read also linuxatemyram.
I don't understand why you want to "reserve a chunk of memory that OS has not access to it". You'll just waste RAM since by definition nothing could be able to access that chunk of memory (all the memory is by definition managed by the operating system). The only use case is when you know that some part of the RAM is physically broken (and you know which part and which physical address). Then you can configure your system to avoid it (but I forgot the details). Or perhaps you are running Linux over some hypervisor which does use that RAM in some other system VM -e.g. running another OS like FreeBSD?
My feeling is that you don't understand what is an operating system, what is an OS kernel, what are system calls, what is virtual memory, what is an address space, a process, the page cache (so your question does not make much sense!). You need to read a lot. Start with Advanced Linux Programming and follow all the links I gave here.
You might want a tmpfs
file system reserved to some applications. You could chown
the file tree in it to some user dedicated to these applications. See credentials(7), capabilities(7), ....
You might be interested by mlock(2) (it will lock some virtual memory segment into physical RAM), mmap(2), madvise(2), msync(2), mincore(2), or (to deal with file contents) posix_fadvise(2)
If you want to get some (virtual) memory and be sure that it is in RAM, get that memory range using mmap
(e.g. with MAP_ANONYMOUS
, or with MAP_FILE|MAP_LOCKED|MAP_SHARED
if you give a file segment) then lock that memory segment in physical RAM using mlock
(unless you used mmap
with MAP_LOCKED
which does an implicit mlock
)
You won't get any help unless you show some commands and some code related to your issue.