GNU/Linux has union mount that overlays dirs. So you can mount a writeable dir on top of a read-only dir. When the writeable dir is unmounted the read-only dir is untouched.
I am looking for the same functionality for block devices - preferably with the writeable part stored in a file. So I would like to run something like:
device-setup /dev/newdevice /dev/read-only-device overlayfile
If I write to /dev/newdevice the changes should be stored in overlayfile. If I read the sectors written to, I should get the data from overlayfile. If I read sectors not written to, I should get the data from /dev/read-only-device.
Does such a tool exist?