From b29a98a3574573958d27cf7b46c9f780bf9ee557 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Wed, 19 Jul 2017 23:03:53 +0200 Subject: Allow syntax 'livemedia=scandev:/path/to/live.iso' Use the 'scandev' keyword instead of specifying an actual partition name if you want liveslak to scan all partitions for the ISO. Use this if you are not sure of the devicename and have no means of figuring it out. --- liveinit.tpl | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'liveinit.tpl') diff --git a/liveinit.tpl b/liveinit.tpl index e20eb61..66af4d6 100755 --- a/liveinit.tpl +++ b/liveinit.tpl @@ -601,7 +601,7 @@ if [ "$RESCUE" = "" ]; then sleep 1 else # LIVEMEDIA was specified on the boot commandline using "livemedia=" - if [ ! -b "$LIVEMEDIA" ]; then + if [ "$LIVEMEDIA" != "scandev" -a ! -b "$LIVEMEDIA" ]; then # Passed a UUID or LABEL? LIVEALL=$(findfs UUID=$LIVEMEDIA 2>/dev/null) || LIVEALL=$(findfs LABEL=$LIVEMEDIA 2>/dev/null) LIVEMEDIA="$LIVEALL" @@ -613,10 +613,36 @@ if [ "$RESCUE" = "" ]; then else if [ -n "$LIVEPATH" -a "$LIVEPATH" != "$LIVEMEDIA" ]; then # Boot option used: "livemedia=/dev/sdX:/path/to/live.iso", - # instead of just "livemedia=/dev/sdX". + # or: "livemedia=scandev:/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} + # + if [ "$LIVEMEDIA" = "scandev" ]; then + # Scan partitions to find the one with the ISO and set LIVEMEDIA: + echo "${MARKER}: Scanning for '$LIVEPATH'..." + for ISOPART in $(blkid |cut -d: -f1 |grep "[0-9]$") $(blkid |cut -d: -f1 |grep -v "[0-9]$") ; do + PARTFS=$(blkid $ISOPART |rev |cut -d'"' -f2 |rev) + # Abuse the $SUPERMNT a bit, we will actually use it later: + mount -t $PARTFS -o ro $ISOPART ${SUPERMNT} + if [ -f ${SUPERMNT}/${LIVEPATH} ]; then + # Found our ISO! + LIVEMEDIA=$ISOPART + umount $ISOPART + unset ISOPART + break + else + umount $ISOPART + fi + done + if [ -n "$ISOPART" ]; then + echo "${MARKER}: Partition scan unable to find ISO, trouble ahead." + fi + fi + # At this point we know $LIVEMEDIA - either because the bootparameter + # specified it or else because the 'scandev' found it for us: SUPERFS=$(blkid $LIVEMEDIA |rev |cut -d'"' -f2 |rev) mount -t $SUPERFS -o ro $LIVEMEDIA ${SUPERMNT} if [ -f "${SUPERMNT}/$LIVEPATH" ]; then -- cgit v1.2.3