How to place / store a file in memory on linux?
On Linux, you probably already have an tmpfs
filesystem that you can write to at /dev/shm
.
$ >/dev/shm/foo
$ df /dev/shm/foo
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 224088 0 224088 0% /dev/shm
This may use swap, however. For a true ramdisk (that won't swap), you need to use the ramfs
filesystem.
mount ramfs -t ramfs /mountpoint