Making a small ramdisk or memory storage for temporary calculations

Doing small experiments with databases will almost always make your disk-activity led flicker like it needs to be replaced. However, all that disk activity is not needed as most computers nowadays have enough memory to store even a 100Mb of experimental random data.

Using a memory based SQLite database is not always doable as you may have to share it between different languages and processes. The easiest and most general solution is to create a small disk in memory which you can use to store whatever you want. Here is how...

1. Create a directory:

mkdir memdisk

2. Mount it as a tmpfs of the right size and give yourself the rights to work with it:

sudo mount -t tmpfs -o size=5M,mode=0775 tmpfs memdisk
sudo chown ${USER}.${USER} memdisk

The options should be self explanatory. Changing 5M into 100M will create a 100Mb ramdisk istead of 5Mb as in the example.

Happy hacking!