projects
/
live-boot-grml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix read-only persistence mode with overlayfs
[live-boot-grml.git]
/
components
/
9990-misc-helpers.sh
diff --git
a/components/9990-misc-helpers.sh
b/components/9990-misc-helpers.sh
index
83eca32
..
fba3d43
100755
(executable)
--- a/
components/9990-misc-helpers.sh
+++ b/
components/9990-misc-helpers.sh
@@
-420,6
+420,12
@@
is_supported_fs ()
return 1
fi
return 1
fi
+ # get_fstype might report "unknown" or "swap", ignore it as no such kernel module exists
+ if [ "${fstype}" = "unknown" ] || [ "${fstype}" = "swap" ]
+ then
+ return 1
+ fi
+
# Try to look if it is already supported by the kernel
if grep -q ${fstype} /proc/filesystems
then
# Try to look if it is already supported by the kernel
if grep -q ${fstype} /proc/filesystems
then
@@
-449,7
+455,7
@@
is_supported_fs ()
get_fstype ()
{
get_fstype ()
{
-
/sbin/
blkid -s TYPE -o value $1 2>/dev/null
+ blkid -s TYPE -o value $1 2>/dev/null
}
where_is_mounted ()
}
where_is_mounted ()
@@
-507,7
+513,7
@@
base_path ()
{
testpath="${1}"
mounts="$(awk '{print $2}' /proc/mounts)"
{
testpath="${1}"
mounts="$(awk '{print $2}' /proc/mounts)"
- testpath="$(
busybox
realpath ${testpath})"
+ testpath="$(realpath ${testpath})"
while true
do
while true
do
@@
-625,7
+631,7
@@
setup_loop ()
echo "${passphrase}" > /tmp/passphrase
unset passphrase
exec 9</tmp/passphrase
echo "${passphrase}" > /tmp/passphrase
unset passphrase
exec 9</tmp/passphrase
-
/sbin/
losetup ${options} -e "${encryption}" -p 9 "${dev}" "${fspath}"
+ losetup ${options} -e "${encryption}" -p 9 "${dev}" "${fspath}"
error=${?}
exec 9<&-
rm -f /tmp/passphrase
error=${?}
exec 9<&-
rm -f /tmp/passphrase
@@
-732,7
+738,7
@@
mount_persistence_media ()
fi
elif [ "${backing}" != "${old_backing}" ]
then
fi
elif [ "${backing}" != "${old_backing}" ]
then
- if ! mount -
-
move ${old_backing} ${backing} >/dev/null
+ if ! mount -
o
move ${old_backing} ${backing} >/dev/null
then
[ -z "${probe}" ] && log_warning_msg "Failed to move persistence media ${device}"
rmdir "${backing}"
then
[ -z "${probe}" ] && log_warning_msg "Failed to move persistence media ${device}"
rmdir "${backing}"
@@
-772,7
+778,7
@@
close_persistence_media ()
if is_active_luks_mapping ${device}
then
if is_active_luks_mapping ${device}
then
-
/sbin/
cryptsetup luksClose ${device}
+ cryptsetup luksClose ${device}
fi
}
fi
}
@@
-786,7
+792,7
@@
open_luks_device ()
opts="${opts} --readonly"
fi
opts="${opts} --readonly"
fi
- if
/sbin/
cryptsetup status "${name}" >/dev/null 2>&1
+ if cryptsetup status "${name}" >/dev/null 2>&1
then
re="^[[:space:]]*device:[[:space:]]*\([^[:space:]]*\)$"
opened_dev=$(cryptsetup status ${name} 2>/dev/null | grep "${re}" | sed "s|${re}|\1|")
then
re="^[[:space:]]*device:[[:space:]]*\([^[:space:]]*\)$"
opened_dev=$(cryptsetup status ${name} 2>/dev/null | grep "${re}" | sed "s|${re}|\1|")
@@
-827,7
+833,7
@@
open_luks_device ()
while true
do
$cryptkeyscript "$cryptkeyprompt" | \
while true
do
$cryptkeyscript "$cryptkeyprompt" | \
-
/sbin/
cryptsetup -T 1 luksOpen ${dev} ${name} ${opts}
+ cryptsetup -T 1 luksOpen ${dev} ${name} ${opts}
if [ 0 -eq ${?} ]
then
if [ 0 -eq ${?} ]
then
@@
-868,14
+874,14
@@
get_gpt_name ()
{
local dev
dev="${1}"
{
local dev
dev="${1}"
-
/sbin/
blkid -s PART_ENTRY_NAME -p -o value ${dev} 2>/dev/null
+ blkid -s PART_ENTRY_NAME -p -o value ${dev} 2>/dev/null
}
is_gpt_device ()
{
local dev
dev="${1}"
}
is_gpt_device ()
{
local dev
dev="${1}"
- [ "$(
/sbin/
blkid -s PART_ENTRY_SCHEME -p -o value ${dev} 2>/dev/null)" = "gpt" ]
+ [ "$(blkid -s PART_ENTRY_SCHEME -p -o value ${dev} 2>/dev/null)" = "gpt" ]
}
probe_for_gpt_name ()
}
probe_for_gpt_name ()
@@
-915,7
+921,7
@@
probe_for_fs_label ()
for label in ${overlays}
do
for label in ${overlays}
do
- if [ "$(
/sbin/
blkid -s LABEL -o value $dev 2>/dev/null)" = "${label}" ]
+ if [ "$(blkid -s LABEL -o value $dev 2>/dev/null)" = "${label}" ]
then
echo "${label}=${dev}"
fi
then
echo "${label}=${dev}"
fi
@@
-1108,7
+1114,7
@@
find_persistence_media ()
# Close luks device if it isn't used
if [ -z "${result}" ] && [ -n "${luks_device}" ] && is_active_luks_mapping "${luks_device}"
then
# Close luks device if it isn't used
if [ -z "${result}" ] && [ -n "${luks_device}" ] && is_active_luks_mapping "${luks_device}"
then
-
/sbin/
cryptsetup luksClose "${luks_device}"
+ cryptsetup luksClose "${luks_device}"
fi
done
fi
done
@@
-1139,13
+1145,13
@@
get_mac ()
is_luks_partition ()
{
device="${1}"
is_luks_partition ()
{
device="${1}"
-
/sbin/
cryptsetup isLuks "${device}" 1>/dev/null 2>&1
+ cryptsetup isLuks "${device}" 1>/dev/null 2>&1
}
is_active_luks_mapping ()
{
device="${1}"
}
is_active_luks_mapping ()
{
device="${1}"
-
/sbin/
cryptsetup status "${device}" 1>/dev/null 2>&1
+ cryptsetup status "${device}" 1>/dev/null 2>&1
}
get_luks_backing_device ()
}
get_luks_backing_device ()
@@
-1163,6
+1169,10
@@
removable_dev ()
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
do
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
do
+ if [ ! -d "${sysblock}" ]; then
+ continue
+ fi
+
dev_ok=
if [ "$(cat ${sysblock}/removable)" = "1" ]
then
dev_ok=
if [ "$(cat ${sysblock}/removable)" = "1" ]
then
@@
-1208,6
+1218,10
@@
non_removable_dev ()
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
do
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
do
+ if [ ! -d "${sysblock}" ]; then
+ continue
+ fi
+
if [ "$(cat ${sysblock}/removable)" = "0" ]
then
case "${output_format}" in
if [ "$(cat ${sysblock}/removable)" = "0" ]
then
case "${output_format}" in
@@
-1584,7
+1598,7
@@
activate_custom_mounts ()
do_union ${dest} ${source} ${rootfs_dest_backing}
elif [ -n "${opt_bind}" ] && [ -z "${PERSISTENCE_READONLY}" ]
then
do_union ${dest} ${source} ${rootfs_dest_backing}
elif [ -n "${opt_bind}" ] && [ -z "${PERSISTENCE_READONLY}" ]
then
- mount -
-
bind "${source}" "${dest}"
+ mount -
o
bind "${source}" "${dest}"
elif [ -n "${opt_bind}" -o -n "${opt_union}" ] && [ -n "${PERSISTENCE_READONLY}" ]
then
# bind-mount and union mount are handled the same
elif [ -n "${opt_bind}" -o -n "${opt_union}" ] && [ -n "${PERSISTENCE_READONLY}" ]
then
# bind-mount and union mount are handled the same
@@
-1601,6
+1615,13
@@
activate_custom_mounts ()
mkdir -p ${cow_dir}
chown_ref "${source}" "${cow_dir}"
chmod_ref "${source}" "${cow_dir}"
mkdir -p ${cow_dir}
chown_ref "${source}" "${cow_dir}"
chmod_ref "${source}" "${cow_dir}"
+ if [ "${UNIONTYPE}" = "overlay" ]
+ then
+ # When we use overlay we add the "/rw" postfix to our source when using it
+ # as upper layer. Therefore we also have to add it here when using it as
+ # the lower layer.
+ source="${source}/rw"
+ fi
do_union ${dest} ${cow_dir} ${source} ${rootfs_dest_backing}
fi
do_union ${dest} ${cow_dir} ${source} ${rootfs_dest_backing}
fi