]> 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, 19 Feb 2015 09:59:54 +0000 (10:59 +0100)
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>
dracut.cmdline.7.asc
modules.d/90dmsquash-live/dmsquash-live-root.sh

index 9ddad0f36d9eec3c537de9ad3236128feb25c0d9..e51fd1b7a4f8cbdd7c82de979e251f7cc7f1fa06 100644 (file)
@@ -834,6 +834,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
@@ -846,6 +850,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 45f724cbdc089d3c3ed6fcd735a096d0a0b42e53..b632f6a41e1ee82fc98ccd405d4ce4845821218a 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