X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive;h=9c747d5c4ab64456480082ac240c470220d2ef0c;hb=70366e34b42762b4c3e4e25b431fd62b14916a09;hp=b7fd4cee2ed8c9d22d63784d1f5f5dd68df2e08f;hpb=8bde092d4cf8f5d257b6aab0acbf43e31ae688ba;p=live-boot-grml.git diff --git a/scripts/live b/scripts/live index b7fd4ce..9c747d5 100755 --- a/scripts/live +++ b/scripts/live @@ -326,6 +326,15 @@ Arguments () export PERSISTENT ;; + persistent=*) + PERSISTENT="${ARGUMENT#persistent=}" + if [ -z "${PERSISTENT}" ] + then + PERSISTENT="Yes" + fi + export PERSISTENT + ;; + nopersistent) NOPERSISTENT="Yes" export NOPERSISTENT @@ -604,7 +613,7 @@ copy_live_to () if [ "${copytodev}" = "ram" ] then # copying to ram: - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) ) + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\ /dev/null 2>&1 RES=$? + if [ "${RES}" != "0" ] + then + log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\"" + fi cd "${OLDPWD}" fi - umount "${snapback}" + umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\"" if [ "${RES}" != "0" ] then log_warning_msg "Impossible to include the ${snapfile} Snapshot file" fi - else - dev=$(find_cow_device "${snap_label}") - if [ -b "${dev}" ] + elif [ -b "${snapdata}" ] + then + # Try to find if it could be a snapshot partition + dev="${snapdata}" + log_success_msg "found snapshot device on ${dev}" + if echo "${dev}" | grep -qs loop then - if echo "${dev}" | grep -qs loop - then - # strange things happens, user confused? - snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) - snapfile=$(basename ${snaploop}) - snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ') - else - snapdev="${dev}" - fi + # strange things happens, user confused? + snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) + snapfile=$(basename ${snaploop}) + snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts) + else + snapdev="${dev}" + fi - if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" + then + log_warning_msg "Impossible to include the ${snap_type} Snapshot" + return 1 + else + if [ -n "${snapfile}" ] then - log_warning_msg "Impossible to include the ${snap_label} Snapshot" - return 1 - else - if [ -n "${snapfile}" ] - then - # it was a loop device, user confused - umount ${snapdev} - fi + # it was a loop device, user confused + umount ${snapdev} fi - else - log_warning_msg "Impossible to include the ${snap_label} Snapshot" - return 1 fi + else + log_warning_msg "Impossible to include the ${snap_type} Snapshot" + return 1 fi echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt @@ -1108,7 +1142,30 @@ setup_unionfs () fi done + # search for label and files (this could be hugely optimized) cowprobe=$(find_cow_device "${root_persistence}") + if [ -b "${cowprobe}" ] + then + # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots + # makes sense to have both persistence for /cow and /home mounted, maybe also with + # snapshots to be sure to really store some e.g key config files, + # but not on the same media + blacklistdev="${cowprobe}" + PERSISTENCE_IS_ON="1" + export PERSISTENCE_IS_ON + fi + # homecow just mount something on /home, this should be generalized some way + homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}") + if [ -b "${homecow}" ] + then + PERSISTENCE_IS_ON="1" + export PERSISTENCE_IS_ON + fi + root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}") + # This second type should be removed when snapshot will get smarter, + # hence when "/etc/live-snapshot*list" will be supported also by + # ext2|ext3|jffs2 snapshot types. + home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}") if [ -b "${cowprobe}" ] then @@ -1197,7 +1254,6 @@ setup_unionfs () then # directly mount /home # FIXME: add a custom mounts configurable system - homecow=$(find_cow_device "${home_persistence}" ) if [ -b "${homecow}" ] then @@ -1208,8 +1264,9 @@ setup_unionfs () fi # Look for other snapshots to copy in - try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" - try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME" + try_snap "${root_snapdata}" "${rootmnt}" "ROOT" + # This second type should be removed when snapshot grow smarter + try_snap "${home_snapdata}" "${rootmnt}/home" "HOME" fi if [ -n "${SHOWMOUNTS}" ]