I have read somewhere that one can put a file on a linux system into memory, and loading it will be superfast.
How do I do this? How do I verify the file is loaded from memory?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
On Linux, you probably already have an
tmpfs filesystem that you can write to at
$ >/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
mount ramfs -t ramfs /mountpoint
It's called a ramdisk. You can simply mount your RAM as follows:
mount tmpfs <mountpoint> -t tmpfs -o size=2G
This creates a ramdisk of 2 GiB. For more information see
man mount and search for
tmpfscan swap. Dec 24, 2012 at 11:05