Cleaning up comment to keep only the part that's relevant here.
[live-boot-grml.git] / components / 9990-misc-helpers.sh
index fcd2b07..c59e40e 100755 (executable)
@@ -1292,15 +1292,17 @@ do_union ()
                        rw_opt="rw"
                        ro_opt="rr+wh"
                        noxino_opt="noxino"
-                       ;;
 
-               *)
-                       rw_opt="rw"
-                       ro_opt="ro"
+                       unionmountopts="-o noatime,${noxino_opt},dirs=${unionrw}=${rw_opt}"
+                       if [ -n "${unionro}" ]
+                       then
+                               for rofs in ${unionro}
+                               do
+                                       unionmountopts="${unionmountopts}:${rofs}=${ro_opt}"
+                               done
+                       fi
                        ;;
-       esac
 
-       case "${UNIONTYPE}" in
                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?
@@ -1312,21 +1314,18 @@ do_union ()
                                panic "overlay needs at least one lower filesystem (read-only branch)."
                        fi
                        unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}"
-                       mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
-                       ;;
-
-               *)
-                       unionmountopts="-o noatime,${noxino_opt},dirs=${unionrw}=${rw_opt}"
-                       if [ -n "${unionro}" ]
-                       then
-                               for rofs in ${unionro}
-                               do
-                                       unionmountopts="${unionmountopts}:${rofs}=${ro_opt}"
-                               done
-                       fi
+                       # 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"
                        mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
                        ;;
        esac
+
+       mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
 }
 
 get_custom_mounts ()