diff options
author | Eric Hameleers <alien@slackware.com> | 2016-02-14 23:16:18 +0100 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2016-02-14 23:16:18 +0100 |
commit | d5c3fad34e0dcada728c58011c86414a3e9bd748 (patch) | |
tree | cb1df2d766dca2ef50b2159eaef877fd8b1181c2 | |
parent | 49346f3cd4efcb1a9ffca4f6fd4eb33fe52fb493 (diff) | |
download | liveslak-d5c3fad34e0dcada728c58011c86414a3e9bd748.tar.gz liveslak-d5c3fad34e0dcada728c58011c86414a3e9bd748.tar.xz |
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.
Diffstat (limited to '')
-rwxr-xr-x | liveinit | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -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 >/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: |