我尝试将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层的数据?

最佳答案

如果检查dmesg输出,您将看到内核指出尝试超过最大堆栈深度的尝试:

overlayfs: maximum fs stacking depth exceeded

实际上,堆栈深度限制为2,请参见overlayfs dev分支:
  • #define FILESYSTEM_MAX_STACK_DEPTH
  • stacking depth check

  • 如果要超出此深度,可以尝试更改常量并构建自己的内核。但是,请记住(根据注释)堆栈溢出的风险。

    关于linux - 如何提供overlayfs的嵌套安装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25910229/

    10-11 06:37