I came to the conclusion that aufs is limited to 127 layers based on tests.
(prepare)
mkdir write joined {1..400}
for((i=1;i<=400;i++));do echo >$i/$i.txt;done #for checks
using a single mount, the limit is 84 layers (numbereds + the write one).
The folder name doesn't change the 84 limit (so each could be bigger ex. "layer-72", therefore not a string size limitation).
sudo mount -v -t aufs \
-o "sync,br=write:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84" \
"none" "joined";echo $?
The above will fail, unless you remove ":84" from the end.
Using remount, it can go up to 127 layers (numbereds + the write one)
sudo mount -v -t aufs -o "sync,br=write" "none" "joined";echo $?
for((i=1;i<=400;i++));do
echo "try $i";
if ! "sudo" "mount" -v "-o" "remount,append:$i" "joined";then
break; # it stops with error "No space left on device", but is not related to free bytes on storage!
fi;
ls -l joined/$i.txt;
done
research
I am trying to use mount.aufs just to see readable error messages, as mount -v is not helping.
Is there documentation specifying how to translate mount parameters to mount.aufs?
I am still trying to find mount.aufs source code too; that could help my understanding of what parameters it accepts.
Alternative acceptable answer
Is aufs patchable (as apparently 127 is a hard-coded limit)? Is it worth the effort/mess, or more than 127 may cause performance issues as suggested on comments?
Could an alternative folders merger provide more than 127 layers? If so, which one? Here a list I found: overlayfs unionfs mhddfs mergerfs docker. What commands I should use based on the test case I provided above? aufs is quite clear and simple to use and understand, and that was the main reason I chose it.
PS.: I am using this now: how to make mergerfs behave like I did aufs behave: only write everything new or modified (including paths, everything..) to a single writable folder?