I would like to be able to merge changes from the upper filesystem of an overlay mount to a lower filesystem.
I am interested both online (i.e. merge while the overlay is mounted) and offline (unmount the overlay and then merge) solutions.
I have found a couple of offline solutions, which I have added as answers.
Does anyone know of any online solutions? It would be good to have a "commit" type command you could run to merge down the layers while the overlay is still mounted.
Something like this has been asked in the following questions with no answer:
- Is there anyway to modify one file and sync to the lower directory in OverlayFs?
- How to modify a lower file through an OverlayFS directory?
- OverlayFS Seamlessly Edit File in Lower Directory
- OverlayFS - How to make changes to upper filesystem persistent without unmounting?
My goal is to have a safe filesystem sandbox with snapshots that can be used with any Linux application over any (where practical) underlying filesystem, allowing you to roll back changes or manually commit them when you are ready.
I have a suspicion that modern mainline Linux has all the necessary features to do this built-in, thanks to all the sandboxing/virtualization innovations of the last few years, if only I knew how to use them.