How to use multiple lower layers in overlayfs

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

According this document it should be possible to use multiple lower layers with overlayfs, but I can't get it to work on kernel 3.18.13. Am I using it wrong, or do I need a later kernel, and if so which one?

this works:

>>>mkdir lower1 lower2 upper workdir merged >>>echo hello > lower1/myfile >>>sudo mount -t overlay overlay -olowerdir=lower1,upperdir=upper,workdir=workdir/ merged >>>cat merged/myfile hello 

example very similar to document:

>>>sudo mount -t overlay overlay -olowerdir=lower1:lower2 merged mount: wrong fs type, bad option, bad superblock on overlay,        missing codepage or helper program, or other error         In some cases useful info is found in syslog - try        dmesg | tail or so. >>>dmesg | tail -n1 [42131.327203] overlayfs: missing upperdir or lowerdir or workdir 

ok, lets add them:

>>>sudo mount -t overlay overlay -olowerdir=lower1:lower2,upperdir=upper,workdir=workdir/ merged mount: wrong fs type, bad option, bad superblock on overlay,        missing codepage or helper program, or other error         In some cases useful info is found in syslog - try        dmesg | tail or so. >>>dmesg | tail -n1 [42155.052961] overlayfs: failed to resolve 'lower1:lower2': -2 

回答1:

It may be tempting to use multiple overlayfs mounts to achieve "stacking" of multiple lower directories, however, this has proven not achievable beyond two mounts with later kernel versions. That is, if you mount one set of upper/lower directories to a mountpoint then use the same mountpoint as another overlayfs mount's lower directory, the third mount attempt would fail and you would see this in dmesg: "overlayfs: maximum fs stacking depth exceeded". I see why a limiting stacking depth is needed, but it is unclear to me why this is currently set to 2.

So if you are stuck with 3.18 and can't yet move to 3.19 (as toto38 suggests) then you are looking for a way to use multiple "lower" directories without recompiling your kernel? If you're using RHEL/Centos/Fedora then funionfs is probably your best bet (yum install funionfs). You can specify multiple read-only lower directories in a single mount command:

funionfs -o dirs=<FIRST_LOWER_RO_DIR_PATH>=RO:<SECOND_LOWER_RO_DIR_PATH>=RO:<UPPER_RW_DIR_PATH> NONE <MOUNT_POINT_DIR_PATH>

I've never compared the performance between overlayfs and funionfs, though overlayfs is working in kernel space and funionfs is in userspace (via fuse) so I'd suppose that funionfs is probably has a bit more overhead than overlayfs.



回答2:

Multi-Layer Support Coming To OverlayFS In Linux 3.19
http://www.phoronix.com/scan.php?page=news_item&px=MTg1Nzg



回答3:

You can use one existing overlay over another one mounting it many times. Just set the lowerdir of one overlay as the mount point of an existing overlay (and so on...).



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!