OverlayFs merge on unmount

1

For performance reasons I would like to stack tmpfs on top of the working directory of some programs. However, the program needs to access data previously saved in the "real" working directory, sometimes lots of data. So, instead of copying the whole folder to tmpfs, I thought of using OverlayFs in a similar fashion to DeepFreeze.

However, I would like to make the data persistent when unmounting the union (for example on poweroff), overwriting previous files with the same path, and leaving the other untouched.

Is there a way to automatically do this, without the user having to remember to "sync" the folders? I cannot find a feature of OverlayFs for this, and the alternative I could think of, namely a umount hook, seems not practical to implement.

matpen

Posted 2016-12-31T11:59:40.700

Reputation: 195

Answers

1

You may want to take a look at   anything-sync-daemon.
It's designed to mount user-specified directories via tmpfs / overlayfs and then sync them back to persistent storage periodically, so it's pretty much exactly what you're trying to do. This page has a great overview of what it is and how it works; I know there are similar pages, as well as prebuilt packages available for many distributions.

Another option, not as applicable to your need but which I'll mention for others who may have a similar use case, is   profile-sync-daemon.
It's specifically tailored to keeping browser profile directories on tmpfs / overlayfs and works pretty much the same as anything-sync-daemon, but for a more specific use case.

Rubio

Posted 2016-12-31T11:59:40.700

Reputation: 569

Thank you for the pointer. Actually "anything-sync-daemon" is more suited for the job, as "profile-sync-daemon" is specifically tailored for browser profiles. Could you add this to your question (and maybe a link to the wiki or github page of the project) so that I can mark it as accepted? – matpen – 2017-01-03T09:59:05.837

I *knew* there was another package! I just couldn't find it. I'm using profile-sync-daemon currently as it does what I wanted, but I found it (quite some time ago) from a reference to it on some anything-sync-daemon page I was looking at; I was happy to find one suited just to browser profiles, as otherwise I was contemplating hacking anything-sync-daemon to do the same thing. I'm updating my answer to include that. – Rubio – 2017-01-03T10:07:38.477