如何提供overlayfs的嵌套mount

时间:2014-09-18 10:30:03

标签: linux ubuntu debian mount

我尝试将overlayfs层挂载为下层overlayfs,但是在两层之后它会崩溃

mount -t overlayfs -o rw,lowerdir=/tmp/test/layers/centos5.6-layer0-lower,upperdir=/tmp/test/layers/centos5.6-layer0-upper overlayfs /tmp/mount/centos5.6-layer0-mount
# remove deleted files into overlayfs
find /tmp/mount/centos5.6-layer0-mount -lname '(overlay-whiteout)' -exec rm -rf {} \;

mount -t overlayfs -o rw,lowerdir=/tmp/mount/centos5.6-layer0-mount,upperdir=/tmp/test/layers/centos5.6-layer1-upper overlayfs /tmp/mount/centos5.6-layer1-mount
# remove deleted files into overlayfs
find /tmp/mount/centos5.6-layer1-mount -lname '(overlay-whiteout)' -exec rm -rf {} \;

mount -t overlayfs -o rw,lowerdir=/tmp/mount/centos5.6-layer1-mount,upperdir=/tmp/test/layers/centos5.6-layer2-upper overlayfs /tmp/mount/centos5.6-layer2-mount
mount: wrong fs type, bad option, bad superblock on overlayfs,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
# remove deleted files into overlayfs
find /tmp/mount/centos5.6-layer2-mount -lname '(overlay-whiteout)' -exec rm -rf {} \;

mount -t overlayfs -o rw,lowerdir=/tmp/mount/centos5.6-layer2-mount,upperdir=/tmp/test/layers/centos5.6-layer3-upper overlayfs /tmp/mount/centos5.6-layer3-mount
find /tmp/mount/centos5.6-layer3-mount -lname '(overlay-whiteout)' -exec rm -rf {} \;

如何提供超过2层?

1 个答案:

答案 0 :(得分:3)

如果你检查dmesg输出,你会看到内核说明试图超过最大堆叠深度:

overlayfs: maximum fs stacking depth exceeded

实际上,堆叠深度限制为2,请参阅overlayfs dev分支:

如果你想超越这个深度,你可以尝试更改常量并构建自己的内核。但是,请记住堆栈溢出的风险(根据评论)。