Reputation: 91
I have a server that receives a file in a HTTP request, I'd like to make that file available to another process but I don't want the I/O overhead of writing that file to disk.
Are there any directories in linux that are actually mapped to RAM, so the process I start can access a path as is were a normal file?
I know that if I do this in a normal file, then there is a good chance that the file wont actually be flushed to disk because of cache, but that's not what I'm looking for.
Upvotes: 3
Views: 828
Reputation: 10336
You can use the following to create a RAM disk (as per these instructions):
mkdir /mnt/ramdisk
mount -t ramfs -o size=512m ramfs /mnt/ramdisk
Upvotes: 1
Reputation: 5853
In case you want to make sure a specific file is/stays in RAM, you can use vmtouch (https://hoytech.com/vmtouch/). However, the file will be written to disk.
Upvotes: 0
Reputation: 155744
There are no guaranteed locations that are backed by RAM, but it's not particularly hard to convert /tmp
to be backed by RAM if you have enough of RAM to spare. Given that /tmp
is cleaned out on boot anyway, it's an ideal choice for a RAM disk, since data loss due to power loss doesn't matter; the data would have been cleaned on boot anyway.
Upvotes: 3