- image_directory="$1"
- rootmnt="$2"
-
- modprobe -qb unionfs
-
- croot="" # Should really be /casper, but run-init doesn't handle
- # mount-points in subdirectories at all
-
- # Let's just mount the read-only file systems first
- rofsstring=""
- rofslist=""
- if [ ${NETBOOT} == "nfs" ] ; then
- roopt="nfsro" # go aroung a bug in nfs-unionfs locking
- else
- roopt="ro"
- fi
-
- mkdir -p "${croot}"
- for image_type in "ext2" "squashfs" "dir" ; do
- for image in "${image_directory}"/*."${image_type}"; do
- imagename=$(basename "${image}")
- if [ -d "${image}" ]; then
- # it is a plain directory: do nothing
- rofsstring="${image}=${roopt}:${rofsstring}"
- rofslist="${image} ${rofslist}"
- elif [ -f "${image}" ]; then
- backdev=$(get_backing_device "$image")
- fstype=$(get_fstype "${backdev}")
- if [ "${fstype}" = "unknown" ]; then
- panic "Unknown file system type on ${backdev} (${image})"
- fi
- mkdir -p "${croot}/${imagename}"
- mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
- fi
- done
- done
- rofsstring=${rofsstring%:}
-
- mkdir -p /cow
- cowdevice="tmpfs"
- cow_fstype="tmpfs"
-
- # Looking for "${root_persistence}" device or file
- if [ ! -z "${PERSISTENT}" ]; then
- cowprobe=$(find_cow_device "${root_persistence}")
- if [ -b "${cowprobe}" ]; then
- cowdevice=${cowprobe}
- cow_fstype=$(get_fstype "${cowprobe}")
- else
- [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent medium"
- fi
- fi
-
- mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow"
-
- mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed"
-
- for d in ${rofslist}; do
- mkdir -p "${rootmnt}/casper/${d}"
- mount -o bind "${d}" "${rootmnt}/casper/${d}"
- case d in
- *.dir) ;; # do nothing
- *) umount "${d}" ;;
- esac
- done
-
- # Adding other custom mounts
- if [ ! -z "${PERSISTENT}" ]; then
- homecow=$(find_cow_device "${home_persistence}" )
- if [ -b "${homecow}" ]; then
- mount ${homecow} -t $(get_fstype "${homecow}") -o rw "${rootmnt}/home"
- else
- [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent home medium"
- fi
- fi
-
- if [ ! -z "${SHOWCOW}" ]; then
- mkdir -p "$rootmnt/cow"
- mount -o bind /cow "$rootmnt/cow"
- fi
+ image_directory="$1"
+ rootmnt="$2"
+
+ modprobe -qb unionfs
+
+ # run-init can't deal with this, but we're going to move all of these
+ # away before it runs anyway.
+ croot="/casper"
+
+ # Let's just mount the read-only file systems first
+ rofsstring=""
+ rofslist=""
+ if [ "${NETBOOT}" == "nfs" ] ; then
+ roopt="nfsro" # go aroung a bug in nfs-unionfs locking
+ else
+ roopt="ro"
+ fi
+
+ mkdir -p "${croot}"
+ for image_type in "ext2" "squashfs" "dir" ; do
+ for image in "${image_directory}"/*."${image_type}"; do
+ imagename=$(basename "${image}")
+ if [ -d "${image}" ]; then
+ # it is a plain directory: do nothing
+ rofsstring="${image}=${roopt}:${rofsstring}"
+ rofslist="${image} ${rofslist}"
+ elif [ -f "${image}" ]; then
+ backdev=$(get_backing_device "$image")
+ fstype=$(get_fstype "${backdev}")
+ if [ "${fstype}" = "unknown" ]; then
+ panic "Unknown file system type on ${backdev} (${image})"
+ fi
+ mkdir -p "${croot}/${imagename}"
+ mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
+ fi
+ done
+ done
+ rofsstring=${rofsstring%:}
+
+ mkdir -p /cow
+ cowdevice="tmpfs"
+ cow_fstype="tmpfs"
+
+ # Looking for "${root_persistence}" device or file
+ if [ ! -z "${PERSISTENT}" ]; then
+ cowprobe=$(find_cow_device "${root_persistence}")
+ if [ -b "${cowprobe}" ]; then
+ cowdevice=${cowprobe}
+ cow_fstype=$(get_fstype "${cowprobe}")
+ else
+ [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent medium"
+ fi
+ fi
+
+ mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow"
+
+ mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed"
+
+ for d in ${rofslist}; do
+ mkdir -p "${rootmnt}/casper/${d##*/}"
+ case d in
+ *.dir) mount -o bind "${d}" "${rootmnt}/casper/${d##*/}" ;;
+ *) mount -o move "${d}" "${rootmnt}/casper/${d##*/}" ;;
+ esac
+ done
+
+ # Adding other custom mounts
+ if [ ! -z "${PERSISTENT}" ]; then
+ homecow=$(find_cow_device "${home_persistence}" )
+ if [ -b "${homecow}" ]; then
+ mount ${homecow} -t $(get_fstype "${homecow}") -o rw "${rootmnt}/home"
+ else
+ [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent home medium"
+ fi
+ fi
+
+ if [ ! -z "${SHOWCOW}" ]; then
+ mkdir -p "$rootmnt/cow"
+ mount -o bind /cow "$rootmnt/cow"
+ fi