X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive-helpers;h=3ec1e7b215877f66eb1b64c5763ea6e8afd0abe2;hb=13bb5656427cd5ad5475ceb48fe973c2f3b41f8c;hp=aacfe93afffa892428b3c0131de00488f4190d81;hpb=56627dfef6afd7f94f0bd8d76122eefb0b115826;p=live-boot-grml.git diff --git a/scripts/live-helpers b/scripts/live-helpers index aacfe93..3ec1e7b 100644 --- a/scripts/live-helpers +++ b/scripts/live-helpers @@ -608,3 +608,53 @@ link_files () fi done } + +do_union () { + root_backing="${1}" + unionrw="${2}" + unionro="${3}" + unionmountpoint="${4}" + + if [ "${UNIONTYPE}" = "aufs" ] + then + rw_opt="rw" + ro_opt="rr+wh" + noxino_opt="noxino," + elif [ "${UNIONTYPE}" = "unionfs-fuse" ] + then + rw_opt="RW" + ro_opt="RO" + else + rw_opt="rw" + ro_opt="ro" + fi + + case "${UNIONTYPE}" in + unionfs-fuse) + # FIXME: handle PERSISTENT_READONLY + unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid" + unionmountopts="${unionmountopts} ${unionrw}=${rw_opt}:${unionro}=${ro_opt}" + ( sysctl -w fs.file-max=391524 ; ulimit -HSn 16384 + unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \ + ( mkdir -p /run/sendsigs.omit.d + pidof unionfs-fuse >> /run/sendsigs.omit.d/unionfs-fuse || true ) + ;; + + overlayfs) + # FIXME: is PERSISTENT_READONLY possible? (overlayfs only handles two dirs, but perhaps they can be chained?) + unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}" + mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" + ;; + + *) + if [ -n "${PERSISTENT_READONLY}" ] + then + mount -t tmpfs -o rw,noatime,mode=755 tmpfs "${unionrw}" + unionmountopts="-o noatime,${noxino_opt}dirs=${unionrw}=${rw_opt}:${root_backing}=${ro_opt}:${unionro}=${ro_opt}" + else + unionmountopts="-o noatime,${noxino_opt}dirs=${unionrw}=${rw_opt}:${unionro}=${ro_opt}" + fi + mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" + ;; + esac +}