You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.9 KiB

From 70b7ec9492f950bcfb6f390c58ad6e3e2b8fda9c Mon Sep 17 00:00:00 2001
From: Fabian Deutsch <fabiand@fedoraproject.org>
Date: Thu, 19 Feb 2015 10:09:14 +0100
Subject: [PATCH] dmsquash: Add squashfs support to rd.live.fsimg
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 | 9 ++++
modules.d/90dmsquash-live/dmsquash-live-root.sh | 64 +++++++++++++------------
2 files changed, 42 insertions(+), 31 deletions(-)
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
index 0c3bc295..1e89bd50 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -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
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index 12354f42..64abc0be 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -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