summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-04-09 16:05:48 +0200
committerTails developers <amnesia@boum.org>2012-04-09 16:05:48 +0200
commitf92f379a6e868bc486c050ff5ca81c1707da7374 (patch)
treeb64f36e3966ca1afb7745cc2c9809cc4bc9698e5 /scripts
parent0622a98c98d454e80118d00ec76226ff209e1bc1 (diff)
downloadlive-boot-f92f379a6e868bc486c050ff5ca81c1707da7374.tar.gz
live-boot-f92f379a6e868bc486c050ff5ca81c1707da7374.zip
Allow using / as destination in custom mounts.
Also make this backwards compatible with live-rw labelled volumes.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/live67
-rw-r--r--scripts/live-helpers55
2 files changed, 45 insertions, 77 deletions
diff --git a/scripts/live b/scripts/live
index f4f4059..af8c12e 100755
--- a/scripts/live
+++ b/scripts/live
@@ -952,7 +952,11 @@ setup_unionfs ()
log_end_msg
fi
- mkdir -p /overlay
+ # tmpfs file systems
+ touch /etc/fstab
+ mkdir -p /live
+ mount -t tmpfs tmpfs /live
+ mkdir -p /live/overlay
# Looking for persistence devices or files
if [ -n "${PERSISTENCE}" ] && [ -z "${NOPERSISTENCE}" ]
@@ -999,7 +1003,7 @@ setup_unionfs ()
if echo ${PERSISTENCE_METHOD} | grep -qe "\<overlay\>"
then
- overlays="${root_overlay_label} ${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label}"
+ overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label}"
fi
if echo ${PERSISTENCE_METHOD} | grep -qe "\<snapshot\>"
@@ -1009,7 +1013,6 @@ setup_unionfs ()
local root_snapdata=""
local home_snapshot_label=""
- local root_overlay_label=""
local overlay_devices=""
for media in $(find_persistence_media "${overlays}" "${snapshots}" "${whitelistdev}")
do
@@ -1030,16 +1033,14 @@ setup_unionfs ()
home_snapdata="${media#*=}"
fi
;;
- ${root_overlay_label}=*|${old_root_overlay_label}=*)
- if [ -z "${root_overlay_device}" ]
- then
- device="${media#*=}"
- root_overlay_device="${device}"
- fi
+ ${old_root_overlay_label}=*)
+ device="${media#*=}"
+ fix_backwards_compatibility ${device} / union
+ overlay_devices="${overlay_devices} ${device}"
;;
${old_home_overlay_label}=*)
device="${media#*=}"
- fix_home_rw_compatibility ${device}
+ fix_backwards_compatibility ${device} /home bind
overlay_devices="${overlay_devices} ${device}"
;;
${custom_overlay_label}=*)
@@ -1048,26 +1049,6 @@ setup_unionfs ()
;;
esac
done
-
- if [ -b "${root_overlay_device}" ]
- then
- PERSISTENCE_IS_ON="1"
- export PERSISTENCE_IS_ON
-
- cowdevice=${root_overlay_device}
- cow_fstype=$(get_fstype "${root_overlay_device}")
- if [ -z "${PERSISTENCE_READONLY}" ]
- then
- cow_mountopt="rw,noatime"
- else
- cow_mountopt="ro,noatime"
- fi
-
- if [ "${FORCEPERSISTENCEFSCK}" = "Yes" ]
- then
- fsck -y ${cowdevice}
- fi
- fi
elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENCE}" ]
then
# check if there are any nfs options
@@ -1104,13 +1085,13 @@ setup_unionfs ()
if [ "${UNIONTYPE}" != "unionmount" ]
then
- if [ -n "${PERSISTENCE_READONLY}" ]
+ if [ -n "${PERSISTENCE_READONLY}" ] && [ "${cowdevice}" != "tmpfs" ]
then
- mount -t tmpfs -o rw,noatime,mode=755 tmpfs "/overlay"
- root_backing="${rootmnt}/live/persistence/$(basename ${cowdevice})-root"
+ mount -t tmpfs -o rw,noatime,mode=755 tmpfs "/live/overlay"
+ root_backing="/live/persistence/$(basename ${cowdevice})-root"
mkdir -p ${root_backing}
else
- root_backing="/overlay"
+ root_backing="/live/overlay"
fi
if [ "${cow_fstype}" = "nfs" ]
@@ -1164,12 +1145,11 @@ setup_unionfs ()
unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}"
mount_full $unionmountopts "${unionmountpoint}"
else
- cow_dir="/overlay${dir}"
+ cow_dir="/live/overlay${dir}"
rofs_dir="${rofs}${dir}"
mkdir -p ${cow_dir}
if [ -n "${PERSISTENCE_READONLY}" ] && [ "${cowdevice}" != "tmpfs" ]
then
- #mount -t tmpfs -o rw,noatime,mode=755 tmpfs "${cow_dir}"
do_union ${unionmountpoint} ${cow_dir} ${root_backing} ${rofs_dir}
else
do_union ${unionmountpoint} ${cow_dir} ${rofs_dir}
@@ -1180,11 +1160,6 @@ setup_unionfs ()
# Correct the permissions of /:
chmod 0755 "${rootmnt}"
- # tmpfs file systems
- touch /etc/fstab
- mkdir -p "${rootmnt}/live"
- mount -t tmpfs tmpfs ${rootmnt}/live
-
live_rofs_list=""
# SHOWMOUNTS is necessary for custom mounts with the union option
# Since we may want to do custom mounts in user-space it's best to always enable SHOWMOUNTS
@@ -1193,7 +1168,7 @@ setup_unionfs ()
# XXX: is the for loop really necessary? rofslist can only contain one item (see above XXX about EXPOSEDROOT) and this is also assumed elsewhere above (see use of $rofs above).
for d in ${rofslist}
do
- live_rofs="${rootmnt}/live/rofs/${d##*/}"
+ live_rofs="/live/rofs/${d##*/}"
live_rofs_list="${live_rofs_list} ${live_rofs}"
mkdir -p "${live_rofs}"
case d in
@@ -1223,7 +1198,7 @@ setup_unionfs ()
# Gather information about custom mounts from devies detected as overlays
get_custom_mounts ${custom_mounts} ${overlay_devices}
- [ -n "${DEBUG}" ] && cp ${custom_mounts} "${rootmnt}/live/persistence"
+ [ -n "${DEBUG}" ] && cp ${custom_mounts} "/live/persistence"
# Now we do the actual mounting (and symlinking)
local used_overlays=""
@@ -1245,9 +1220,13 @@ setup_unionfs ()
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
mkdir -p "${rootmnt}/live/overlay"
- mount -o move /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"
+ 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"
+
}
check_dev ()
diff --git a/scripts/live-helpers b/scripts/live-helpers
index 58613d5..9a80b11 100644
--- a/scripts/live-helpers
+++ b/scripts/live-helpers
@@ -15,7 +15,6 @@ else
udevinfo='udevinfo'
fi
-root_overlay_label="full-ov"
old_root_overlay_label="live-rw"
old_home_overlay_label="home-rw"
custom_overlay_label="custom-ov"
@@ -261,7 +260,6 @@ Arguments ()
;;
persistence-subtext=*)
- root_overlay_label="${root_overlay_label}-${ARGUMENT#persistence-subtext=}"
old_root_overlay_label="${old_root_overlay_label}-${ARGUMENT#persistence-subtext=}"
old_home_overlay_label="${old_home_overlay_label}-${ARGUMENT#persistence-subtext=}"
custom_overlay_label="${custom_overlay_label}-${ARGUMENT#persistence-subtext=}"
@@ -745,16 +743,7 @@ try_mount ()
mount_persistence_media ()
{
local device=${1}
- local backing=""
-
- # We can't mount into ${rootmnt}/live before ${rootmnt} has been
- # mounted since that would cover our mountpoint.
- if [ -n "${rootmnt}" ] && [ -z "$(what_is_mounted_on ${rootmnt})" ]
- then
- backing="/$(basename ${device})-backing"
- else
- backing="${rootmnt}/live/persistence/$(basename ${device})"
- fi
+ local backing="/live/persistence/$(basename ${device})"
mkdir -p "${backing}"
local old_backing="$(where_is_mounted ${device})"
@@ -1266,7 +1255,7 @@ do_union ()
get_custom_mounts ()
{
- # Side-effect: leaves $devices with live-persistence.conf mounted in ${rootmnt}/live/persistence
+ # Side-effect: leaves $devices with live-persistence.conf mounted in /live/persistence
# Side-effect: prints info to file $custom_mounts
local custom_mounts=${1}
@@ -1299,7 +1288,7 @@ get_custom_mounts ()
if [ -n "${DEBUG}" ] && [ -e "${include_list}" ]
then
- cp ${include_list} ${rootmnt}/live/persistence/${persistence_list}.${device_name}
+ cp ${include_list} /live/persistence/${persistence_list}.${device_name}
fi
while read dir options # < ${include_list}
@@ -1310,9 +1299,9 @@ get_custom_mounts ()
continue
fi
- if trim_path ${dir} | grep -q -e "^[^/]" -e "^/$" -e "^/live\(/.*\)\?$" -e "^/\(.*/\)\?\.\.\?\(/.*\)\?$"
+ if trim_path ${dir} | grep -q -e "^[^/]" -e "^/live\(/.*\)\?$" -e "^/\(.*/\)\?\.\.\?\(/.*\)\?$"
then
- log_warning_msg "Skipping unsafe custom mount ${dir}: must be an absolute path containing neither the \".\" nor \"..\" special dirs, and cannot be \"/live\" (or any sub-directory therein) or \"/\" (for the latter, use ${root_overlay_label}-type persistence)"
+ log_warning_msg "Skipping unsafe custom mount ${dir}: must be an absolute path containing neither the \".\" nor \"..\" special dirs, and cannot be \"/live\" or any sub-directory therein."
continue
fi
@@ -1416,8 +1405,13 @@ activate_custom_mounts ()
if [ -n "$(what_is_mounted_on "${dest}")" ]
then
- log_warning_msg "Skipping custom mount ${dest}: $(what_is_mounted_on "${dest}") is already mounted there"
- continue
+ if [ "${dest}" = "${rootmnt}" ]
+ then
+ umount "${dest}"
+ else
+ log_warning_msg "Skipping custom mount ${dest}: $(what_is_mounted_on "${dest}") is already mounted there"
+ continue
+ fi
fi
if [ ! -d "${dest}" ]
@@ -1474,7 +1468,7 @@ activate_custom_mounts ()
local rofs_dest_backing=""
if [ -n "${opt_link}"]
then
- for d in ${rootmnt}/live/rofs/*
+ for d in /live/rofs/*
do
if [ -n "${rootmnt}" ]
then
@@ -1496,8 +1490,8 @@ activate_custom_mounts ()
link_files ${source} ${dest} ${rootmnt}
elif [ -n "${opt_link}" ] && [ -n "${PERSISTENCE_READONLY}" ]
then
- mkdir -p ${rootmnt}/live/persistence
- local links_source=$(mktemp -d ${rootmnt}/live/persistence/links-source-XXXXXX)
+ mkdir -p /live/persistence
+ local links_source=$(mktemp -d /live/persistence/links-source-XXXXXX)
chown_ref ${source} ${links_source}
chmod_ref ${source} ${links_source}
# We put the cow dir in the below strange place to
@@ -1505,14 +1499,7 @@ activate_custom_mounts ()
# has its own directory and isn't nested with some
# other custom mount (if so that mount's files would
# be linked, causing breakage.
- if [ -n "${rootmnt}" ]
- then
- local cow_dir="/overlay/live/persistence/$(basename ${links_source})"
- else
- # This is happens if persistence is activated
- # post boot
- local cow_dir="/live/overlay/live/persistence/$(basename ${links_source})"
- fi
+ local cow_dir="/live/overlay/live/persistence/$(basename ${links_source})"
mkdir -p ${cow_dir}
chown_ref "${source}" "${cow_dir}"
chmod_ref "${source}" "${cow_dir}"
@@ -1531,7 +1518,7 @@ activate_custom_mounts ()
# is non-empty (and necessary) only for unions
if [ -n "${rootmnt}" ]
then
- local cow_dir="$(echo ${dest} | sed -e "s|^${rootmnt}|/overlay/|")"
+ local cow_dir="$(echo ${dest} | sed -e "s|^${rootmnt}|/live/overlay/|")"
else
# This is happens if persistence is activated
# post boot
@@ -1562,9 +1549,11 @@ activate_custom_mounts ()
echo ${used_devices}
}
-fix_home_rw_compatibility ()
+fix_backwards_compatibility ()
{
local device=${1}
+ local dir=${2}
+ local opt=${3}
if [ -n "${PERSISTENCE_READONLY}" ]
then
@@ -1580,8 +1569,8 @@ fix_home_rw_compatibility ()
local include_list="${backing}/${persistence_list}"
if [ ! -r "${include_list}" ]
then
- echo "# home-rw backwards compatibility:
-/home source=." > "${include_list}"
+ echo "# persistence backwards compatibility:
+${dir} ${opt},source=." > "${include_list}"
fi
}