diff options
Diffstat (limited to 'modules.d/90mgalive')
-rwxr-xr-x | modules.d/90mgalive/mgalive-root.sh | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/modules.d/90mgalive/mgalive-root.sh b/modules.d/90mgalive/mgalive-root.sh index 347c676..e5dd177 100755 --- a/modules.d/90mgalive/mgalive-root.sh +++ b/modules.d/90mgalive/mgalive-root.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/sh . /lib/dracut-lib.sh @@ -54,25 +54,40 @@ else overlay=$livedev$overlay fi +# If the base device is partitioned (i.e. it's a USB stick, not a DVD), get the +# device name and start offset of the first partition. This is the protective +# partition covering the iso9660 filesystem. +if [ $livedev = $basedev ] ; then + ps=0 + case $basedev in + /dev/sd*) + test -b ${basedev}1 && livedev=${basedev}1 && ps=$(partx -go START $livedev) + ;; + /dev/mmblk*) + test -b ${basedev}p1 && livedev=${basedev}p1 && ps=$(partx -go START $livedev) + ;; + esac +else + ps=$(partx -go START $livedev) +fi + info "mgalive basedev is $basedev" info "mgalive livedev is $livedev" info "mgalive basedir is $basedir/" info "mgalive overlay is $overlay" media=$livedev -if [ $livedev = $basedev ] ; then - ps=0 -else - ps=$(partx -go START $livedev) -fi + if [ $ps -ne 0 ] ; then if strstr "$(blkid $basedev)" "iso9660" ; then # This happens when we boot from a USB stick with a isohybrid partition # scheme where the first sector is unclaimed, so the first partition starts # at sector 1. The iso9660 filesystem starts at sector 0, so blkid doesn't - # detect a valid filesystem in the first partition. udev, however, links + # detect a valid filesystem in the first partition. In the past, udev linked # the entry in /dev/disk/by-label to the first partition, not to the raw - # device, and that is what we get passed in $1 (mga#3334). + # device, and that is what we got passed in $1 (mga#3334). More recently, + # udev links it to the base device (mga#27629). The preceding tests ensure + # we handle both cases. if [ -n "$overlay" ] ; then # If we mount the raw device, we can't then also mount a partition # on that device. So to enable persistence, we need to extend the @@ -91,7 +106,7 @@ if [ $ps -ne 0 ] ; then media=$basedev fi else - info "$livedev does not contain a valid filesystem" + info "$basedev does not contain a valid filesystem" fi fi |