Blame SOURCES/0262-dmsquash-Add-squashfs-support-to-rd.live.fsimg.patch

712866
From 70b7ec9492f950bcfb6f390c58ad6e3e2b8fda9c Mon Sep 17 00:00:00 2001
712866
From: Fabian Deutsch <fabiand@fedoraproject.org>
712866
Date: Thu, 19 Feb 2015 10:09:14 +0100
712866
Subject: [PATCH] dmsquash: Add squashfs support to rd.live.fsimg
712866
712866
Previously rd.live.fsimg only supported filesystems residing in
712866
(compressed) archives.
712866
Now rd.live.fsimg can also be used when a squashfs image is used.
712866
This is achieved by extracting the rootfs image from the squashfs and
712866
then continue with the default routines for rd.live.fsimg.
712866
In addition some code duplication got removed and some documentation
712866
got added.
712866
712866
Signed-off-by: Fabian Deutsch <fabiand@fedoraproject.org>
712866
(cherry picked from commit b0472eac111268e2cae783097d0eccc1986e1762)
712866
---
712866
 dracut.cmdline.7.asc                            |  9 ++++
712866
 modules.d/90dmsquash-live/dmsquash-live-root.sh | 64 +++++++++++++------------
712866
 2 files changed, 42 insertions(+), 31 deletions(-)
712866
712866
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
5c6c2a
index 0c3bc295..1e89bd50 100644
712866
--- a/dracut.cmdline.7.asc
712866
+++ b/dracut.cmdline.7.asc
712866
@@ -802,6 +802,10 @@ Enables debug output from the live boot process.
712866
 Specifies the directory within the squashfs where the ext3fs.img or rootfs.img
712866
 can be found.  By default, this is __LiveOS__.
712866
 
712866
+**rd.live.ram=**1::
712866
+Copy the complete image to RAM and use this for booting. This is useful
712866
+when the image resides on i.e. a DVD which needs to be ejected later on.
712866
+
712866
 **rd.live.overlay.thin=**1::
712866
 Enables the usage of thin snapshots instead of classic dm snapshots.
712866
 The advantage of thin snapshots is, that they support discards, and will free
712866
@@ -814,6 +818,11 @@ Enables writable filesystem support.  The system will boot with a fully
712866
 writable filesystem without snapshots __(see notes above about available live boot options)__.
712866
 You can use the **rootflags** option to set mount options for the live
712866
 filesystem as well __(see documentation about rootflags in the **Standard** section above)__.
712866
+This implies that the whole image is copied to RAM before the boot continues.
712866
++
712866
+NOTE: There must be enough free RAM available to hold the complete image.
712866
++
712866
+This method is very suitable for diskless boots.
712866
 
712866
 
712866
 Plymouth Boot Splash
712866
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
5c6c2a
index 12354f42..64abc0be 100755
712866
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
712866
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
712866
@@ -148,6 +148,7 @@ do_live_overlay() {
712866
         base=$BASE_LOOPDEV
712866
         over=$OVERLAY_LOOPDEV
712866
     fi
712866
+
712866
     if [ -n "$thin_snapshot" ]; then
712866
         modprobe dm_thin_pool
712866
         mkdir /run/initramfs/thin-overlay
712866
@@ -199,29 +200,6 @@ if [ -n "$OSMINSQFS" ]; then
712866
     umount -l /run/initramfs/squashfs.osmin
712866
 fi
712866
 
712866
-# we might have an embedded fs image to use as rootfs (uncompressed live)
712866
-if [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then
712866
-    FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img"
712866
-elif [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then
712866
-    FSIMG="/run/initramfs/live/${live_dir}/rootfs.img"
712866
-fi
712866
-
712866
-if [ -n "$FSIMG" ] ; then
712866
-    BASE_LOOPDEV=$( losetup -f )
712866
-
712866
-    if [ -n "$writable_fsimg" ] ; then
712866
-        # mount the provided fileysstem read/write
712866
-        echo "Unpacking live filesystem (may take some time)"
712866
-        unpack_archive $FSIMG /run/initramfs/fsimg/
712866
-        losetup $BASE_LOOPDEV /run/initramfs/fsimg/rootfs.img
712866
-        echo "0 $( blockdev --getsize $BASE_LOOPDEV ) linear $BASE_LOOPDEV 0" | dmsetup create live-rw
712866
-    else
712866
-        # mount the filesystem read-only and add a dm snapshot for writes
712866
-        losetup -r $BASE_LOOPDEV $FSIMG
712866
-        do_live_from_base_loop
712866
-    fi
712866
-fi
712866
-
712866
 # we might have an embedded fs image on squashfs (compressed live)
712866
 if [ -e /run/initramfs/live/${live_dir}/${squash_image} ]; then
712866
     SQUASHED="/run/initramfs/live/${live_dir}/${squash_image}"
712866
@@ -242,18 +220,42 @@ if [ -e "$SQUASHED" ] ; then
712866
     mkdir -m 0755 -p /run/initramfs/squashfs
712866
     mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs
712866
 
712866
-    BASE_LOOPDEV=$( losetup -f )
712866
-    if [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
712866
-        losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/ext3fs.img
712866
-    elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
712866
-        losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/rootfs.img
712866
-    fi
712866
+fi
712866
+
712866
+# we might have an embedded fs image to use as rootfs (uncompressed live)
712866
+if [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then
712866
+    FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img"
712866
+elif [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then
712866
+    FSIMG="/run/initramfs/live/${live_dir}/rootfs.img"
712866
+elif [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
712866
+    FSIMG="/run/initramfs/squashfs/LiveOS/ext3fs.img"
712866
+elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
712866
+    FSIMG="/run/initramfs/squashfs/LiveOS/rootfs.img"
712866
+fi
712866
 
712866
-    umount -l /run/initramfs/squashfs
712866
+if [ -n "$FSIMG" ] ; then
712866
+    BASE_LOOPDEV=$( losetup -f )
712866
 
712866
-    do_live_from_base_loop
712866
+    if [ -n "$writable_fsimg" ] ; then
712866
+        # mount the provided fileysstem read/write
712866
+        echo "Unpacking live filesystem (may take some time)"
712866
+        mkdir /run/initramfs/fsimg/
712866
+        if [ -n "$SQUASHED" ]; then
712866
+            cp -v $FSIMG /run/initramfs/fsimg/rootfs.img
712866
+        else
712866
+            unpack_archive $FSIMG /run/initramfs/fsimg/
712866
+        fi
712866
+        losetup $BASE_LOOPDEV /run/initramfs/fsimg/rootfs.img
712866
+        echo "0 $( blockdev --getsize $BASE_LOOPDEV ) linear $BASE_LOOPDEV 0" | dmsetup create live-rw
712866
+    else
712866
+        # mount the filesystem read-only and add a dm snapshot for writes
712866
+        losetup -r $BASE_LOOPDEV $FSIMG
712866
+        do_live_from_base_loop
712866
+    fi
712866
 fi
712866
 
712866
+[ -e "$SQUASHED" ] && umount -l /run/initramfs/squashfs
712866
+
712866
 if [ -b "$OSMIN_LOOPDEV" ]; then
712866
     # set up the devicemapper snapshot device, which will merge
712866
     # the normal live fs image, and the delta, into a minimzied fs image