I want to have one folder in which I will store data which needs to be queried as fast as possible and the disk makes me wait a lot even it is SSD. On the other hand I have to store it permanently. I may made compromise which is that the data can be stored on the disk periodically (automatically!). I have UPS power supply so if the power gone I will not (eventually) lose the data.


"Your question has been identified as a possible duplicate of another question. If the answers there do not address your problem, please edit to explain in detail the parts of your question that are unique."

I do not found any information on how to configure auto save of the data to persistent storage, periodically.

Another requirement: on boot I would like the data from the persistent storage to get back on the RAM folder/partition.

Complete solutions will be highly appreciated!

  • 1
    Possible duplicate of How do I make a RAM disk?
    – Yaron
    Commented Mar 23, 2017 at 15:13
  • Do you see any information on how to auto save periodically the data on persistent storage? Or something equal? I do not.
    – daffr32
    Commented Mar 23, 2017 at 16:14

1 Answer 1

  1. Create a RAM disk

As described here you can make a RAM disk

mkdir -p /media/nameme
mount -t tmpfs -o size=2048M tmpfs /media/nameme/
  1. Copy last backup into RAM disk

    cp -ru /source/path /destination/path

Where source/path is the location of the backup-data, and /destination/path is the RAM disk location

Note: The same script which runs on boot and execute Create a RAM disk can also copy the data from the backup-folder into the RAM disk.

  1. auto save periodically the data on persistent storage:

You can create a simple script which will copy the content of this RAM disk once a period of time (minute/hour/etc) using a cron tab See here how to set a cron-tab.

crontab -e

running a copy/backup command every 15 minutes:

*/15 * * * * /path/to/command
  1. Copy command:

The command might be something like:

cp -ru /source/path /destination/path

-r -recursive

-u --update - copy only when the SOURCE file is newer than the destination file or when the destination file is missing

  • Thanks for the info provided. Unfortunately that is not fully automated I will have to execute commands after reboots. Please see "Another requirement" in my question.
    – daffr32
    Commented Mar 26, 2017 at 11:09
  • @daffr32 - I've updated my answer to also support copy from backup to RAM disk
    – Yaron
    Commented Mar 26, 2017 at 11:47
  • Great! Can you confirm that the commands provided will not conflict. I will setup the execution of the command to copy the disk to the RAM once on boot. Second command which will execute each 5 minutes will copy from RAM to the disk. If that is the case I am going to accept the answer. However can you tell if there is a way to lock somehow the RAMdisk until the first rsync on boot which copies from the disk is done. The point is to make it unusable until it is completely synced.
    – daffr32
    Commented Mar 26, 2017 at 18:35
  • @daffr32 - the command provided should not conflict. The copy from disk to RAM shouldn't take much time. waiting several seconds for the first copy from disk to RAM should be good enough.
    – Yaron
    Commented Mar 27, 2017 at 6:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .