- image_string="`echo ${image_string} | sed -e 's/ /\n/g' | sort `"
- fi
-
- mkdir -p "${croot}"
- for image in ${image_string}; 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
- rofsstring=${rofsstring%:}
-
- mkdir -p /cow
- cowdevice="tmpfs"
- cow_fstype="tmpfs"
-
- # Looking for "${root_persistence}" device or file
- if [ -n "${PERSISTENT}" ]; then
- cowprobe=$(find_cow_device "${root_persistence}")
- if [ -b "${cowprobe}" ]; then
- cowdevice=${cowprobe}
- cow_fstype=$(get_fstype "${cowprobe}")
- else
- [ "$quiet" != "y" ] && log_warning_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 ${UNIONTYPE} -o dirs=/cow=rw:$rofsstring ${UNIONTYPE} "$rootmnt" || panic "${UNIONTYPE} mount failed"
-
- # Adding other custom mounts
- if [ -n "${PERSISTENT}" ]; then
- # directly mount /home
- # FIXME: add a custom mounts configurable system
- homecow=$(find_cow_device "${home_persistence}" )
- if [ -b "${homecow}" ]; then
- mount -t $(get_fstype "${homecow}") -o rw "${homecow}" "${rootmnt}/home"
- export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
- else
- [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium"
- fi
- # Look for other snapshots to copy in
- try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT"
- try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME"
- fi
-
- if [ -n "${SHOWMOUNTS}" ]; then
- for d in ${rofslist}; do
- mkdir -p "${rootmnt}/live/${d##*/}"
- case d in
- *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
- ;;
- *) mount --move "${d}" "${rootmnt}/live/${d##*/}"
- ;;
- esac
- done
- fi
-
- # shows cow fs on /cow for use by live-snapshot
- mkdir -p "${rootmnt}/live/cow"
- mount -o bind /cow "${rootmnt}/live/cow"
+ image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
+ fi
+
+ [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
+
+ mkdir -p "${croot}"
+
+ for image in ${image_string}
+ 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
+ if losetup --help 2>&1 | grep -q -- "-r\b"
+ then
+ backdev=$(get_backing_device "${image}" "-r")
+ else
+ backdev=$(get_backing_device "${image}")
+ fi
+ fstype=$(get_fstype "${backdev}")
+
+ if [ "${fstype}" = "unknown" ]
+ then
+ panic "Unknown file system type on ${backdev} (${image})"
+ fi
+
+ if [ -z "${fstype}" ]
+ then
+ fstype="${imagename##*.}"
+ log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
+ fi
+
+ mkdir -p "${croot}/${imagename}"
+ log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
+ mount -t "${fstype}" -o ro,noatime "${backdev}" "${croot}/${imagename}" || panic "Can not mount ${backdev} (${image}) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
+ log_end_msg
+ fi
+ done
+
+ rofsstring=${rofsstring%:}
+
+ mkdir -p /cow
+
+ # Looking for "${root_persistence}" device or file
+ if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
+ then
+ # Load USB modules
+ num_block=$(ls -l /sys/block | wc -l)
+ for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
+ do
+ modprobe -q -b ${module}
+ done
+
+ if [ -x /sbin/udevadm ]
+ then
+ # lenny
+ udevadm trigger
+ udevadm settle
+ else
+ # etch
+ udevtrigger
+ udevsettle
+ fi
+
+ # For some reason, udevsettle does not block in this scenario,
+ # so we sleep for a little while.
+ #
+ # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
+ for timeout in 5 4 3 2 1
+ do
+ sleep 1
+
+ if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
+ then
+ break
+ fi
+ done
+
+ cowprobe=$(find_cow_device "${root_persistence}")
+
+ if [ -b "${cowprobe}" ]
+ then
+ cowdevice=${cowprobe}
+ cow_fstype=$(get_fstype "${cowprobe}")
+ cow_mountopt="rw,noatime"
+ else
+ log_warning_msg "Unable to find the persistent medium"
+ cowdevice="tmpfs"
+ cow_fstype="tmpfs"
+ cow_mountopt="rw,noatime,mode=755"
+ fi
+ elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
+ then
+ # check if there are any nfs options
+ if echo ${NFS_COW}|grep -q ','
+ then
+ nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
+ nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
+ else
+ nfs_cow_opts="-o nolock"
+ nfs_cow=${NFS_COW}
+ fi
+ mac="$(get_mac)"
+ if [ -n "${mac}" ]
+ then
+ cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
+ cow_fstype="nfs"
+ else
+ panic "unable to determine mac address"
+ fi
+ else
+ cowdevice="tmpfs"
+ cow_fstype="tmpfs"
+ cow_mountopt="rw,noatime,mode=755"
+ fi
+
+ if [ "${cow_fstype}" = "nfs" ]
+ then
+ log_begin_msg \
+ "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
+ nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
+ panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
+ else
+ mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
+ panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
+ fi
+
+ rofscount=$(echo ${rofslist} |wc -w)
+
+ if [ -n "${EXPOSED_ROOT}" ]
+ then
+ if [ ${rofscount} -ne 1 ]
+ then
+ panic "only one RO file system supported with exposedroot: ${rofslist}"
+ fi
+ exposedrootfs=${rofslist%% }
+
+ mount --bind ${exposedrootfs} ${rootmnt} || \
+ panic "bind mount of ${exposedrootfs} failed"
+
+ cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
+ /home /var/lib/live'
+
+ 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"
+ 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}"
+ fi
+
+ # tmpfs file systems
+ touch /etc/fstab
+ mkdir -p "${rootmnt}/live"
+ mount -t tmpfs tmpfs ${rootmnt}/live
+
+ # Adding other custom mounts
+ if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
+ then
+ # directly mount /home
+ # FIXME: add a custom mounts configurable system
+ homecow=$(find_cow_device "${home_persistence}" )
+
+ if [ -b "${homecow}" ]
+ then
+ mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
+ export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
+ else
+ log_warning_msg "Unable to find the persistent home medium"
+ fi
+
+ # Look for other snapshots to copy in
+ try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT"
+ try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME"
+ fi
+
+ if [ -n "${SHOWMOUNTS}" ]
+ then
+ for d in ${rofslist}
+ do
+ mkdir -p "${rootmnt}/live/${d##*/}"
+
+ case d in
+ *.dir)
+ # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
+ ;;
+
+ *)
+ mount -o move "${d}" "${rootmnt}/live/${d##*/}"
+ ;;
+ esac
+ done
+ fi
+
+ # shows cow fs on /cow for use by live-snapshot
+ mkdir -p "${rootmnt}/live/cow"
+ mount -o move /cow "${rootmnt}/live/cow" >/dev/null 2>&1 || mount -o bind /cow "${rootmnt}/live/cow" || log_warning_msg "Unable to move or bind /cow to ${rootmnt}/live/cow"