Adding upstream version 1.177.1.
[live-boot-grml.git] / scripts / live
index f79eaff..0fb6adf 100755 (executable)
@@ -762,16 +762,8 @@ do_netmount ()
 
        modprobe -q af_packet # For DHCP
 
-       if [ -x /sbin/udevadm ]
-       then
-               # lenny
-               udevadm trigger
-               udevadm settle
-       else
-               # etch
-               udevtrigger
-               udevsettle
-       fi
+       udevadm trigger
+       udevadm settle
 
        ipconfig ${DEVICE} | tee /netboot.config
 
@@ -1094,7 +1086,25 @@ setup_unionfs ()
        image_directory="${1}"
        rootmnt="${2}"
         addimage_directory="${3}"
-       modprobe -q -b ${UNIONTYPE}
+
+       case ${UNIONTYPE} in
+               aufs|unionfs)
+                       modprobe -q -b ${UNIONTYPE}
+
+                       if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
+                       then
+                               echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
+                               echo "This might be really slow."
+
+                               UNIONTYPE="unionfs-fuse"
+                       fi
+                       ;;
+       esac
+
+       if [ "${UNIONTYPE}" = unionfs-fuse ]
+       then
+               modprobe fuse
+       fi
 
        # run-init can't deal with images in a subdir, but we're going to
        # move all of these away before it runs anyway.  No, we're not,
@@ -1110,6 +1120,9 @@ setup_unionfs ()
        if [ "${UNIONTYPE}" = "aufs" ]
        then
                roopt="rr,noxino"
+       elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
+       then
+               roopt="RO"
        else
                roopt="ro"
        fi
@@ -1232,16 +1245,8 @@ setup_unionfs ()
                                modprobe -q -b ${module}
                        done
 
-                       if [ -x /sbin/udevadm ]
-                       then
-                               # lenny
-                               udevadm trigger
-                               udevadm settle
-                       else
-                               # etch
-                               udevtrigger
-                               udevsettle
-                       fi
+                       udevadm trigger
+                       udevadm settle
 
                        # For some reason, udevsettle does not block in this scenario,
                        # so we sleep for a little while.
@@ -1357,16 +1362,27 @@ setup_unionfs ()
 
                for dir in ${cow_dirs}; do
                        mkdir -p /cow${dir}
-                       mount -t ${UNIONTYPE} \
-                               -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
-                               ${UNIONTYPE} "${rootmnt}${dir}" || \
-                               panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
-                                       rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
+
+                       case "${UNIONTYPE}" in
+                               unionfs-fuse)
+                                       (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${exposedrootfs}${dir} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow=RW:${exposedrootfs}${dir}")
+                                       ;;
+
+                               *)
+                                       mount -t ${UNIONTYPE} -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro ${UNIONTYPE} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
+                                       ;;
+                       esac
                done
        else
-               mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
-                       ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
-                       ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
+               case "${UNIONTYPE}" in
+                       unionfs-fuse)
+                               (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${rofsstring} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow:RW:${rofsstring}")
+                               ;;
+
+                       *)
+                               mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
+                               ;;
+               esac
        fi
 
        # Correct the permissions of /:
@@ -1409,7 +1425,15 @@ setup_unionfs ()
                                        ;;
 
                                *)
-                                       mount -o move "${d}" "${rootmnt}/live/${d##*/}"
+                                       case "${UNIONTYPE}" in
+                                               unionfs-fuse)
+                                                       mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
+                                                       ;;
+
+                                               *)
+                                                       mount -o move "${d}" "${rootmnt}/live/${d##*/}"
+                                                       ;;
+                                       esac
                                        ;;
                        esac
                done
@@ -1730,12 +1754,24 @@ mountroot ()
 
        log_end_msg
 
+       # unionfs-fuse needs /dev to be bind-mounted for the duration of
+       # live-bottom; udev's init script will take care of things after that
+       if [ "${UNIONTYPE}" = unionfs-fuse ]
+       then
+               mount -n -o bind /dev "${rootmnt}/dev"
+       fi
+
        maybe_break live-bottom
        log_begin_msg "Running /scripts/live-bottom\n"
 
        run_scripts /scripts/live-bottom
        log_end_msg
 
+       if [ "${UNIONFS}" = unionfs-fuse ]
+       then
+               umount "${rootmnt}/dev"
+       fi
+
        exec 1>&6 6>&-
        exec 2>&7 7>&-
        kill ${tailpid}