todo/union mountinggit-annexhttp://git-annex.branchable.com/todo/union_mounting/git-annexikiwiki2020-06-17T01:18:32Zcomment 1http://git-annex.branchable.com/todo/union_mounting/comment_1_cb08435812dd7766de26199c73f38e8b/Michael2013-11-27T22:47:37Z2013-03-01T01:26:36Z
This would indeed be very helpful when remotely mounting a photo/video collection over samba.
comment 2http://git-annex.branchable.com/todo/union_mounting/comment_2_240b1736f6bd4fbf87c372d3a46e661b/edheil [wordpress.com]2013-11-27T22:47:37Z2013-03-01T04:50:28Z
+1 this would be sweet as hell
Please add this ;)http://git-annex.branchable.com/todo/union_mounting/comment_3_cf0a0d4fbd929f24f7056115b2acb7de/ypid2014-03-13T19:10:17Z2014-03-13T19:10:17Z
+1 This would be so great. For me the only thing which is missing in this awesome project.
Interim shell scripthttp://git-annex.branchable.com/todo/union_mounting/comment_4_2f02fe00a84bf94b7c8e437d8b80293f/chkno2020-06-17T01:18:32Z2020-02-04T07:26:10Z
<p>Until this feature is available in git annex proper, here is a small shell script that uses <a href="https://gitlab.freedesktop.org/xorg/util/lndir">lndir</a> to create a merged view of the .git/annex/objects areas of multiple git-annex repositories.</p>
<ul>
<li><a href="https://chkno.net/union-link-annexes">union-link-annexes</a></li>
</ul>
<p>Demo:</p>
<pre><code>$ git init repo1
$ cd repo1
$ git annex init repo1
$ echo from1 > from1
$ echo both > both
$ git annex add from1 both
$ git commit -m .
$ cd ..
$ git clone repo1 repo2
$ cd repo2
$ echo from2 > from2
$ git annex add from2
$ git annex copy --from origin both
$ git annex sync
$ git annex list
here
|origin
||
XX both
_X from1
X_ from2
$ cd ../repo1
$ git annex sync
$ cd ..
$ union-link-annexes merged repo1 repo2
$ grep . repo1/*
repo1/both:both
repo1/from1:from1
grep: repo1/from2: No such file or directory
$ grep . repo2/*
repo2/both:both
grep: repo2/from1: No such file or directory
repo2/from2:from2
$ grep . merged/*
merged/both:both
merged/from1:from1
merged/from2:from2
$ find merged -not -type d -printf '%p -&gt; %l\n'
merged/both -> .git/annex/objects/XV/zk/SHA256E-s5--f6d...
merged/from1 -> .git/annex/objects/vf/8W/SHA256E-s6--16e...
merged/from2 -> .git/annex/objects/3M/P2/SHA256E-s6--21e...
merged/.git/annex/objects/vf/8W/SHA256E-s6--16e... -> ../../../../../../../repo1/.git/annex/objects/vf/8W/SHA256E-s6--16e...
merged/.git/annex/objects/XV/zk/SHA256E-s5--f6d... -> ../../../../../../../repo1/.git/annex/objects/XV/zk/SHA256E-s5--f6d...
merged/.git/annex/objects/3M/P2/SHA256E-s6--21e... -> ../../../../../../../repo2/.git/annex/objects/3M/P2/SHA256E-s6--21e...
</code></pre>
union mounting and hidemissinghttp://git-annex.branchable.com/todo/union_mounting/comment_5_58c38383a7ac2df843772960fa10204f/chrysn2020-06-17T01:18:32Z2020-02-04T09:01:52Z
One easy way to achieve this with git-annex as is would be actual operating-system union mounting. This'll work as long as all (but the lowest / most costly) checkouts <a href="https://git-annex.branchable.com/tips/hiding_missing_files/">have their missing files hidden</a>. Just be sure not to call <code>git-annex</code> on the resulting directory (and if there's any danger of it, you might want to consider whiteing out the git configuration in an additional top layer), but only inside one of the supplying repositories.
Three union-mounting methods that *don't* workhttp://git-annex.branchable.com/todo/union_mounting/comment_6_65055977d7c8db3c9c29d90e033e5bb4/chkno2020-06-17T01:18:32Z2020-02-08T06:21:03Z
<p>Linux's in-tree union-mounting option overlayfs <a href="https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt">does not support modifications to underlying filesystems while an overlayfs mount is active</a>:</p>
<blockquote><p>Changes to the underlying filesystems while part of a mounted overlay filesystem are not allowed. If the underlying filesystem is changed, the behavior of the overlay is undefined, though it will not result in a crash or deadlock.</p></blockquote>
<p>I.e., it's great for the LiveCD case of combining a read-only squashfs and a private tmpfs into something that behaves just like a normal filesystem, but it cannot be used to export a read-only view of multiple mutable resources.</p>
<p>I can report that <a href="http://aufs.sourceforge.net/">aufs</a> also doesn't work for this use case, at least as of 2014 when I last tried it. Writes to underlying filesystems cause kernel panics that bring the whole machine down.</p>
<p>I can also report that <a href="https://github.com/hanwen/go-fuse/blob/master/example/unionfs/main.go">hanwen/go-fuse's unionfs</a> doesn't work for this use case. Example problem: Growing files' sizes get stuck at the size they were the first time they were viewed through the union mount.</p>