From a90330d1814e42c0b4f90e953dd26f75cae3a508 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Wed, 9 Mar 2016 14:00:30 +0100 Subject: Add preliminary support for booting a Live ISO image in your filesystem. Boot parameter "livemedia=" has been expanded; Generic syntax for explicitly defining your live media: livemedia=/dev/sdX The syntax for pointing the initrd to an ISO image of Slackware Live Edition instead of a partition or DVD media expands on the above: livemedia=/dev/sdX:/path/to/slackwarelive.iso Note: this functionality is yet untested ;-) --- liveinit | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'liveinit') diff --git a/liveinit b/liveinit index f043c7e..315ec52 100755 --- a/liveinit +++ b/liveinit @@ -110,7 +110,12 @@ for ARG in $(cat /proc/cmdline); do LIVEMAIN=$(echo $ARG | cut -f2 -d=) ;; livemedia=*) - LIVEMEDIA=$(echo $ARG | cut -f2 -d=) + # generic syntax: livemedia=/dev/sdX + # ISO syntax: livemedia=/dev/sdX:/path/to/slackwarelive.iso + LM=$(echo $ARG | cut -f2 -d=) + LIVEMEDIA=$(echo $LM | cut -f1 -d:) + LIVEPATH=$(echo $LM | cut -f2 -d:) + unset LM ;; livepw=*) LIVEPW=$(echo $ARG | cut -f2 -d=) @@ -375,16 +380,31 @@ if [ "$RESCUE" = "" ]; then if [ ! -b "$LIVEMEDIA" ]; then # Passed a UUID or LABEL? LIVEALL=$(findfs UUID=$LIVEMEDIA 2>/dev/null) || LIVEALL=$(findfs LABEL=$LIVEMEDIA 2>/dev/null) - if [ -z "$LIVEALL" ]; then - echo "${MARKER}: Live media '$LIVEMEDIA' not found... trouble ahead." - else - LIVEMEDIA="$LIVEALL" - fi + LIVEMEDIA="$LIVEALL" else LIVEALL="$LIVEMEDIA" fi - LIVEFS=$(blkid $LIVEMEDIA |rev |cut -d'"' -f2 |rev) - mount -t $LIVEFS -o ro $LIVEMEDIA /mnt/media + if [ -z "$LIVEALL" ]; then + echo "${MARKER}: Live media '$LIVEMEDIA' not found... trouble ahead." + else + if [ -n "$LIVEPATH" -a "$LIVEPATH" != "$LIVEMEDIA" ]; then + # Boot option used: "livemedia=/dev/sdX:/path/to/live.iso", + # instead of just "livemedia=/dev/sdX". + # First mount the partition and then loopmount the ISO: + SUPERMNT=/mnt/super_$(od -An -N1 -tu1 /dev/urandom |tr -d ' ') + mkdir -p ${SUPERMNT} + SUPERFS=$(blkid $LIVEMEDIA |rev |cut -d'"' -f2 |rev) + mount -t $SUPERFS -o ro $LIVEMEDIA ${SUPERMNT} + if [ -f "${SUPERMNT}/$LIVEPATH" ]; then + LIVEFS=$(blkid "${SUPERMNT}/$LIVEPATH" |rev |cut -d'"' -f2 |rev) + LIVEALL="${SUPERMNT}/$LIVEPATH" + LIVEMEDIA="$LIVEALL" + MOUNTOPTS="loop" + fi + fi + LIVEFS=$(blkid $LIVEMEDIA |rev |cut -d'"' -f2 |rev) + mount -t $LIVEFS -o ${MOUNTOPTS:-ro} $LIVEMEDIA /mnt/media + fi fi # Finished determining the media availability, it should be mounted now. -- cgit v1.2.3