From d5c3fad34e0dcada728c58011c86414a3e9bd748 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Sun, 14 Feb 2016 23:16:18 +0100 Subject: liveinit: do not give the OS access to the Live media if "toram" was specified. If we mounted the media partition in the Live OS, an I/O error will be the result when the user removes the boot media from the computer. --- liveinit | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'liveinit') diff --git a/liveinit b/liveinit index 262c549..9ec6fef 100755 --- a/liveinit +++ b/liveinit @@ -446,8 +446,20 @@ if [ "$RESCUE" = "" ]; then prdir=${PERSISTENCE}_$(od -An -N1 -tu1 /dev/urandom |tr -d ' ') mkdir -p /mnt/live/${prdir} losetup $prdev /mnt/media/${PERSISTENCE}.img + # Check if the persistence container is LUKS encrypted: + if cryptsetup isLuks $prdev 1>/dev/null 2>/dev/null ; then + echo "Unlocking LUKS encrypted persistence file '/${PERSISTENCE}.img'" + cryptsetup luksOpen $prdev ${PERSISTENCE} /dev/tty0 2>&1 + if [ $? -ne 0 ]; then + echo "${MARKER}: Failed to unlock persistence file '/${PERSISTENCE}.img'." + echo "${MARKER}: Falling back to RAM." + else + # LUKS properly unlocked; from now on use the mapper device instead: + prdev=/dev/mapper/${PERSISTENCE} + fi + fi prfs=$(blkid $prdev |rev |cut -d'"' -f2 |rev) - mount -t $prfs $prdev /mnt/live/${prdir} + mount -t $prfs $prdev /mnt/live/${prdir} 2>/dev/null if [ $? -ne 0 ]; then echo "${MARKER}: Failed to mount persistence file '/${PERSISTENCE}.img'." echo "${MARKER}: Falling back to RAM." @@ -490,9 +502,11 @@ if [ "$RESCUE" = "" ]; then mkdir -p /mnt/overlay/mnt/live mount --bind /mnt/live /mnt/overlay/mnt/live - # Same for the Linux filesystem on the USB stick: - mkdir -p /mnt/overlay/mnt/livemedia - mount --bind /mnt/media /mnt/overlay/mnt/livemedia + if [ $TORAM -eq 0 ]; then + # Same for the Linux filesystem on the USB stick: + mkdir -p /mnt/overlay/mnt/livemedia + mount --bind /mnt/media /mnt/overlay/mnt/livemedia + fi if [ ! -z "$USE_SWAP" ]; then # Use any available swap device: -- cgit v1.2.3