summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2012-06-06 18:29:07 +0200
committerDaniel Baumann <daniel@debian.org>2012-06-06 18:43:56 +0200
commite243babf191d5b42efe58e90e74a22bd8063be8d (patch)
treed29c3630f8235f98395450b4b3c499580b1f625e /scripts
parentf04ab476c668ad513f1ec68beaa948a26c862e05 (diff)
downloadlive-boot-e243babf191d5b42efe58e90e74a22bd8063be8d.tar.gz
live-boot-e243babf191d5b42efe58e90e74a22bd8063be8d.zip
Dropping snapshot functionality, superseeded by awesome custom mount persistence.
See the following threads for more information: * http://lists.debian.org/debian-live/2012/04/msg00110.html * http://lists.debian.org/debian-live/2012/06/msg00039.html
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/boot.sh3
-rwxr-xr-xscripts/boot/cmdline.sh5
-rwxr-xr-xscripts/boot/misc-helpers.sh43
-rwxr-xr-xscripts/boot/mountroot.sh13
-rwxr-xr-xscripts/boot/overlay.sh31
-rwxr-xr-xscripts/boot/persistence-excludes.sh62
-rwxr-xr-xscripts/boot/snapshot.sh173
7 files changed, 15 insertions, 315 deletions
diff --git a/scripts/boot.sh b/scripts/boot.sh
index 2809f42..e8b7626 100755
--- a/scripts/boot.sh
+++ b/scripts/boot.sh
@@ -59,9 +59,6 @@ fi
old_root_overlay_label="live-rw"
old_home_overlay_label="home-rw"
custom_overlay_label="custom-ov"
-root_snapshot_label="live-sn"
-old_root_snapshot_label="live-sn"
-home_snapshot_label="home-sn"
persistence_list="live-persistence.conf"
if [ ! -f /live.vars ]
diff --git a/scripts/boot/cmdline.sh b/scripts/boot/cmdline.sh
index 296d1f7..669f5bc 100755
--- a/scripts/boot/cmdline.sh
+++ b/scripts/boot/cmdline.sh
@@ -210,9 +210,6 @@ Cmdline ()
old_root_overlay_label="${old_root_overlay_label}-${_PARAMETER#persistence-subtext=}"
old_home_overlay_label="${old_home_overlay_label}-${_PARAMETER#persistence-subtext=}"
custom_overlay_label="${custom_overlay_label}-${_PARAMETER#persistence-subtext=}"
- root_snapshot_label="${root_snapshot_label}-${_PARAMETER#persistence-subtext=}"
- old_root_snapshot_label="${root_snapshot_label}-${_PARAMETER#persistence-subtext=}"
- home_snapshot_label="${home_snapshot_label}-${_PARAMETER#persistence-subtext=}"
;;
nopersistence)
@@ -337,7 +334,7 @@ Cmdline ()
if [ -z "${PERSISTENCE_METHOD}" ]
then
- PERSISTENCE_METHOD="snapshot,overlay"
+ PERSISTENCE_METHOD="overlay"
export PERSISTENCE_METHOD
fi
diff --git a/scripts/boot/misc-helpers.sh b/scripts/boot/misc-helpers.sh
index 8970327..241bba1 100755
--- a/scripts/boot/misc-helpers.sh
+++ b/scripts/boot/misc-helpers.sh
@@ -842,8 +842,7 @@ is_gpt_device ()
probe_for_gpt_name ()
{
local overlays="${1}"
- local snapshots="${2}"
- local dev="${3}"
+ local dev="${2}"
local gpt_dev="${dev}"
if is_active_luks_mapping ${dev}
@@ -859,7 +858,7 @@ probe_for_gpt_name ()
fi
local gpt_name=$(get_gpt_name ${gpt_dev})
- for label in ${overlays} ${snapshots}
+ for label in ${overlays}
do
if [ "${gpt_name}" = "${label}" ]
then
@@ -871,10 +870,9 @@ probe_for_gpt_name ()
probe_for_fs_label ()
{
local overlays="${1}"
- local snapshots="${2}"
- local dev="${3}"
+ local dev="${2}"
- for label in ${overlays} ${snapshots}
+ for label in ${overlays}
do
if [ "$(/sbin/blkid -s LABEL -o value $dev 2>/dev/null)" = "${label}" ]
then
@@ -886,8 +884,7 @@ probe_for_fs_label ()
probe_for_file_name ()
{
local overlays="${1}"
- local snapshots="${2}"
- local dev="${3}"
+ local dev="${2}"
local ret=""
local backing="$(mount_persistence_media ${dev} probe)"
@@ -905,17 +902,6 @@ probe_for_file_name ()
ret="${ret} ${label}=${loopdev}"
fi
done
- for label in ${snapshots}
- do
- for ext in squashfs cpio.gz ext2 ext3 ext4 jffs2
- do
- path="${PERSISTENCE_PATH}${label}.${ext}"
- if [ -f "${backing}/${path}" ]
- then
- ret="${ret} ${label}=${dev}:${backing}:${path}"
- fi
- done
- done
if [ -n "${ret}" ]
then
@@ -927,19 +913,15 @@ probe_for_file_name ()
find_persistence_media ()
{
- # Scans devices for overlays and snapshots, and returns a whitespace
+ # Scans devices for overlays, and returns a whitespace
# separated list of how to use them. Only overlays with a partition
- # label or file name in ${overlays} are returned, and ditto for
- # snapshots with labels in ${snapshots}.
+ # label or file name in ${overlays} are returned.
#
# When scanning a LUKS device, the user will be asked to enter the
# passphrase; on failure to enter it, or if no persistence partitions
# or files were found, the LUKS device is closed.
#
- # For a snapshot file the return value is ${label}=${snapdata}", where
- # ${snapdata} is the parameter used for try_snap().
- #
- # For all other cases (overlay/snapshot partition and overlay file) the
+ # For all other cases (overlay partition and overlay file) the
# return value is "${label}=${device}", where ${device} a device that
# can mount the content. In the case of an overlay file, the device
# containing the file will remain mounted as a side-effect.
@@ -949,8 +931,7 @@ find_persistence_media ()
# scanned.
local overlays="${1}"
- local snapshots="${2}"
- local white_listed_devices="${3}"
+ local white_listed_devices="${2}"
local ret=""
local black_listed_devices="$(what_is_mounted_on /live/image)"
@@ -983,14 +964,14 @@ find_persistence_media ()
# Probe for matching GPT partition names or filesystem labels
if is_in_comma_sep_list filesystem ${PERSISTENCE_STORAGE}
then
- result=$(probe_for_gpt_name "${overlays}" "${snapshots}" ${dev})
+ result=$(probe_for_gpt_name "${overlays}" ${dev})
if [ -n "${result}" ]
then
ret="${ret} ${result}"
continue
fi
- result=$(probe_for_fs_label "${overlays}" "${snapshots}" ${dev})
+ result=$(probe_for_fs_label "${overlays}" ${dev})
if [ -n "${result}" ]
then
ret="${ret} ${result}"
@@ -1001,7 +982,7 @@ find_persistence_media ()
# Probe for files with matching name on mounted partition
if is_in_comma_sep_list file ${PERSISTENCE_STORAGE}
then
- result=$(probe_for_file_name "${overlays}" "${snapshots}" ${dev})
+ result=$(probe_for_file_name "${overlays}" ${dev})
if [ -n "${result}" ]
then
ret="${ret} ${result}"
diff --git a/scripts/boot/mountroot.sh b/scripts/boot/mountroot.sh
index bad0a78..dbc66d4 100755
--- a/scripts/boot/mountroot.sh
+++ b/scripts/boot/mountroot.sh
@@ -184,18 +184,6 @@ mountroot ()
fi
fi
- # copy snapshot configuration if exists
- if [ -f snapshot.conf ]
- then
- log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d"
- if [ ! -d "${rootmnt}/etc/live/boot.d" ]
- then
- mkdir -p "${rootmnt}/etc/live/boot.d"
- fi
- cp snapshot.conf "${rootmnt}/etc/live/boot.d/"
- log_end_msg
- fi
-
if [ -f /etc/resolv.conf ] && [ ! -s ${rootmnt}/etc/resolv.conf ]
then
log_begin_msg "Copying /etc/resolv.conf to ${rootmnt}/etc/resolv.conf"
@@ -208,7 +196,6 @@ mountroot ()
panic "A wrong rootfs was mounted."
fi
- persistence_exclude
fstab
Netbase
diff --git a/scripts/boot/overlay.sh b/scripts/boot/overlay.sh
index 17a47e1..7b79df6 100755
--- a/scripts/boot/overlay.sh
+++ b/scripts/boot/overlay.sh
@@ -202,33 +202,11 @@ setup_unionfs ()
overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label}"
fi
- if is_in_comma_sep_list snapshot ${PERSISTENCE_METHOD}
- then
- snapshots="${root_snapshot_label} ${home_snapshot_label}"
- fi
-
- local root_snapdata=""
- local home_snapdata=""
local overlay_devices=""
- for media in $(find_persistence_media "${overlays}" "${snapshots}" "${whitelistdev}")
+ for media in $(find_persistence_media "${overlays}" "${whitelistdev}")
do
media="$(echo ${media} | tr ":" " ")"
case ${media} in
- ${root_snapshot_label}=*|${old_root_snapshot_label}=*)
- if [ -z "${root_snapdata}" ]
- then
- root_snapdata="${media#*=}"
- fi
- ;;
- ${home_snapshot_label}=*)
- # This second type should be removed when snapshot will get smarter,
- # hence when "/etc/live-snapshot*list" will be supported also by
- # ext2|ext3|ext4|jffs2 snapshot types.
- if [ -z "${home_snapdata}" ]
- then
- home_snapdata="${media#*=}"
- fi
- ;;
${old_root_overlay_label}=*)
device="${media#*=}"
fix_backwards_compatibility ${device} / union
@@ -409,17 +387,12 @@ setup_unionfs ()
close_persistence_media ${overlay}
fi
done
-
- # Look for other snapshots to copy in
- [ -n "${root_snapdata}" ] && try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
- # This second type should be removed when snapshot grow smarter
- [ -n "${home_snapdata}" ] && try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home"
fi
mkdir -p "${rootmnt}/live"
mount -o move /live "${rootmnt}/live" >/dev/null 2>&1 || mount -o bind /live "${rootmnt}/live" || log_warning_msg "Unable to move or bind /live to ${rootmnt}/live"
- # shows cow fs on /overlay for use by live-snapshot
+ # shows cow fs on /overlay (FIXME: do we still need/want this? probably yes)
mkdir -p "${rootmnt}/live/overlay"
mount -o move /live/overlay "${rootmnt}/live/overlay" >/dev/null 2>&1 || mount -o bind /overlay "${rootmnt}/live/overlay" || log_warning_msg "Unable to move or bind /overlay to ${rootmnt}/live/overlay"
diff --git a/scripts/boot/persistence-excludes.sh b/scripts/boot/persistence-excludes.sh
deleted file mode 100755
index ee9521e..0000000
--- a/scripts/boot/persistence-excludes.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/sh
-
-#set -e
-
-persistence_exclude ()
-{
- # Persistence enhancer script
- # This script saves precious time on slow persistence devices/image files
- # and writes on flash based device.
- # a tmpfs on $PERSTMP is mounted and directories listed in
- # /etc/live-persistence.binds will be copied there and then bind mounted back.
-
- if [ -z "${PERSISTENCE}" ] || [ -n "${NOPERSISTENCE}" ] || [ -z "${PERSISTENCE_IS_ON}" ] || [ ! -f /root/etc/live-persistence.binds ]
- then
- return
- fi
-
- # FIXME: stop hardcoding overloading of initramfs-tools functions
- . /scripts/functions
- . /lib/live/boot/initramfs-tools.sh
-
- dirs="$(sed -e '/^ *$/d' -e '/^#.*$/d' /root/etc/live-persistence.binds | tr '\n' '\0')"
- if [ -z "${dirs}" ]
- then
- return
- fi
-
- log_begin_msg "Moving persistence bind mounts"
-
- PERSTMP="/root/live/persistence-binds"
- CPIO="/bin/cpio"
-
- if [ ! -d "${PERSTMP}" ]
- then
- mkdir -p "${PERSTMP}"
- fi
-
- mount -t tmpfs tmpfs "${PERSTMP}"
-
- for dir in $(echo "${dirs}" | tr '\0' '\n')
- do
- if [ ! -e "/root/${dir}" ] && [ ! -L "/root/${dir}" ]
- then
- # directory do not exists, create it
- mkdir -p "/root/${dir}"
- elif [ ! -d "/root/${dir}" ]
- then
- # it is not a directory, skip it
- break
- fi
-
- # Copy previous content if any
- cd "/root/${dir}"
- find . -print0 | ${CPIO} -pumd0 "${PERSTMP}/${dir}"
- cd "${OLDPWD}"
-
- # Bind mount it to origin
- mount -o bind "${PERSTMP}/${dir}" "/root/${dir}"
- done
-
- log_end_msg
-}
diff --git a/scripts/boot/snapshot.sh b/scripts/boot/snapshot.sh
deleted file mode 100755
index 568fda7..0000000
--- a/scripts/boot/snapshot.sh
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/bin/sh
-
-#set -e
-
-do_snap_copy ()
-{
- fromdev="${1}"
- todir="${2}"
- snap_type="${3}"
- size=$(fs_size "${fromdev}" "" "used")
-
- if [ -b "${fromdev}" ]
- then
- log_success_msg "Copying snapshot ${fromdev} to ${todir}..."
-
- # look for free mem
- if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
- then
- todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
- freespace=$(df -k | awk '/'${todev}'/{print $4}')
- else
- freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
- fi
-
- tomount="/mnt/tmpsnap"
-
- if [ ! -d "${tomount}" ]
- then
- mkdir -p "${tomount}"
- fi
-
- fstype=$(get_fstype "${fromdev}")
-
- if [ -n "${fstype}" ]
- then
- # Copying stuff...
- mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
- cp -a "${tomount}"/* ${todir}
- umount "${tomount}"
- else
- log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
- fi
-
- rmdir "${tomount}"
-
- if echo ${fromdev} | grep -qs loop
- then
- losetup -d "${fromdev}"
- fi
-
- return 0
- else
- log_warning_msg "Unable to find the snapshot ${snap_type} medium"
- return 1
- fi
-}
-
-try_snap ()
-{
- # copy the contents of previously found snapshot to ${snap_mount}
- # and remember the device and filename for resync on exit in live-boot.init
-
- snapdata="${1}"
- snap_mount="${2}"
- snap_type="${3}"
- snap_relpath="${4}"
-
- if [ -z "${snap_relpath}" ]
- then
- # root snapshot, default usage
- snap_relpath="/"
- else
- # relative snapshot (actually used just for "/home" snapshots)
- snap_mount="${2}${snap_relpath}"
- fi
-
- if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
- then
- log_success_msg "found snapshot: ${snapdata}"
- snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
- snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
- snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
-
- if ! try_mount "${snapdev}" "${snapback}" "ro"
- then
- break
- fi
-
- RES="0"
-
- if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
- then
- # squashfs, jffs2 or ext2/ext3/ext4 snapshot
- dev=$(get_backing_device "${snapback}/${snapfile}")
-
- do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
- RES="$?"
- else
- # cpio.gz snapshot
-
- # Unfortunately klibc's cpio is incompatible with the
- # rest of the world; everything else requires -u -d,
- # while klibc doesn't implement them. Try to detect
- # whether it's in use.
- cpiopath="$(which cpio)" || true
- if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
- then
- cpioargs=
- else
- cpioargs='--unconditional --make-directories'
- fi
-
- if [ -s "${snapback}/${snapfile}" ]
- then
- BEFOREDIR="$(pwd)"
- cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null
- RES="$?"
- cd "${BEFOREDIR}"
- else
- log_warning_msg "${snapback}/${snapfile} is empty, adding it for sync on reboot."
- RES="0"
- fi
-
- if [ "${RES}" != "0" ]
- then
- log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
- fi
- fi
-
- umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
-
- if [ "${RES}" != "0" ]
- then
- log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
- fi
-
- elif [ -b "${snapdata}" ]
- then
- # Try to find if it could be a snapshot partition
- dev="${snapdata}"
- log_success_msg "found snapshot ${snap_type} device on ${dev}"
- if echo "${dev}" | grep -qs loop
- then
- # 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}"
- then
- log_warning_msg "Impossible to include the ${snap_type} Snapshot (i)"
- return 1
- else
- if [ -n "${snapfile}" ]
- then
- # it was a loop device, user confused
- umount ${snapdev}
- fi
- fi
- else
- log_warning_msg "Impossible to include the ${snap_type} Snapshot (o)"
- return 1
- fi
-
- if [ -z ${PERSISTENCE_READONLY} ]
- then
- echo "export ${snap_type}SNAP=${snap_relpath}:${snapdev}:${snapfile}" >> snapshot.conf # for resync on reboot/halt
- fi
- return 0
-}