[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Multiple lower layers with union=overlay



Hi,

I believe the current git version stacks multiple overlay layers in the
wrong order. Overlay stacks layers from right to left. I.e. the
rightmost layer is the bottom level, the leftmost is the top level. See
https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt ,
"Multiple lower layers"

According to the live-boot man page, about filesystem.module:

"The first entry in this file will be the "lowest" point in the aufs,
and the last file  in  this list  will  be  on  the "top" of the aufs,
directly below /overlay."

This is opposite from how it works in overlay, and the order of layers
is not reversed for aufs, so I believe the order of the layers in the
mount command should be reversed. I have attached the patch I wrote for
the current version in unstable. It has been briefly tested.

Please CC me on replies as I'm not on the list.


Kind regards,

Linnea
--- root/9990-misc-helpers.sh.bak	2016-01-15 13:41:39.750812112 +0100
+++ lib/live/boot/9990-misc-helpers.sh	2016-01-15 15:32:43.694833121 +0100
@@ -1304,22 +1304,29 @@
 			;;
 
 		overlay)
-			# XXX: can multiple unionro be used? (overlay only handles two dirs, but perhaps they can be chained?)
-			# XXX: and can unionro be optional? i.e. can overlay skip lowerdir?
-			if echo ${unionro} | grep -q " "
-			then
-				panic "Multiple lower filesystems are currently not supported with overlay (unionro = ${unionro})."
-			elif [ -z "${unionro}"	]
+			# XXX: can unionro be optional? i.e. can overlay skip lowerdir?
+			if [ -z "${unionro}"	]
 			then
 				panic "overlay needs at least one lower filesystem (read-only branch)."
 			fi
+			lowerdir=
+			first=1
+			for rofs in ${unionro}
+			do
+				if [ $first = 1 ]; then
+					first=0
+					lowerdir="$rofs"
+				else
+					lowerdir="$rofs:$lowerdir"
+				fi
+			done
 			# overlayfs requires:
 			# + a workdir to become mounted
 			# + workdir and upperdir to reside under the same mount
 			# + workdir and upperdir to be in separate directories
 			mkdir "${unionrw}/rw"
 			mkdir "${unionrw}/work"
-			unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}/rw,workdir=${unionrw}/work"
+			unionmountopts="-o noatime,lowerdir=${lowerdir},upperdir=${unionrw}/rw,workdir=${unionrw}/work"
 			;;
 	esac
 

Reply to: