7 # Persistence enhancer script
8 # This script saves precious time on slow persistence devices/image files
9 # and writes on flash based device.
10 # a tmpfs on $PERSTMP is mounted and directories listed in
11 # /etc/live-persistence.binds will be copied there and then bind mounted back.
13 if [ -z "${PERSISTENCE}" ] || [ -n "${NOPERSISTENCE}" ] || [ -z "${PERSISTENCE_IS_ON}" ] || [ ! -f /root/etc/live-persistence.binds ]
18 # FIXME: stop hardcoding overloading of initramfs-tools functions
20 . /lib/live/boot/initramfs-tools.sh
22 dirs="$(sed -e '/^ *$/d' -e '/^#.*$/d' /root/etc/live-persistence.binds | tr '\n' '\0')"
28 log_begin_msg "Moving persistence bind mounts"
30 PERSTMP="/root/live/persistence-binds"
33 if [ ! -d "${PERSTMP}" ]
38 mount -t tmpfs tmpfs "${PERSTMP}"
40 for dir in $(echo "${dirs}" | tr '\0' '\n')
42 if [ ! -e "/root/${dir}" ] && [ ! -L "/root/${dir}" ]
44 # directory do not exists, create it
45 mkdir -p "/root/${dir}"
46 elif [ ! -d "/root/${dir}" ]
48 # it is not a directory, skip it
52 # Copy previous content if any
54 find . -print0 | ${CPIO} -pumd0 "${PERSTMP}/${dir}"
57 # Bind mount it to origin
58 mount -o bind "${PERSTMP}/${dir}" "/root/${dir}"