]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dmsquash: Add squashfs support to rd.live.fsimg
authorFabian Deutsch <fabiand@fedoraproject.org>
Thu, 19 Feb 2015 09:09:14 +0000 (10:09 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 2 Jul 2015 17:47:46 +0000 (19:47 +0200)
Previously rd.live.fsimg only supported filesystems residing in
(compressed) archives.
Now rd.live.fsimg can also be used when a squashfs image is used.
This is achieved by extracting the rootfs image from the squashfs and
then continue with the default routines for rd.live.fsimg.
In addition some code duplication got removed and some documentation
got added.

Signed-off-by: Fabian Deutsch <fabiand@fedoraproject.org>
(cherry picked from commit b0472eac111268e2cae783097d0eccc1986e1762)

dracut.cmdline.7.asc
modules.d/90dmsquash-live/dmsquash-live-root.sh

index 0c3bc29576ac02cf9cbdffc0f23b6e41e2aea363..1e89bd50f878f2604df9a25f4305eb98ef37ea51 100644 (file)
@@ -802,6 +802,10 @@ Enables debug output from the live boot process.
 Specifies the directory within the squashfs where the ext3fs.img or rootfs.img
 can be found.  By default, this is __LiveOS__.
 
+**rd.live.ram=**1::
+Copy the complete image to RAM and use this for booting. This is useful
+when the image resides on i.e. a DVD which needs to be ejected later on.
+
 **rd.live.overlay.thin=**1::
 Enables the usage of thin snapshots instead of classic dm snapshots.
 The advantage of thin snapshots is, that they support discards, and will free
@@ -814,6 +818,11 @@ Enables writable filesystem support.  The system will boot with a fully
 writable filesystem without snapshots __(see notes above about available live boot options)__.
 You can use the **rootflags** option to set mount options for the live
 filesystem as well __(see documentation about rootflags in the **Standard** section above)__.
+This implies that the whole image is copied to RAM before the boot continues.
++
+NOTE: There must be enough free RAM available to hold the complete image.
++
+This method is very suitable for diskless boots.
 
 
 Plymouth Boot Splash
index 12354f42312ef902c1b3972893e0620177948b81..64abc0be1087dd40e7d5f38bb4fd88d6a8563c22 100755 (executable)
@@ -148,6 +148,7 @@ do_live_overlay() {
         base=$BASE_LOOPDEV
         over=$OVERLAY_LOOPDEV
     fi
+
     if [ -n "$thin_snapshot" ]; then
         modprobe dm_thin_pool
         mkdir /run/initramfs/thin-overlay
@@ -199,29 +200,6 @@ if [ -n "$OSMINSQFS" ]; then
     umount -l /run/initramfs/squashfs.osmin
 fi
 
-# we might have an embedded fs image to use as rootfs (uncompressed live)
-if [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then
-    FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img"
-elif [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then
-    FSIMG="/run/initramfs/live/${live_dir}/rootfs.img"
-fi
-
-if [ -n "$FSIMG" ] ; then
-    BASE_LOOPDEV=$( losetup -f )
-
-    if [ -n "$writable_fsimg" ] ; then
-        # mount the provided fileysstem read/write
-        echo "Unpacking live filesystem (may take some time)"
-        unpack_archive $FSIMG /run/initramfs/fsimg/
-        losetup $BASE_LOOPDEV /run/initramfs/fsimg/rootfs.img
-        echo "0 $( blockdev --getsize $BASE_LOOPDEV ) linear $BASE_LOOPDEV 0" | dmsetup create live-rw
-    else
-        # mount the filesystem read-only and add a dm snapshot for writes
-        losetup -r $BASE_LOOPDEV $FSIMG
-        do_live_from_base_loop
-    fi
-fi
-
 # we might have an embedded fs image on squashfs (compressed live)
 if [ -e /run/initramfs/live/${live_dir}/${squash_image} ]; then
     SQUASHED="/run/initramfs/live/${live_dir}/${squash_image}"
@@ -242,18 +220,42 @@ if [ -e "$SQUASHED" ] ; then
     mkdir -m 0755 -p /run/initramfs/squashfs
     mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs
 
-    BASE_LOOPDEV=$( losetup -f )
-    if [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
-        losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/ext3fs.img
-    elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
-        losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/rootfs.img
-    fi
+fi
+
+# we might have an embedded fs image to use as rootfs (uncompressed live)
+if [ -e /run/initramfs/live/${live_dir}/ext3fs.img ]; then
+    FSIMG="/run/initramfs/live/${live_dir}/ext3fs.img"
+elif [ -e /run/initramfs/live/${live_dir}/rootfs.img ]; then
+    FSIMG="/run/initramfs/live/${live_dir}/rootfs.img"
+elif [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then
+    FSIMG="/run/initramfs/squashfs/LiveOS/ext3fs.img"
+elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then
+    FSIMG="/run/initramfs/squashfs/LiveOS/rootfs.img"
+fi
 
-    umount -l /run/initramfs/squashfs
+if [ -n "$FSIMG" ] ; then
+    BASE_LOOPDEV=$( losetup -f )
 
-    do_live_from_base_loop
+    if [ -n "$writable_fsimg" ] ; then
+        # mount the provided fileysstem read/write
+        echo "Unpacking live filesystem (may take some time)"
+        mkdir /run/initramfs/fsimg/
+        if [ -n "$SQUASHED" ]; then
+            cp -v $FSIMG /run/initramfs/fsimg/rootfs.img
+        else
+            unpack_archive $FSIMG /run/initramfs/fsimg/
+        fi
+        losetup $BASE_LOOPDEV /run/initramfs/fsimg/rootfs.img
+        echo "0 $( blockdev --getsize $BASE_LOOPDEV ) linear $BASE_LOOPDEV 0" | dmsetup create live-rw
+    else
+        # mount the filesystem read-only and add a dm snapshot for writes
+        losetup -r $BASE_LOOPDEV $FSIMG
+        do_live_from_base_loop
+    fi
 fi
 
+[ -e "$SQUASHED" ] && umount -l /run/initramfs/squashfs
+
 if [ -b "$OSMIN_LOOPDEV" ]; then
     # set up the devicemapper snapshot device, which will merge
     # the normal live fs image, and the delta, into a minimzied fs image