A shell script which creates and manages named overlayfs mounts backed by the contents from tar files.
https://github.com/wagoodman/tar-overlay.git
Note: this is a work in progress, so it is not stable yet.
1) install a tar, this becomes an immutable 'image':
[wagoodman@vm1 ~]$ tar-overlay install-image ~/Downloads/msgpack-python-0.4.6.tar.gz
[wagoodman@vm1 ~]$ tar-overlay list-images
msgpack-python-0.4.6
2) create a few instances and mount them:
[wagoodman@vm1 ~]$ tar-overlay create-overlay foo msgpack-python-0.4.6
[wagoodman@vm1 ~]$ tar-overlay create-overlay bar msgpack-python-0.4.6
[wagoodman@vm1 ~]$ tar-overlay list-overlays
scratch1
scratch2
[wagoodman@vm1 ~]$ tar-overlay mount-overlay foo
~/bin/tar-overlay/store/instances/foo/rootfs
[wagoodman@vm1 ~]$ tar-overlay mount-overlay bar
~/bin/tar-overlay/store/instances/bar/rootfs
Note: the output for each mount attempt is where the instance mountpoint is.
3) Make some changes in one of the instances (foo):
[wagoodman@vm1 ~]$ tree -L 1 ~/bin/tar-overlay/store/instances/foo/rootfs
~/bin/tar-overlay/store/instances/foo/rootfs
โโโ COPYING
โโโ msgpack
โโโ PKG-INFO
โโโ README.rst
โโโ setup.py
โโโ test
2 directories, 4 files
[wagoodman@vm1 ~]$ rm -rf ~/bin/tar-overlay/store/instances/foo/rootfs/test
Notice that we can query which files have changed:
[wagoodman@vm1 ~]$ tar-overlay show-changes foo
.
โโโ test
โโโ test_buffer.py
โโโ test_case.py
โโโ test_except.py
โโโ test_extension.py
โโโ test_format.py
โโโ test_limits.py
โโโ test_newspec.py
โโโ test_obj.py
โโโ test_pack.py
โโโ test_read_size.py
โโโ test_seq.py
โโโ test_sequnpack.py
โโโ test_subtype.py
โโโ test_unpack.py
โโโ test_unpack_raw.py
1 directories, 15 files
Also notice that the other instance (bar) still has the original file:
[wagoodman@vm1 ~]$ tree -L 1 ~/bin/tar-overlay/store/instances/bar/rootfs
~/bin/tar-overlay/store/instances/bar/rootfs
โโโ COPYING
โโโ msgpack
โโโ PKG-INFO
โโโ README.rst
โโโ setup.py
โโโ test
2 directories, 4 files
[wagoodman@vm1 ~]$ rm -rf ~/bin/tar-overlay/store/instances/bar/rootfs/test
(See, the 'test' dir is still there)
4) Restore the 'foo' instance back to the original contents from the tar:
[wagoodman@vm1 ~]$ tar-overlay reset-overlay foo
[wagoodman@vm1 ~]$ tree -L 1 ~/bin/tar-overlay/store/instances/foo/rootfs
~/bin/tar-overlay/store/instances/foo/rootfs
โโโ COPYING
โโโ msgpack
โโโ PKG-INFO
โโโ README.rst
โโโ setup.py
โโโ test
2 directories, 4 files
Docker provides almost the same functionality via dockerfiles, however, I am not using docker for this project... so building and managing images this way seemed awkward if I wasn't planning to use docker for containers. Instead, since overlayfs has been integrated into the kernel and a wrapper script seemed simple enough to make, tar-overlay was born!
tar-overlay [command] [options]
Image commands:
install-image <tar-file> Take the given tar and make it available as in immutable image.
list-images List all known images.
Overlay Commands:
create <name> <image-name> Instantiate an image (make an instance).
list List image instantiations.
mount <name> Mount an instantiation for use.
mount-all Mount all overlays.
info <name> Show all information regardin the given overlay name.
rename <name> <new name> Rename the given instantiation.
reset <name> Undo all changes made to original image.
show-changes <name> Show a tree of all modified files
status <name> Shows if the given overlay is mounted.
umount <name> Unmount an instantiation.
umount-all Unmount all overlays.
Future Commands:
rename-image <iamge-name> Rename the given image.
delete-image <image-name> Delete the given image.
mount-image Mounts an image directly (not advised).
umount-image Unmounts a directly mounted image.
delete <name> Delete the given instantiation.