+++ /dev/null
-3b958f13deb977ed08c7ff2be29bfda68c80ef4a 1.110.4-1.grml01
-e09269bfed3a51506daa42e3a68a9c8645f5b699 1.110.7-2~grml.01
-49bf1f9b8545be452a46c6c6873dc78ccd69bcb3 1.110.7-2~grml.02
-b5965ec3f351f06c62dd0eb75b7ff7ef179eb40a 1.110.7-2~grml.03
-d2b1e45146222439f3219e18a1eaa9116edaa77f 1.136.3-2~grml.01
-51ce7b4d37c5e5b7414bff5258c079fc0066a939 1.136.3-2~grml.02
-6d9de482650fbcadebe16561a71dce1e77b80c3a 1.136.3-2~grml.03
-85a0f25e761aaef19ecf0d0de5a2fdf7c4224dbb 1.136.3-2~grml.04
-a0632f41d658194cacd716d29320b2db511a7a11 1.139.1-1grml.01
ROOTSNAP=""
HOMESNAP=""
-set -eu
+if [ -n "${LIVE_SNAPSHOT_CHECK_UNBOUND}" ]
+then
+ set -eu
+else
+ set -e
+fi
. /usr/share/initramfs-tools/scripts/live-helpers
SNAP_RESYNC_STRING=""
SNAP_TYPE="cpio"
SNAP_LIST="/etc/live-snapshot.list"
+EXCLUDE_LIST="/etc/live-snapshot.exclude_list"
Error ()
{
esac
}
+Entry_is_modified ()
+{
+ # Returns true if file exists and it is also present in "cow" directory
+ # This means it is modified in respect to read-only media, so it deserve
+ # to be saved
+
+ entry="${1}"
+
+ if [ -e "${entry}" ] || [ -L "${entry}" ]
+ then
+ if [ -e "${DEF_SNAP_COW}/${entry}" ] || [ -L "${DEF_SNAP_COW}/${entry}" ]
+ then
+ return 0
+ fi
+ fi
+ return 1
+}
+
Do_filelist ()
{
- # BUGS: supports only cpio.gz types right now
+ # BUGS: supports only cpio.gz types, and does not handle deleted files yet
+
TMP_FILELIST=$1
if [ -f "${SNAP_LIST}" ]
then
- # Generate include list
- for entry in $(cat "${SNAP_LIST}" | grep -v '^#.*$' | grep -v '^ *$')
+ # Generate include list removing empty and commented lines
+ for entry in $(sed -e '/^ *$/d' -e '/^#.*$/d' "${SNAP_LIST}")
do
- if [ -f "${entry}" ]
- then
- printf "%s\000" "${entry}" >> "${TMP_FILELIST}"
- elif [ -d "${entry}" ]
+ if [ -d "${entry}" ]
then
cd /
- find "${entry}" -print0 >> "${TMP_FILELIST}"
+ find "${entry}" | while read line
+ do
+ if Entry_is_modified "${line}"
+ then
+ printf "%s\000" "${line}" >> "${TMP_FILELIST}"
+ fi
+ done
cd "${OLDPWD}"
+ elif Entry_is_modified "${entry}"
+ then
+ # if file exists and it is modified
+ printf "%s\000" "${entry}" >> "${TMP_FILELIST}"
fi
done
# Removing whiteheads of unionfs
cd "${SNAP_COW}"
find . -name '*.wh.*' >> "${TMP_FILELIST}"
+
+ if [ -e "${EXCLUDE_LIST}" ]
+ then
+ # Add explicitly excluded files
+ grep -v '^#.*$' "${EXCLUDE_LIST}" | grep -v '^ *$' >> "${TMP_FILELIST}"
+ fi
+
cd "${OLDPWD}"
mksquashfs "${SNAP_COW}" "${DEST}" -ef "${TMP_FILELIST}"
;;
cpio)
WORKING_DIR=$(Do_filelist "${TMP_FILELIST}")
cd "${WORKING_DIR}"
- cat "${TMP_FILELIST}" | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" || exit 1
+ if [ -e "${EXCLUDE_LIST}" ]
+ then
+ # Convert \0 to \n and tag existing (rare but possible) \n in filenames,
+ # this to let grep -F -v do a proper work in filtering out
+ cat "${TMP_FILELIST}" | \
+ tr '\n' '\1' | \
+ tr '\0' '\n' | \
+ grep -F -v -f "${EXCLUDE_LIST}" | \
+ tr '\n' '\0' | \
+ tr '\1' '\n' | \
+ cpio --quiet -o0 -H newc | \
+ gzip -9c > "${DEST}" || exit 1
+ else
+ cat "${TMP_FILELIST}" | \
+ cpio --quiet -o0 -H newc | \
+ gzip -9c > "${DEST}" || exit 1
+ fi
cd "${OLDPWD}"
;;
+ # ext2|ext3 and jffs2 does not easily support an exclude list; files
+ # should be copied to another directory in order to filter content
ext2|ext3)
DU_DIM="$(du -ks ${SNAP_COW} | cut -f1)"
REAL_DIM="$(expr ${DU_DIM} + ${DU_DIM} / 20)" # Just 5% more to be sure, need something more sophistcated here...
--- /dev/null
+# /etc/live-persistence.binds example
+#
+# If this file is present in the proper path, each uncommented not empty line
+# will be treated as a directory which should not be made persistent and
+# which it's content should be volatile.
+#
+# This is achieved by bind mounting on it a tmpfs clone of the directory specified
+
+# Exclude some standard temporary paths
+/tmp
+/var/log
+/var/cache
+
+# Firefox profiles are not always useful to remember
+/root/.mozilla
--- /dev/null
+# /etc/live-snapshot.exclude_list example
+#
+# If this file is present in the proper path, each uncommented not empty line
+# will be excluded in the target snapshot when live-snapshot is run.
+#
+# The syntax for the line is just a full file or directory pathname.
+
+# Each line is treated like a plain match string for "grep -F -v",
+# so be careful: e.g. "/tmp" will exclude also "/var/tmp" !
+
+# Exclude some standard temporary paths
+/tmp
+/var/log
+/var/cache
+
+# Firefox profiles are not always useful to remember
+/root/.mozilla
+live-initramfs (1.139.1-3grml.01) unstable; urgency=low
+
+ * Resync with Debian's 1.139.1-3 version:
+
+ [ Chris Lamb ]
+ * Remove local overiddes of log_*_msg - #494257 is now fixed in testing.
+
+ [ Daniel Baumann ]
+ * Removing currently unused Upstream-Depends field in control.
+ * Updating vcs fields in control file.
+ * Sourcing live.vars in 15autologin directly, rather than to inherit
+ from live-functions.
+
+ [ Marco Amadori ]
+ * Removed some useless spaces.
+ * Fix default user handling.
+ * Added a pretty vital mount debug string.
+ * Create /etc/mtab on the initramfs ASAP.
+ * Removed mount -n option, since mtab is there.
+ * Re-enable "break=live-premount" debug.
+ * Skipped some runtime duplicated execution.
+ * Add real cpio to initramfs for snapshot's uses.
+ * Fixed try_snap() umounting on error.
+ * Override maybe_break from initramfs-tools.
+ * Forces use of initramfs cpio over busybox's one.
+ * Fixed a wrong trial to copy an unexistant snapshot.
+ * Check for files and umount only if you can mount it first.
+ * Included more debug and comments on persistence code.
+ * Set -u in live-snapshot only in debug mode.
+
+ [ Michael Prokop ]
+ * Ignore errors from fstype.
+
+ -- Michael Prokop <mika@grml.org> Tue, 04 Nov 2008 01:32:01 +0100
+
live-initramfs (1.139.1-2grml.01) unstable; urgency=low
* Resync with Debian's 1.139.1-2 version.
Package: live-initramfs
Architecture: all
Depends: ${misc:Depends}, busybox, file, initramfs-tools, sudo, udev, user-setup
-Recommends: eject, loop-aes-utils, uuid-runtime, wget
-Suggests: curlftpfs, genext2fs (>= 1.4.1), httpfs2, squashfs-tools, mtd-tools
+Recommends: eject, uuid-runtime, wget
+Suggests: loop-aes-utils, curlftpfs, genext2fs (>= 1.4.1), httpfs2, squashfs-tools, mtd-tools
Description: Debian Live initramfs hook
live-initramfs is a hook for the initramfs-tools, used to generate a initramfs
capable to boot live systems, such as those created by live-helper. This
01_add_rsync.dpatch
02_more_verbose_toram.dpatch
03_grml_version_file_hook.dpatch
-04_ignore_errors_from_fstype.dpatch
05_boot_failure_message_grml.dpatch
+++ /dev/null
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 04_ignore_errors_from_fstype.dpatch by Michael Prokop <mika@grml.org>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: Ignore errors from fstype
-##
-## Redirect stderr to /dev/null, otherwise we'll get
-## "stdin: error 0" for some partitions during bootup.
-##
-
-@DPATCH@
-
-diff -r 6b72cefbc61b scripts/live-helpers
---- a/scripts/live-helpers Mon Sep 15 17:32:23 2008 +0200
-+++ b/scripts/live-helpers Mon Sep 15 17:34:17 2008 +0200
-@@ -77,7 +77,7 @@
- return
- fi
-
-- eval $(fstype < ${1})
-+ eval $(fstype < ${1} 2>/dev/null)
-
- if [ "${FSTYPE}" != "unknown" ]
- then
@DPATCH@
---- a/scripts/live-functions Sat Aug 16 11:12:23 2008 +0200
-+++ b/scripts/live-functions Sat Aug 16 11:50:30 2008 +0200
-@@ -119,12 +119,16 @@
+--- a/scripts/live-functions
++++ b/scripts/live-functions
+@@ -90,11 +90,16 @@ panic() {
printf " ${DEB_1}\n"
printf " ${DEB_2} \033[1;37mBOOT FAILED!\033[0m\n"
printf " ${DEB_3}\n"
+ printf " ${DEB_4} This grml image failed to boot.\n\n"
- printf " Please file a bug against the 'live-initramfs' package or email the Debian\n"
-- printf " Live mailing list at <debian-live-devel@lists.alioth.debian.org>, making\n"
+- printf " Live mailing list at <debian-live@lists.debian.org>, making sure to note the\n"
+- printf " exact version, name and distribution of the image you were attempting to boot.\n\n"
+ printf " Please file a bug at http://grml.org/bugs/ or http://bts.grml.org/, making\n"
- printf " sure to note the exact version, name and distribution of the image you were\n"
- printf " attempting to boot.\n\n"
++ printf " sure to not the exact version, name and distribution of the image you were\n"
++ printf " attempting to boot.\n\n"
+
-+ if [ -r /etc/grml_version ] ; then
-+ GRML_VERSION="$(cat /etc/grml_version)"
-+ printf " $GRML_VERSION\n\n"
-+ fi
++ if [ -r /etc/grml_version ] ; then
++ GRML_VERSION="$(cat /etc/grml_version)"
++ printf " $GRML_VERSION\n\n"
++ fi
printf " The file ${LIVELOG} contains some debugging information but booting with the\n"
printf " ${DEBUG} command-line parameter will greatly increase its verbosity which is\n"
live swapon
live nouser
live noxautoconfig
-live persistent
+live persistent[=nofiles]
live {preseed/file|file}=FILE
live package/question=VALUE
live quickreboot
# Program: md5sum
copy_exec /usr/bin/md5sum /bin
+# Program: cpio
+# busybox and klibc lacks --no-absolute-filenames and --sparse, needed for snapshots
+if [ -e "${DESTDIR}/bin/cpio" ]
+then
+ # Override already present cpio's, mostly klibc's
+ rm "${DESTDIR}/bin/cpio"
+fi
+copy_exec /bin/cpio /bin
+
# Program: udev
if [ -x /sbin/udevadm ]
then
if you either do the detection on your own, or, if you want to ship a custom,
premade xorg.conf in your live system.
- persistent::
+ persistent[=nofiles]::
live-initramfs will look for persistent and snapshot partitions or files labeled
"live-rw", "home-rw", and files called "live-sn*", "home-sn*" and will try to,
in order: mount as /cow the first, mount the second in /home, and just copy the
contents of the latter in appropriate locations (snapshots). Snapshots will be
tried to be updated on reboot/shutdown. Look at live-snapshot(1) for more
-informations.
+informations. If "nofiles" is specified, only filesystems with matching labels
+will be searched; no filesystems will be traversed looking for archives or image
+files. This results in shorter boot times.
{preseed/file|file}=**FILE**::
this list will be on the "top" of the aufs, directly below /cow. Without
this file, any images in the "/live" directory are loaded in alphanumeric order.
+ /etc/live-persistence.binds
+
+This optional file (which resides in the rootfs system, not in the live media)
+is used as a list of directories which not need be persistent: ie. their
+content does not need to survive reboots when using the persistence features.
+
+This saves expensive writes and speeds up operations on volatile data such as
+web caches and temporary files (like e.g. /tmp and .mozilla) which are
+regenerated each time. This is achieved by bind mounting each listed directory
+with a tmpfs on the original path.
+
+
See also
--------
/etc/live-snapshot.list
-This optional file, if present changes the behaviour of live-snapshot, only files and directories listed there are included (integrally) in the snapshot.
-Beware, it is an experimental feature that only works for cpio targets now.
+This optional file, if present changes the behaviour of live-snapshot, only files and directories listed there are included (integrally) in the snapshot. It works only for cpio targets.
+
+ /etc/live-snapshot.exclude_list
+
+This optional file, if present will filter the files that will be saved by live-snapshot removing (as in "grep -F -v") all filenames that will be matched by strings listed in it.
+It works for cpio and squashfs snapshot types only; it is pretty useful for filtering temporary files and disk caches.
+
See also
--------
/etc/live-snapshot.list
Facoltativo, se presente cambia completamente il funzionamento di live-snapshot; solo i files e le directory elencate verranno effettivamente inclusi nello snapshot.
-Attenzione, e` una funzionalita` sperimentale che funziona attualmente solo con gli snapshot di tipo "cpio".
+Funziona attualmente solo con gli snapshot di tipo "cpio".
+ /etc/live-snapshot.exclude_list
+
+Facoltativo, se presente verrà utilizzato per filtrare i file da includere negli snapshot. Tutte i file che conterranno le stringhe elecate (come "grep -F -v") non verranno salvati da live-snapshot.
+Funziona attualmente solo con gli snapshot di tipo "cpio" e "squashfs"; è utile per filtrare contenuti poco significativi come i file temporanei e la cache.
See also
--------
mkdir -p "${mountpoint}"
+# Create /etc/mtab for debug purpose and future syncs
+if [ ! -d /etc ]
+then
+ mkdir /etc/
+fi
+
+if [ ! -f /etc/mtab ]
+then
+ touch /etc/mtab
+fi
+
[ -f /etc/live.conf ] && . /etc/live.conf
export USERNAME USERFULLNAME HOSTNAME
export PERSISTENT
;;
+ persistent=*)
+ PERSISTENT="${ARGUMENT#persistent=}"
+ if [ -z "${PERSISTENT}" ]
+ then
+ PERSISTENT="Yes"
+ fi
+ export PERSISTENT
+ ;;
+
nopersistent)
NOPERSISTENT="Yes"
export NOPERSISTENT
url=*)
location="${ARGUMENT#url=}"
- mount -n -o bind /sys /root/sys
- mount -n -o bind /proc /root/proc
- mount -n -o bind /dev /root/dev
+ mount -o bind /sys /root/sys
+ mount -o bind /proc /root/proc
+ mount -o bind /dev /root/dev
mkdir -p /root/var/run/network
chroot /root dhclient eth0
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 '/\<Cached/{print $2}' /proc/meminfo ) )
mount_options="-o size=${size}k"
free_string="memory"
fstype="tmpfs"
# begin copying (or uncompressing)
mkdir "${copyto}"
echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
- mount -n -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
+ mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
if [ "${extension}" = "tgz" ]
then
cd "${copyto}"
tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
- mount -n -r -o move "${copyto}" "${rootmnt}"
+ mount -r -o move "${copyto}" "${rootmnt}"
cd "${OLDPWD}"
else
if [ -n "${MODULETORAMFILE}" ]
livefs_root
umount ${copyfrom}
- mount -n -r -o move ${copyto} ${copyfrom}
+ mount -r -o move ${copyto} ${copyfrom}
fi
rmdir ${copyto}
{
rc=1
dest="${mountpoint}/${LIVE_MEDIA_PATH}"
- mount -n -t ramfs ram "${mountpoint}"
+ mount -t ramfs ram "${mountpoint}"
mkdir -p "${dest}"
for webfile in HTTPFS FTPFS FETCH
# look for free mem
if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
then
- todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' )
- freespace=$(df -k | grep -s ${todev} | awk '{print $4}')
+ todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
+ freespace=$(df -k | awk '/'${todev}'/{print $4}')
else
- 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 '/\<Cached/{print $2}' /proc/meminfo))
fi
tomount="/mnt/tmpsnap"
if [ -n "${fstype}" ]
then
# Copying stuff...
- mount -n -t "${fstype}" -o ro,noatime "${fromdev}" "${tomount}"
+ 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
fi
}
+find_snap ()
+{
+ # Look for ${snap_label}.* in block devices
+ snap_label="${1}"
+
+ if [ "${PERSISTENT}" != "nofiles" ]
+ then
+ # search for image files
+ snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
+ fi
+
+ if [ -z "${snapdata}" ]
+ then
+ snapdata=$(find_cow_device "${snap_label}")
+ fi
+ echo "${snapdata}"
+}
+
try_snap ()
{
- # Look for ${snap_label}.* in block devices and copy the contents to ${snap_mount}
+ # copy the contents of previously found snapshot to ${snap_mount}
# and remember the device and filename for resync on exit in live-initramfs.init
- snap_label="${1}"
+ snapdata="${1}"
snap_mount="${2}"
snap_type="${3}"
- snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
if [ ! -z "${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 ' ')"
+ RES=""
+ if ! try_mount "${snapdev}" "${snapback}" "ro"
+ then
+ break
+ fi
+
if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
then
# squashfs, jffs2 or ext2/ext3 snapshot
dev=$(get_backing_device "${snapback}/${snapfile}")
- if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
- then
- log_warning_msg "Impossible to include the ${snapfile} Snapshot"
- return 1
- fi
+ do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
+ RES=$?
else
# cpio.gz snapshot
- if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1)
+ cd "${snap_mount}"
+ zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
+ RES=$?
+ if [ "${RES}" != "0" ]
then
- log_warning_msg "Impossible to include the ${snapfile} Snapshot"
- return 1
+ 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}"
- else
- dev=$(find_cow_device "${snap_label}")
+ umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
- if [ -b ${dev} ]
+ if [ "${RES}" != "0" ]
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
+ log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
+ fi
- if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
- 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
- fi
+
+ 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
+ # 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
- log_warning_msg "Impossible to include the ${snap_label} Snapshot"
+ snapdev="${dev}"
+ fi
+
+ 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
+ # it was a loop device, user confused
+ umount ${snapdev}
+ fi
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
mkdir -p "${croot}/${imagename}"
log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
- mount -n -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}"
+ 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
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
nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
else
- mount -n -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
+ mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
fi
fi
exposedrootfs=${rofslist%% }
- mount -n --bind ${exposedrootfs} ${rootmnt} || \
+ mount --bind ${exposedrootfs} ${rootmnt} || \
panic "bind mount of ${exposedrootfs} failed"
cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
for dir in ${cow_dirs}; do
mkdir -p /cow${dir}
- mount -n -t ${UNIONTYPE} \
+ 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 -n -t ${UNIONTYPE} -o noatime,dirs=/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}"
fi
# tmpfs file systems
touch /etc/fstab
mkdir -p "${rootmnt}/live"
- mount -n -t tmpfs tmpfs ${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 -n -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
+ 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"
+ 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}" ]
;;
*)
- mount -n -o move "${d}" "${rootmnt}/live/${d##*/}"
+ mount -o move "${d}" "${rootmnt}/live/${d##*/}"
;;
esac
done
# shows cow fs on /cow for use by live-snapshot
mkdir -p "${rootmnt}/live/cow"
- mount -n -o move /cow "${rootmnt}/live/cow" >/dev/null 2>&1 || mount -n -o bind /cow "${rootmnt}/live/cow" || log_warning_msg "Unable to move or bind /cow to ${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"
}
check_dev ()
if [ -d "${devname}" ]
then
- mount -n -o bind "${devname}" $mountpoint || continue
+ mount -o bind "${devname}" $mountpoint || continue
if is_live_path $mountpoint
then
if is_supported_fs ${fstype}
then
- mount -n -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+ mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
if is_live_path ${mountpoint} && \
([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
Arguments
set_usplash_timeout
+
+ maybe_break live-premount
log_begin_msg "Running /scripts/live-premount"
run_scripts /scripts/live-premount
log_end_msg
if [ ! -d /root/live/image ]
then
mkdir -p /root/live/image
- mount -n --move /live/image /root/live/image
+ mount --move /live/image /root/live/image
fi
log_end_msg
# live-initramfs script
-echo "${HOSTNAME}" > /root/etc/hostname
+# Change hostname only if it is not set
+if [ ! -f /root/etc/hostname ] || grep -qs localhost\.localdomain /root/etc/hostname
+then
+ echo "${HOSTNAME}" > /root/etc/hostname
+else
+ HOSTNAME="$(cat /root/etc/hostname)"
+ really_export HOSTNAME
+fi
-cat >> /root/etc/hosts << EOF
+# Create /etc/hosts only if it is not present or empty
+if [ ! -s /root/etc/hosts ]
+then
+ cat > /root/etc/hosts << EOF
127.0.0.1 localhost
127.0.1.1 ${HOSTNAME}
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
EOF
+fi
hostname "${HOSTNAME}"
--- /dev/null
+#!/bin/sh
+
+# 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.
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -z "${PERSISTENT}" ] || [ -n "${NOPERSISTENT}" ] || [ -z "${PERSISTENCE_IS_ON}" ] || [ ! -f /root/etc/live-persistence.binds ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+# live-initramfs script
+
+dirs="$(sed -e '/^ *$/d' -e '/^#.*$/d' /root/etc/live-persistence.binds | tr '\n' '\0')"
+if [ -z "${dirs}" ]
+then
+ exit 0
+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
set passwd/user-uid
EOF
+if ! grep "${USERNAME}" /root/etc/passwd
+then
+ echo "The default user (${USERNAME}) is not present,"
+ first_user=$(grep '^[^:]*:[^:]*:[12]\?[0-9][0-9][0-9][0-9]:' /root/etc/passwd | head -1 | cut -f1 -d ':')
+ if [ -n "${first_user}" ];
+ then
+ echo "setting default user to: ${first_user}."
+ USERNAME="${first_user}"
+ really_export USERNAME
+ else
+ echo "no other valid users found, disabling autologin."
+ NOAUTOLOGIN="Yes"
+ NOXAUTOLOGIN="Yes"
+ USERNAME=""
+ really_export NOAUTOLOGIN
+ really_export NOXAUTOLOGIN
+ really_export USERNAME
+ log_end_msg
+ exit 0
+ fi
+fi
+
if [ -z "${NOSUDO}" ]
then
if ! grep -q "${USERNAME}" /root/etc/sudoers
# live-initramfs script
-cat >> ${FSTAB} << EOF
+# Create a fake fstab only if it is not already there
+if [ ! -f "${FSTAB}" ] || grep -qs 'UNCONFIGURED FSTAB FOR BASE SYSTEM' "${FSTAB}"
+then
+ cat >> ${FSTAB} << EOF
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
${UNIONTYPE} / ${UNIONTYPE} rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
EOF
+fi
# disabled for now
#rm -f /root/etc/rcS.d/S*checkroot.sh
continue
fi
- /lib/udev/vol_id ${device%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue
+ /lib/udev/vol_id ${device%%[0-9]*} 2>/dev/null | grep -q "^ID_FS_USAGE=raid" && continue
magic=$(/bin/dd if="${device}" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
# live-initramfs header
-if [ -n "${NOXAUTOLOGIN}" ]
+. /live.vars
+
+if [ -n "${NOXAUTOLOGIN}" ] || [ -z "${USERNAME}" ]
then
exit 0
fi
locale=en_US.UTF-8
-mount -n -o bind /sys /root/sys
-mount -n -o bind /proc /root/proc
-mount -n -o bind /dev /root/dev
+mount -o bind /sys /root/sys
+mount -o bind /proc /root/proc
+mount -o bind /dev /root/dev
if [ -n "${XDEBCONF}" -a -x /root/usr/sbin/xdebconfigurator ]
then
if [ -n "$XDRIVER" ]
then
- mount -n -o bind /sys /root/sys
- mount -n -o bind /proc /root/proc
- mount -n -o bind /dev /root/dev
+ mount -o bind /sys /root/sys
+ mount -o bind /proc /root/proc
+ mount -o bind /dev /root/dev
chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
set xserver-xorg/autodetect_video_card false
if [ -n "$XVIDEOMODE" ]
then
- mount -n -o bind /sys /root/sys
- mount -n -o bind /proc /root/proc
- mount -n -o bind /dev /root/dev
+ mount -o bind /sys /root/sys
+ mount -o bind /proc /root/proc
+ mount -o bind /dev /root/dev
chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
set xserver-xorg/config/monitor/mode-list ${XVIDEOMODE}
panel_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-panel-data 2>/dev/null) || panel_version=""
-if [ -n "${panel_version}" ]
+if [ -n "${panel_version}" ] && [ -n "${USERNAME}" ]
then
chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/panel/global/disable_lock_screen true
fi
. /scripts/live-functions
+if [ -z "${USERNAME}" ]
+then
+ echo "No default user for accessibility options."
+ exit 0
+fi
+
log_begin_msg "Configuring accessibility options"
# live-initramfs script
gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version=""
-if [ -n "${gpm_version}" ]
+if [ -n "${gpm_version}" ] && [ -n "${USERNAME}" ]
then
#live-reconfigure /root gnome-power-manager
# Gnome < 2.20
<match user="root">
<return result="yes"/>
</match>
+EOF
+
+if [ -n "${USERNAME}" ]
+then
+ cat << EOF >> /root/etc/PolicyKit/PolicyKit.conf
<!-- don't ask password for user in live session -->
<match user="$USERNAME">
<return result="yes"/>
</match>
+EOF
+fi
+
+cat << EOF >> /root/etc/PolicyKit/PolicyKit.conf
<define_admin_auth group="admin"/>
</config>
EOF
STRING="${1}"
VALUE="$(eval echo -n \${$STRING})"
- if [ -f /live.vars ] && cat /live.vars | grep -sq "export ${STRING}"
+ if [ -f /live.vars ] && grep -sq "export ${STRING}" /live.vars
then
sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
else
fi
}
+# Override maybe_break from scripts/functions
+maybe_break()
+{
+ if [ "${break}" = "$1" ]; then
+ # Call original panic
+ . /scripts/functions
+ panic "Spawning shell within the initramfs"
+ fi
+}
+
# Override panic from scripts/functions
panic() {
return
fi
- eval $(fstype < ${1})
+ eval $(fstype < ${1} 2>/dev/null)
if [ "${FSTYPE}" != "unknown" ]
then
mountp="/mnt/tmp_fs_size"
mkdir -p "${mountp}"
- mount -n -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}"
+ mount -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}" || log_warning_msg "cannot mount -t $(get_fstype ${dev}) -o ro ${dev} ${mountp}"
doumount=1
fi
if [ -n "${doumount}" ]
then
- umount "${mountp}"
+ umount "${mountp}" || log_warning_msg "cannot umount ${mountp}"
rmdir "${mountp}"
fi
dev="${1}"
mountp="${2}"
opts="${3}"
+ fstype="${4}"
old_mountp="$(where_is_mounted ${dev})"
if [ -n "${old_mountp}" ]
then
- mount -n -o remount,"${opts}" "${dev}" "${old_mountp}" || panic "Remounting ${dev} ${opts} on ${old_mountp} failed"
- mount -n -o bind "${old_mountp}" "${mountp}" || panic "Cannot bind-mount ${old_mountp} on ${mountp}"
+ mount -o remount,"${opts}" "${dev}" "${old_mountp}" || panic "Remounting ${dev} ${opts} on ${old_mountp} failed"
+ mount -o bind "${old_mountp}" "${mountp}" || panic "Cannot bind-mount ${old_mountp} on ${mountp}"
else
- mount -n -t $(get_fstype "${dev}") -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}"
+ if [ -z "${fstype}" ]
+ then
+ fstype=$(get_fstype "${dev}")
+ fi
+ mount -t "${fstype}" -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}, fstype=${fstype}, options=${opts}"
fi
}
find_cow_device ()
{
+ # Returns a device containing a partition labeled "${pers_label}" or containing a file named the same way
+ # in the latter case the partition containing the file is left mounted
+ # if is not in black_listed_devices
pers_label="${1}"
cow_backing="/${pers_label}-backing"
+ black_listed_devices="${2}"
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram | grep -v fd)
do
do
devname=$(sys2dev "${dev}")
+ if echo "${black_listed_devices}" | grep -q "${devname}"
+ then
+ # skip this device enterely
+ break
+ fi
+
if [ "$(/lib/udev/vol_id -l ${devname} 2>/dev/null)" = "${pers_label}" ]
then
echo "${devname}"
return
fi
+ if [ "${PERSISTENT}" = "nofiles" ]
+ then
+ # do not mount the device to find for image files
+ # just skip this
+ break
+ fi
+
case "$(get_fstype ${devname})" in
vfat|ext2|ext3|jffs2)
mkdir -p "${cow_backing}"
- try_mount "${devname}" "${cow_backing}" "rw"
+ if ! try_mount "${devname}" "${cow_backing}" "rw"
+ then
+ break
+ fi
if [ -f "${cow_backing}/${pers_label}" ]
then
find_files ()
{
- # return the first of ${filenames} found on vfat and ext2/ext3 devices
+ # return the a string composed by device name, mountpoint an the first of ${filenames} found on a supported partition
# FIXME: merge with above function
filenames="${1}"
snap_backing="/snap-backing"
+ black_listed_devices="${2}"
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram | grep -v fd)
do
devname=$(sys2dev "${dev}")
devfstype="$(get_fstype ${devname})"
+ if echo "${black_listed_devices}" | grep -q "${devname}"
+ then
+ # skip this device enterely
+ break
+ fi
+
if is_supported_fs ${devfstype}
then
mkdir -p "${snap_backing}"
- try_mount "${devname}" "${snap_backing}" "ro"
- for filename in ${filenames}
+ if try_mount "${devname}" "${snap_backing}" "ro" "${devfstype}"
+ then
+ for filename in ${filenames}
do
- if [ -f "${snap_backing}/${filename}" ]
- then
- echo "${devname} ${snap_backing} ${filename}"
- return 0
- fi
- done
+ if [ -f "${snap_backing}/${filename}" ]
+ then
+ echo "${devname} ${snap_backing} ${filename}"
+ umount ${snap_backing}
+ return 0
+ fi
+ done
+ fi
umount ${snap_backing}
fi