Lazy disk backup for a ramdisk on Linux

disk-space-utilizationfilesystemsramdisk

Quick and dirty summary: I want something like a write cache that drains only when the system isn't busy.

I want something along the lines of this question RAM disk and physical RAID with a slight twist.

For a particular build I'm doing often, I would like to keep build output in a ramdisk that eventually gets written out to disk. One particular target I'm building is really a bunch of cp, tar, gzip and such so I'm disk bound. In a tight debug cycle I want it to be fast, and don't care so much if the build output is destroyed by power-off. However, it would be nice if the ramdisk was synced out to disk when the system wasn't busy. I can imagine doing this with a a cron job, but I'm asking you all on the off chance there's a more coherent solution that combines the characteristics of the other question (ramdisk that overflows to disk) with this new twist (given enough idle disk time, the contents of the ramdisk make it out to disk too). Idealy, the whole thing looks like a single mountpoint, where I set the total size and the amount of ram to use.

— updated —

I don't think the page cache does what I want because I really want pretty fast write performance.

Best Answer

Couple of wacky ideas. First, Puppy Linux kinda does this; it syncs your working space to permanent every so often. It seems to do this with smart scripts and simple copy commands.

Second ... what if you scheduled an rsync between ramdisk->real disk every so often?