Overlayfs with a lot of directories

overlayfs

Say I have an arbitrary number of directories, labeled by numbers.

I also have the directory merge.

I can do

mount -t overlay -olowerdir=1:2:50 overlay merge

to get the contents of 1, 2, and 50 in merge.

What is the best way to 'add' more directories to the overlay, say, 23, 81, and 457 as if I had done the command

mount -t overlay -olowerdir=1:2:50:23:81:457 overlay merge

in the first place?

If I want to "unoverlay" a certain directory, say 23, can I do it without unmounting the entire thing?

Conceptually, I guess you could say I want an arbitrary number of directories on the same "level" of overlay.

Best Answer

(I have exactly the same problem.) The only info I could find about it, is this:

From https://lkml.org/lkml/2014/11/10/129 :

Maybe it wasn't clear, but the number of lower layers isn't limited by
FILESYSTEM_MAX_STACK_DEPTH, only by the max size of the mount option buffer in
the kernel (1 page, usually 4096bytes).  So you could have a hundred read-only
layers stacked in a single overlayfs mount.

As for changing the stacking while the overlayfs is mounted: currently this is
not supported, the layers specified at the mount time remain there until the
overlay is unmounted.  Currently there's no possibility to add or remove layers
in a dynamic way, and it is definitely more tricky to implement than the static 
configuration.

-- Miklos Szeredi Mon, 10 Nov 2014
Related Question