summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2018-07-27 22:19:39 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2018-07-27 22:19:39 +0100
commitc21aa7c1422830bf5b556d680fad26f452d90503 (patch)
treec2ab9d7756b2629fc101aa27add7648c37be4b38
parentafe8c649e0fc33fe839950e6e77e48c953e5e19d (diff)
downloaddraklive-config-c21aa7c1422830bf5b556d680fad26f452d90503.tar
draklive-config-c21aa7c1422830bf5b556d680fad26f452d90503.tar.gz
draklive-config-c21aa7c1422830bf5b556d680fad26f452d90503.tar.bz2
draklive-config-c21aa7c1422830bf5b556d680fad26f452d90503.tar.xz
draklive-config-c21aa7c1422830bf5b556d680fad26f452d90503.zip
Add support for multi-boot USB sticks (requested by several users).
-rw-r--r--config/live.cfg3
-rwxr-xr-xfiles/mgalive-parse.sh31
-rwxr-xr-xfiles/mgalive-root.sh81
3 files changed, 115 insertions, 0 deletions
diff --git a/config/live.cfg b/config/live.cfg
index 30cce52..15a4344 100644
--- a/config/live.cfg
+++ b/config/live.cfg
@@ -73,6 +73,9 @@ my $_l = {
[ 'files/live.modprobe.CD', '/etc/modprobe.d/live.conf', { mode => 0644, no_install => 1 } ],
# live media specific initrd
[ 'files/live-dracut.conf', '/etc/dracut.conf.d/60-live.conf', { mode => 0644, no_install => 1 } ],
+ #- use mga7 dracut modules to support multi-boot USB sticks
+ [ 'files/mgalive-parse.sh', '/usr/lib/dracut/modules.d/90mgalive/mgalive-parse.sh', { mode => 0755 } ],
+ [ 'files/mgalive-root.sh', '/usr/lib/dracut/modules.d/90mgalive/mgalive-root.sh', { mode => 0755 } ],
),
#- disable first boot wizard at live boot
[ 'files/firstboot', '/etc/sysconfig/firstboot', { mode => 0644 } ],
diff --git a/files/mgalive-parse.sh b/files/mgalive-parse.sh
new file mode 100755
index 0000000..c5225ba
--- /dev/null
+++ b/files/mgalive-parse.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# live images are specified with
+# root=mgalive:backingdev
+
+[ -z "$root" ] && root=$(getarg root=)
+
+if [ "${root%%:*}" = "mgalive" ] ; then
+ liveroot=$root
+fi
+
+[ "${liveroot%%:*}" = "mgalive" ] || return
+
+modprobe -q loop
+
+case "$liveroot" in
+ mgalive:LABEL=*|LABEL=*) \
+ root="${root#mgalive:}"
+ root="$(echo $root | sed 's,/,\\x2f,g')"
+ root="mgalive:/dev/disk/by-label/${root#LABEL=}"
+ rootok=1 ;;
+ mgalive:UUID=*|UUID=*) \
+ root="${root#mgalive:}"
+ root="mgalive:/dev/disk/by-uuid/${root#UUID=}"
+ rootok=1 ;;
+esac
+info "root was $liveroot, is now $root"
+
+# make sure that init doesn't complain
+[ -z "$root" ] && root="mgalive"
+
+wait_for_dev /live/union
diff --git a/files/mgalive-root.sh b/files/mgalive-root.sh
new file mode 100755
index 0000000..5eb387b
--- /dev/null
+++ b/files/mgalive-root.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+. /lib/dracut-lib.sh
+
+[ -f /tmp/root.info ] && . /tmp/root.info
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+[ -z "$1" ] && exit 1
+livedev="$1"
+
+# Create the live tree
+mkdir -m 0755 -p /live/distrib
+mkdir -m 0755 -p /live/media
+mkdir -m 0755 -p /live/overlay
+mkdir -m 0755 -p /live/union
+mkdir -m 0755 -p /run/mgalive/ovlsize
+
+# Get the base device name
+basedev=$(echo $livedev | sed 's,\(/dev/sd[a-z]\)1,\1,g')
+
+# Get the base directory for locating the loopback file. In normal use this is
+# the root directory, but a multi-boot USB stick may want to override this.
+basedir=$(getarg mgalive.basedir)
+
+# Get the device or path used for persistant storage (if it exists). In normal
+# use this is another partition on the same base device, but a multi-boot USB
+# stick may want to override this.
+overlay=$(getarg mgalive.overlay)
+if [ -z "$overlay" ] ; then
+ 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"
+
+# Mount the live media
+mount -n -o ro $media /live/media
+
+# Mount the loopback filesystem
+LOOPDEV=$( losetup -f )
+if [ -e /live/media$basedir/loopbacks/distrib-lzma.sqfs ] ; then
+ # Retain support for the original draklive. Note that despite the file
+ # name, it uses xz compression.
+ losetup -r $LOOPDEV /live/media$basedir/loopbacks/distrib-lzma.sqfs
+else
+ losetup -r $LOOPDEV /live/media$basedir/loopbacks/distrib.sqfs
+fi
+mount -n -t squashfs -o ro $LOOPDEV /live/distrib
+mount -n -t squashfs -o ro $LOOPDEV /run/mgalive/ovlsize
+
+# Mount the overlay filesystem
+if [ -z "$overlay" ] ; then
+ mount -n -t tmpfs -o mode=755 none /live/overlay
+else
+ mount -n -o noatime $overlay /live/overlay
+fi
+# work and memory must be on same root
+mkdir -m 0755 -p /live/overlay/work
+mkdir -m 0755 -p /live/overlay/memory
+mount -n -t overlay overlay -o lowerdir=/live/distrib,upperdir=/live/overlay/memory,workdir=/live/overlay/work,noatime /live/union
+
+ln -s /live/union /dev/root
+
+printf '/bin/mount --rbind /live/union %s\n' "$NEWROOT" > $hookdir/mount/01-$$-live.sh
+
+need_shutdown
+
+exit 0