diff options
Diffstat (limited to 'modules.d')
-rwxr-xr-x | modules.d/90mgalive/mgalive-root.sh | 42 | ||||
-rwxr-xr-x | modules.d/90mgalive/module-setup.sh | 1 |
2 files changed, 34 insertions, 9 deletions
diff --git a/modules.d/90mgalive/mgalive-root.sh b/modules.d/90mgalive/mgalive-root.sh index 77a34bd..e0fd882 100755 --- a/modules.d/90mgalive/mgalive-root.sh +++ b/modules.d/90mgalive/mgalive-root.sh @@ -30,24 +30,48 @@ basedir=$(getarg mgalive.basedir) # stick may want to override this. overlay=$(getarg mgalive.overlay) if [ -z "$overlay" ] ; then - overlay=`blkid -t LABEL=mgalive-persist -o device | grep $basedev` + overlay=$(blkid -t LABEL=mgalive-persist -o device | grep $basedev) else overlay=$livedev$overlay fi -if [ -z "$basedir" -a -z "$overlay" ] ; then - # Fix udev isohybrid LABEL issues (mga #3334) - # (things have moved on - this may not be needed now) - media=$basedev -else - media=$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 [ -z "$(blkid $livedev)" ] ; 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 + # 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). + 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 + # first partition to claim the full range of the iso9660 filesystem. + ps=$(partx -go START $livedev) + pe=$(partx -go END $livedev) + if [ $ps -eq 1 ] ; then + info "Extending $livedev to cover sector 0" + delpart $basedev 1 + addpart $basedev 1 0 $pe + else + info "$livedev is not a valid protective partition" + fi + else + # If we don't have a persistent partition, take the easy option. + info "Using $basedev to mount the iso9660 filesystem" + media=$basedev + fi + else + info "$livedev does not contain a valid filesystem" + fi +fi + # Mount the live media mount -n -o ro $media /live/media diff --git a/modules.d/90mgalive/module-setup.sh b/modules.d/90mgalive/module-setup.sh index b8f3f8d..260f4e8 100755 --- a/modules.d/90mgalive/module-setup.sh +++ b/modules.d/90mgalive/module-setup.sh @@ -16,6 +16,7 @@ installkernel() { install() { inst_multiple blkid clear eject grep losetup umount + inst_multiple addpart delpart partx inst_hook cmdline 30 "$moddir/mgalive-parse.sh" inst_hook pre-udev 30 "$moddir/mgalive-genrules.sh" |