Bug#715186: support loop-mounted iso on same partition as persistence
I have been doing this since Debian Squeeze with a patched
9990-misc-helpers in my live initrd. I can use (optionally) a
single-partition live usb with RW access and a persistence file.
It is activated only if "mountmode=rw,noatime" is on cmdline. I never
had any problem with this (although some use cases might) there fore
it is not "default"
I posted this here before but there was no positive interest. Anyway,
here is my latest (done with diff -u) for live-boot_1:20160511
--- 9990-misc-helpers.sh.original 2016-05-11 14:44:15.000000000 +0100
+++ 9990-misc-helpers.sh 2016-05-13 14:12:33.948155440 +0100
@@ -2,6 +2,30 @@
#set -e
+## Patched for version: live-boot-1:20160511
+
+## New cmdline parameter " mountmode=rw"
+## Overrides the live-media partition default RO mount
+##
+## Then the partition containing the live-media will be writable
+## Persistent loopback files in the same partition should then work
+##
+## If " mountmode=rw" is not specified:
+## No changes will be made to original defaults (ro,noatime)
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+if cat /proc/cmdline|grep -q "mountmode=rw" ; then
+ custom_mountmode=rw,noatime
+ echo -e "\n Custom mount options were selected"
+ echo -e " The live-media device will be mounted ${custom_mountmode} \n"
+ sleep 2
+# else live-media partition mount opts default to "ro,noatime"
+fi
+
+## PATCH end ##
+
+
is_live_path()
{
DIRECTORY="${1}/${LIVE_MEDIA_PATH}"
@@ -126,6 +150,26 @@
then
mkdir /live/fromiso
mount -t $fs_type "$ISO_DEVICE" /live/fromiso
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+ ## custom_mountmode: if set, remount /live/fromiso
+ if [ -n "${custom_mountmode}" ]; then
+
+ if [ "$fstype" = "vfat" ]; then
+ custom_mountopts=rw,noatime,umask=000
+ else
+ custom_mountopts=${custom_mountmode}
+ fi
+
+ umount /live/fromiso
+ mount -t ${fstype} -o ${custom_mountopts} "$ISO_DEVICE" /live/fromiso
+
+ fi
+## PATCH end
+
+
ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
loopdevname=$(setup_loop "/live/fromiso/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
devname="${loopdevname}"
@@ -196,6 +240,26 @@
devuid=$(blkid -o value -s UUID "$devname")
[ -n "$devuid" ] && grep -qs "\<$devuid\>" /var/lib/live/boot/devices-already-tried-to-mount && continue
mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+ ## custom_mountmode: if set, remount the live-media device
+ ## but only if is_live_path (we might be "findiso")
+ if is_live_path ${mountpoint} && [ -n "${custom_mountmode}" ]; then
+
+ if [ "$fstype" = "vfat" ]; then
+ custom_mountopts=rw,noatime,umask=000
+ else
+ custom_mountopts=${custom_mountmode}
+ fi
+ umount ${mountpoint}
+ mount -t ${fstype} -o ${custom_mountopts} "${devname}" ${mountpoint} || continue
+ fi
+
+## PATCH end
+
+
[ -n "$devuid" ] && echo "$devuid" >> /var/lib/live/boot/devices-already-tried-to-mount
if [ -n "${FINDISO}" ]
@@ -205,6 +269,25 @@
umount ${mountpoint}
mkdir -p /live/findiso
mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+ ## custom_mountmode: if set, remount /live/findiso
+ if [ -n "${custom_mountmode}" ]; then
+
+ if [ "$fstype" = "vfat" ]; then
+ custom_mountopts=rw,noatime,umask=000
+ else
+ custom_mountopts=${custom_mountmode}
+ fi
+
+ umount /live/findiso
+ mount -t ${fstype} -o ${custom_mountopts} "${devname}" /live/findiso || continue
+ fi
+## PATCH end
+
+
loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
devname="${loopdevname}"
mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
@@ -719,6 +802,26 @@
mkdir -p "${backing}"
old_backing="$(where_is_mounted ${device})"
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+ ## custom_mountmode: (only if) is set rw
+ ## set ${backing} and stop if live-media device is already mounted
+ ##
+ if [ -n "${custom_mountmode}" ]; then
+
+ if [ "${old_backing}" = "/live/findiso" ] || [ "${old_backing}" = "/live/fromiso" ] || [ "${old_backing}" = "/live/medium" ]
+ then
+ backing=${old_backing}
+ echo ${backing}
+ return 0
+ fi
+ fi
+
+## PATCH end
+
+
if [ -z "${old_backing}" ]
then
fstype="$(get_fstype ${device})"
@@ -1031,6 +1134,19 @@
black_listed_devices="${black_listed_devices} $(what_is_mounted_on d)"
done
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+ ## custom_mountmode: If used with persistence, unset black_listed_devices
+ ## persistence files in the live-media partition can then be used (but note warning above)
+
+ if cat /proc/cmdline|grep -q " persistence" && [ -n "${custom_mountmode}" ]; then
+ black_listed_devices=""
+ fi
+
+## PATCH end
+
+
for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}")
do
local result luks_device
Reply to: