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

Bug#773868: Patch to support overlay



I modified live-boot to support overlay from Linux kernel >=3.18 a few
days ago, by referring to kiwi from OpenSuSE.
Attached please find the patch to support overlayfs for live-boot 4.
My 2 cents.

Steven.

-- 
Steven Shiau <steven _at_ stevenshiau org>
Public Key Server PGP Key ID: 4096R/47CF935C
Fingerprint: 0240 1FEB 695D 7112 62F0  8796 11C1 12DA 47CF 935C

--- a/components/9990-misc-helpers.sh
+++ b/components/9990-misc-helpers.sh
@@ -1322,7 +1322,7 @@
 			pidof unionfs-fuse >> /run/sendsigs.omit.d/unionfs-fuse || true )
 			;;
 
-		overlayfs)
+		overlayfs|overlay)
 			# XXX: can multiple unionro be used? (overlayfs only handles two dirs, but perhaps they can be chained?)
 			# XXX: and can unionro be optional? i.e. can overlayfs skip lowerdir?
 			if echo ${unionro} | grep -q " "
@@ -1333,7 +1333,18 @@
 				panic "Overlayfs needs at least one lower filesystem (read-only branch)."
 			fi
 			unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}"
-			mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
+			if ! mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" 2>/dev/null; then
+				# Ref: kiwi from OpenSuse kiwi-7.02.18-1.1
+				# overlayfs in version >= v22 behaves differently
+            			# + renamed from overlayfs to overlay
+            			# + requires a workdir to become mounted
+            			# + requires workdir and upperdir to reside under the same mount
+            			# + requires workdir and upperdir to be in separate subdirs
+				mkdir ${unionrw}/rw
+				mkdir ${unionrw}/work
+				unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}/rw,workdir=${unionrw}/work"
+				mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
+			fi
 			;;
 
 		*)
--- a/components/9990-overlay.sh
+++ b/components/9990-overlay.sh
@@ -9,7 +9,7 @@
 	addimage_directory="${3}"
 
 	case ${UNIONTYPE} in
-		aufs|unionfs|overlayfs)
+		aufs|unionfs|overlayfs|overlay)
 			modprobe -q -b ${UNIONTYPE}
 
 			if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]

Reply to: