summaryrefslogtreecommitdiffstats
path: root/modules.d/90mgalive
diff options
context:
space:
mode:
authorJybz <j.biernacki@free.fr>2024-04-20 22:22:14 +0200
committerJybz <j.biernacki@free.fr>2024-04-20 22:22:14 +0200
commit0cee55d5a1b60cc67a623f0b107a950633ed72fc (patch)
tree0409eac762f993a6d3f2c8d8352701cbcd2ebf10 /modules.d/90mgalive
parente1d603a423da93d2f3aed511cbec8482bd4a1eec (diff)
downloadmageia-dracut-conf-0cee55d5a1b60cc67a623f0b107a950633ed72fc.tar
mageia-dracut-conf-0cee55d5a1b60cc67a623f0b107a950633ed72fc.tar.gz
mageia-dracut-conf-0cee55d5a1b60cc67a623f0b107a950633ed72fc.tar.bz2
mageia-dracut-conf-0cee55d5a1b60cc67a623f0b107a950633ed72fc.tar.xz
mageia-dracut-conf-0cee55d5a1b60cc67a623f0b107a950633ed72fc.zip
Updated to support encrypted persistent partition and fix mga#25924.
- origin: https://svnweb.mageia.org/packages/cauldron/dracut/current/SOURCES/0511-mgalive-A-module-to-mount-Mageia-Live-media.patch?r1=1368035&r2=1469756 - mgalive: support encrypted persistent partitions (mga#25191) - mgalive: fix boot failure on some machines (mga#25924)
Diffstat (limited to 'modules.d/90mgalive')
-rwxr-xr-xmodules.d/90mgalive/mgalive-root.sh25
1 files changed, 22 insertions, 3 deletions
diff --git a/modules.d/90mgalive/mgalive-root.sh b/modules.d/90mgalive/mgalive-root.sh
index 9d3f86a..8991749 100755
--- a/modules.d/90mgalive/mgalive-root.sh
+++ b/modules.d/90mgalive/mgalive-root.sh
@@ -2,6 +2,12 @@
. /lib/dracut-lib.sh
+can_decrypt=0
+if [ -f /lib/dracut-crypt-lib.sh ] ; then
+ . /lib/dracut-crypt-lib.sh
+ can_decrypt=1
+fi
+
[ -f /tmp/root.info ] && . /tmp/root.info
PATH=/usr/sbin:/usr/bin:/sbin:/bin
@@ -21,6 +27,19 @@ basedev=$(echo $livedev | sed -e 's,\(/dev/sd[a-z]\)1,\1,g' -e 's,\(/dev/mmcblk[
# Make it available to draklive-install and mgalive-shutdown
echo $basedev > /run/mgalive/basedev
+# Unlock any encrypted partitions on the base device
+if [ $can_decrypt -eq 1 ] ; then
+ for dev in $(blkid -t TYPE=crypto_LUKS -o device | grep $basedev) ; do
+ ask_for_password \
+ --ply-cmd "cryptsetup open -T1 $dev crypt_${dev##/dev/}" \
+ --ply-prompt "Password ($dev)" \
+ --ply-tries 3 \
+ --tty-cmd "cryptsetup open -T3 $dev crypt_${dev##/dev/}" \
+ --tty-tries 1
+ done
+fi
+
+
# 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)
@@ -30,7 +49,7 @@ 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'\|'/dev/mapper)
else
overlay=$livedev$overlay
fi
@@ -41,7 +60,8 @@ info "mgalive basedir is $basedir/"
info "mgalive overlay is $overlay"
media=$livedev
-if [ -z "$(blkid $livedev)" ] ; then
+ps=$(partx -go START $livedev)
+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
@@ -53,7 +73,6 @@ if [ -z "$(blkid $livedev)" ] ; 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"