From 245782034beafe9db0aee6c27a9d5abd075b64c6 Mon Sep 17 00:00:00 2001 From: Thomas Backlund Date: Sat, 19 Oct 2013 19:27:20 +0100 Subject: mgalive: A module to mount Mageia Live media Updated to work with overlay from 3.19 Signed-off-by: Thomas Backlund --- modules.d/90mgalive/mgalive-genrules.sh | 18 +++++++++++++ modules.d/90mgalive/mgalive-parse.sh | 27 +++++++++++++++++++ modules.d/90mgalive/mgalive-root.sh | 48 +++++++++++++++++++++++++++++++++ modules.d/90mgalive/module-setup.sh | 26 ++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100755 modules.d/90mgalive/mgalive-genrules.sh create mode 100755 modules.d/90mgalive/mgalive-parse.sh create mode 100755 modules.d/90mgalive/mgalive-root.sh create mode 100755 modules.d/90mgalive/module-setup.sh (limited to 'modules.d') diff --git a/modules.d/90mgalive/mgalive-genrules.sh b/modules.d/90mgalive/mgalive-genrules.sh new file mode 100755 index 0000000..f450ebf --- /dev/null +++ b/modules.d/90mgalive/mgalive-genrules.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +case "$root" in + mgalive:/dev/*) + { + printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/mgalive-root $env{DEVNAME}"\n' \ + ${root#mgalive:/dev/} + printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/mgalive-root $env{DEVNAME}"\n' \ + ${root#mgalive:/dev/} + } >> /etc/udev/rules.d/99-mgalive.rules + wait_for_dev "${root#mgalive:}" + ;; + mgalive:*) + if [ -f "${root#mgalive:}" ]; then + /sbin/initqueue --settled --onetime --unique /sbin/mgalive-root "${root#mgalive:}" + fi + ;; +esac diff --git a/modules.d/90mgalive/mgalive-parse.sh b/modules.d/90mgalive/mgalive-parse.sh new file mode 100755 index 0000000..7952957 --- /dev/null +++ b/modules.d/90mgalive/mgalive-parse.sh @@ -0,0 +1,27 @@ +#!/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 ;; +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/modules.d/90mgalive/mgalive-root.sh b/modules.d/90mgalive/mgalive-root.sh new file mode 100755 index 0000000..1a36c70 --- /dev/null +++ b/modules.d/90mgalive/mgalive-root.sh @@ -0,0 +1,48 @@ +#!/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 live tree +mkdir -m 0755 -p /live/distrib +mkdir -m 0755 -p /live/media +mkdir -m 0755 -p /live/tmpfs +mkdir -m 0755 -p /live/union +mkdir -m 0755 -p /run/mgalive/ovlsize + +# fix udev isohybrid LABEL issues (mga #3334) +# by reading the device we get, stripping away partition number, +# and mount the resulting device +realdev=$(echo $livedev |sed 's,\(/dev/sd[a-z]\)1,\1,g') + +# mount the live media +getargbool 0 UEFI && liveuefi="yes" +if [ -n "$liveuefi" ]; then + mount -n -t vfat -o ro $livedev /live/media +else + mount -n -t iso9660 -o ro $realdev /live/media +fi + +LOOPDEV=$( losetup -f ) +losetup -r $LOOPDEV /live/media/loopbacks/distrib-lzma.sqfs +mount -n -t squashfs -o ro $LOOPDEV /live/distrib +mount -n -t squashfs -o ro $LOOPDEV /run/mgalive/ovlsize +mount -n -t tmpfs -o mode=755 /live/tmpfs /live/tmpfs +# work and memory must be on same root +mkdir -m 0755 -p /live/tmpfs/work +mkdir -m 0755 -p /live/tmpfs/memory +mount -n -t overlay overlay -o lowerdir=/live/distrib,upperdir=/live/tmpfs/memory,workdir=/live/tmpfs/work /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 diff --git a/modules.d/90mgalive/module-setup.sh b/modules.d/90mgalive/module-setup.sh new file mode 100755 index 0000000..99be401 --- /dev/null +++ b/modules.d/90mgalive/module-setup.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +check() { + # a live host-only image doesn't really make a lot of sense + [[ $hostonly ]] && return 1 + return 255 +} + +depends() { + return 0 +} + +installkernel() { + instmods squashfs loop overlay +} + +install() { + inst_multiple umount dmsetup blkid dd losetup grep blockdev + inst_multiple -o eject + + inst_hook cmdline 30 "$moddir/mgalive-parse.sh" + inst_hook pre-udev 30 "$moddir/mgalive-genrules.sh" + inst "$moddir/mgalive-root.sh" "/sbin/mgalive-root" + # should probably just be generally included + inst_rules 60-cdrom_id.rules +} -- cgit v1.2.1