summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJybz <j.biernacki@free.fr>2024-04-20 21:42:04 +0200
committerJybz <j.biernacki@free.fr>2024-04-20 21:42:04 +0200
commite60aeb60f161acf73a01bc1c21fcebcf04408b06 (patch)
tree1332ad1eadbd81beb993884fd1d90010245c6b1f
parent1ed60d25874839c7cc477210754ffd752c2cd797 (diff)
downloadmageia-dracut-conf-e60aeb60f161acf73a01bc1c21fcebcf04408b06.tar
mageia-dracut-conf-e60aeb60f161acf73a01bc1c21fcebcf04408b06.tar.gz
mageia-dracut-conf-e60aeb60f161acf73a01bc1c21fcebcf04408b06.tar.bz2
mageia-dracut-conf-e60aeb60f161acf73a01bc1c21fcebcf04408b06.tar.xz
mageia-dracut-conf-e60aeb60f161acf73a01bc1c21fcebcf04408b06.zip
mgalive: support persistence when isohybrid protective partition starts at sector 1
- origin: https://svnweb.mageia.org/packages/cauldron/dracut/current/SOURCES/0511-mgalive-A-module-to-mount-Mageia-Live-media.patch?r1=1326566&r2=1329441 - mgalive: support persistence when isohybrid protective partition starts at sector 1 - mgalive: fix boot when ISO is copied into USB stick partition (e.g. by Rufus)
-rwxr-xr-xmodules.d/90mgalive/mgalive-root.sh42
-rwxr-xr-xmodules.d/90mgalive/module-setup.sh1
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"