Enable support for Multi-Layered rootfs when overlayfs is in use This script last worked with Ubuntu 14.04 trusty where aufs was the default. After that, Ubuntu changed to overlayfs which didn't support multiple layers in the early versions. Since ??? (at least Ubuntu 15.10 wily), overlayfs now supports multiple lowerdir's separated by colons. This patch re-enables multiple squashfs layers. Tested with casper 1.365 Documentation of overlayfs: * https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt Signed-off-by: Daniel Alder --- chroot/usr/share/initramfs-tools/scripts/casper_orig 2016-03-23 16:58:39.821410256 +0100 +++ chroot/usr/share/initramfs-tools/scripts/casper 2016-03-23 17:06:30.237655915 +0100 @@ -519,26 +519,14 @@ mount -t ${UNIONFS} -o noatime,dirs=/cow/upper=rw:$rofsstring ${UNIONFS} "$rootmnt" || panic "${UNIONFS} mount failed" ;; overlay|overlayfs) - # Mount the layers pairwise from the bottom onto rootmnt, - # for the second and later layers rootmnt forms the lower layer. - mounts="" - for mount in /cow $rofslist + rofsstring="" + for mount in $rofslist do - mounts="$mount $mounts" - done - lower="" - for mount in $mounts - do - if [ "$lower" = "" ]; then - lower="$mount" - continue - fi - mount -t ${UNIONFS} -o "upperdir=$mount/upper,lowerdir=$lower,workdir=$mount/work" \ - "$mount" "$rootmnt" || \ - mount -t ${UNIONFS} -o "upperdir=$mount/upper,lowerdir=$lower" \ - "$mount" "$rootmnt" - lower="$rootmnt" + rofsstring="$rofsstring:$mount" done + rofsstring=${rofsstring#:} + + mount -t ${UNIONFS} -o noatime,lowerdir=$rofsstring,upperdir=/cow/upper,workdir=/cow/work ${UNIONFS} "$rootmnt" || panic "${UNIONFS} mount failed" ;; esac