diff options
author | Eric Hameleers <alien@slackware.com> | 2017-07-19 23:03:53 +0200 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2017-07-19 23:03:53 +0200 |
commit | b29a98a3574573958d27cf7b46c9f780bf9ee557 (patch) | |
tree | 03b8c136314f814af0d407377988544e7d151d21 /liveinit.tpl | |
parent | 7d22682ddd36a23b6c55652ba59b9a05c19a8b7a (diff) | |
download | liveslak-b29a98a3574573958d27cf7b46c9f780bf9ee557.tar.gz liveslak-b29a98a3574573958d27cf7b46c9f780bf9ee557.tar.xz |
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.
Diffstat (limited to 'liveinit.tpl')
-rwxr-xr-x | liveinit.tpl | 30 |
1 files changed, 28 insertions, 2 deletions
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 |