All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image
@ 2021-05-13 20:57 Hari Bathini
  2021-05-13 20:57 ` [PATCH 1/2] dracut: add a new argument "--squash-input-images" Hari Bathini
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hari Bathini @ 2021-05-13 20:57 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Mahesh J Salgaonkar,
	Sourabh Jain, Kairui Song, Dave Young

With the addition of modules.d/99squash module, most of the files in                               
the initramfs image can now be squash'ed. While this saves space, this                             
can also be extended further to provide support for having different                               
initramfs images built into a single image, each squash'ed separately                              
& activated based on different boot scenarios.
        
For that, introduce two dracut options. One, '--squash-input-images':                              
takes a space-separated list of input initramfs images to squash &                                 
include in the initramfs image. Patch one adds this option.                                        
        
Two, '--squash-image-conditional': takes a script file that sets up                                
the appropriate squash image for every possible boot scenario. The                                 
second patch introduces this option.

---

Hari Bathini (2):
      dracut: add a new argument "--squash-input-images"
      dracut/99squash: make sqaush image setup flexible


 dracut.sh                                     | 26 +++++++-
 modules.d/99squash/module-setup.sh            | 17 ++++-
 .../99squash/setup-squash-conditional.sh      | 65 +++++++++++++++++++
 .../99squash/squash-image-conditional.sh      |  5 ++
 4 files changed, 109 insertions(+), 4 deletions(-)
 create mode 100755 modules.d/99squash/setup-squash-conditional.sh
 create mode 100755 modules.d/99squash/squash-image-conditional.sh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] dracut: add a new argument "--squash-input-images"
  2021-05-13 20:57 [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Hari Bathini
@ 2021-05-13 20:57 ` Hari Bathini
  2021-05-13 20:57 ` [PATCH 2/2] dracut/99squash: make sqaush image setup flexible Hari Bathini
  2021-05-14  9:10 ` [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Kairui Song
  2 siblings, 0 replies; 5+ messages in thread
From: Hari Bathini @ 2021-05-13 20:57 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Mahesh J Salgaonkar,
	Sourabh Jain, Kairui Song, Dave Young

Add "squash-input-images" option to include the squash'ed image of
space-separated list of each initramfs image provided.

    Usage: dracut --squash-input-images "image1 image2"

This option can be leveraged, to include initramfs images with varying
purposes build into a single image & to activate/mount one of those
images based on specific boot condition each.

While one squash image (/squash/root.img) is already generated based
on the current dracut options, a squash image is generated for each
initramfs image provided through this new option (/squash/root0.img,
squash/root1.img, etc.).

Signed-off-by: Hari Bathini <hbathini-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>
---
 dracut.sh |  103 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 90 insertions(+), 13 deletions(-)

diff --git a/dracut.sh b/dracut.sh
index 062ed6c1..1a84a707 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -82,6 +82,14 @@ Creates initial ramdisk images for preloading modules
   -f, --force           Overwrite existing initramfs file.
   -a, --add [LIST]      Add a space-separated list of dracut modules.
   --rebuild         Append arguments to those of existing image and rebuild
+  --squash-input-images [LIST]
+                        Include the squash'ed image of space-separated list of
+                         each initramfs image provided. This option can be
+                         leveraged, to include initramfs images with varying
+                         purposes build into a single image. /squash/root0.img,
+                         /squash/root1.img, /squash/root2.img, etc., squash
+                         images are created, one each for each input initramfs
+                         image provided, in that order.
   -m, --modules [LIST]  Specify a space-separated list of dracut modules to
                          call when building the initramfs. Modules are located
                          in /usr/lib/dracut/modules.d.
@@ -373,6 +381,7 @@ rearrange_params()
         --long compress: \
         --long prefix: \
         --long rebuild: \
+        --long squash-input-images: \
         --long force \
         --long kernel-only \
         --long no-kernel \
@@ -443,6 +452,66 @@ rearrange_params()
     fi
 }
 
+squash_setup_dir() {
+    _sqsh_dir="$1"
+
+    mkdir -m 0755 -p "$_sqsh_dir"
+    for folder in "${squash_candidate[@]}"; do
+        mv "$2/$folder" "$_sqsh_dir/$folder"
+    done
+}
+
+squash_setup_input_images() {
+    local _old_pwd="$PWD"
+
+    readonly squash_tmp_dir="$squash_dir-tmp"
+
+    mkdir -m 0755 -p "$squash_tmp_dir"
+    cd "$squash_tmp_dir"
+    _sqsh_suffix=0
+    for input_file in $squash_input_images; do
+        lsinitrd --unpack "$input_file"
+        if [[ $? != 0 ]]; then
+            dfatal "dracut: failed to unpack image file '$input_file', for squashing!"
+            exit 1
+        fi
+
+        if [[ -f "$squash_tmp_dir/squash/root.img" ]]; then
+            mv "$squash_tmp_dir/squash/root.img" "$squash_dir$_sqsh_suffix.img"
+        else
+            squash_setup_dir "$squash_dir$_sqsh_suffix" "$squash_tmp_dir"
+        fi
+        rm -rf "$squash_tmp_dir"/*
+	let _sqsh_suffix++
+    done
+
+    squash_input_suffix_max=$((--_sqsh_suffix))
+    cd "$_old_pwd"
+    rm -rf "$squash_tmp_dir"
+}
+
+squash_make_image() {
+    _sqsh_dir="$1"
+
+    if ! mksquashfs "$_sqsh_dir" "$_sqsh_dir.img" \
+        -no-xattrs -no-exports -noappend -always-use-fragments \
+        -comp xz -Xdict-size 100% -no-progress \
+        > /dev/null; then
+        dfatal "dracut: Failed making squash image"
+        exit 1
+    fi
+
+    rm -rf "$_sqsh_dir"
+}
+
+squash_make_images_for_inputfiles() {
+    for _suffix in `seq 0 $squash_input_suffix_max`; do
+        _sqsh_dir="$squash_dir$_suffix"
+        [[ -f "$_sqsh_dir.img" ]] && continue
+	squash_make_image "$_sqsh_dir"
+    done
+}
+
 verbosity_mod_l=0
 unset kernel
 unset outfile
@@ -519,7 +588,7 @@ eval set -- "$TEMP"
 
 while :; do
     if [[ $1 != "--" ]] && [[ $1 != "--rebuild" ]]; then
-        PARMS_TO_STORE+=" $1";
+        [[ $1 != "--squash-input-images" ]] && PARMS_TO_STORE+=" $1";
     fi
     case $1 in
         --kver)        kernel="$2";                           PARMS_TO_STORE+=" '$2'"; shift;;
@@ -557,6 +626,7 @@ while :; do
                        fi
                        shift
                        ;;
+        --squash-input-images)     squash_input_images_l=("$2"); shift;;
         -f|--force)    force=yes;;
         --kernel-only) kernel_only="yes"; no_kernel="no";;
         --no-kernel)   kernel_only="no"; no_kernel="yes";;
@@ -658,6 +728,17 @@ while (($# > 0)); do
     shift
 done
 
+# error check --squash-input-images & prepare squash_input_images
+unset squash_input_images
+for _input_file in $squash_input_images_l; do
+    if [[ ! -e "$_input_file" ]]; then
+        echo "dracut: image file '$_input_file', for squashing, does not exist!"
+        exit 1
+    fi
+    _abs_input_file=$(readlink -f "$_input_file") && _input_file="$_abs_input_file"
+    squash_input_images+=("$_input_file ")
+done
+
 [[ $sysroot_l ]] && dracutsysrootdir="$sysroot_l"
 
 if [[ $regenerate_all == "yes" ]]; then
@@ -1623,6 +1704,7 @@ export initdir dracutbasedir \
     systemdutildir systemdutilconfdir systemdcatalog systemdntpunits \
     systemdntpunitsconfdir systemdsystemunitdir systemdsystemconfdir \
     hostonly_cmdline loginstall \
+    squash_input_images \
     tmpfilesdir
 
 mods_to_load=""
@@ -2025,10 +2107,10 @@ if dracut_module_included "squash"; then
     readonly squash_candidate=( "usr" "etc" )
 
     # shellcheck disable=SC2174
-    mkdir -m 0755 -p "$squash_dir"
-    for folder in "${squash_candidate[@]}"; do
-        mv "$initdir/$folder" "$squash_dir/$folder"
-    done
+    squash_setup_dir "$squash_dir" "$initdir"
+    if [[ -n "$squash_input_images" ]]; then
+        squash_setup_input_images
+    fi
 
     # Move some files out side of the squash image, including:
     # - Files required to boot and mount the squashfs image
@@ -2117,15 +2199,10 @@ fi
 
 if dracut_module_included "squash"; then
     dinfo "*** Squashing the files inside the initramfs ***"
-    if ! mksquashfs "$squash_dir" "$squash_img" \
-        -no-xattrs -no-exports -noappend -always-use-fragments \
-        -comp xz -Xdict-size 100% -no-progress \
-        > /dev/null; then
-        dfatal "dracut: Failed making squash image"
-        exit 1
+    squash_make_image "$squash_dir"
+    if [[ -n "$squash_input_images" ]]; then
+        squash_make_images_for_inputfiles
     fi
-
-    rm -rf "$squash_dir"
     dinfo "*** Squashing the files inside the initramfs done ***"
 fi
 



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] dracut/99squash: make sqaush image setup flexible
  2021-05-13 20:57 [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Hari Bathini
  2021-05-13 20:57 ` [PATCH 1/2] dracut: add a new argument "--squash-input-images" Hari Bathini
@ 2021-05-13 20:57 ` Hari Bathini
  2021-05-14  9:10 ` [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Kairui Song
  2 siblings, 0 replies; 5+ messages in thread
From: Hari Bathini @ 2021-05-13 20:57 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Mahesh J Salgaonkar,
	Sourabh Jain, Kairui Song, Dave Young

So far, /squash/root.img was the only squash'ed file in the initramfs
image. But with the introduction of '--squash-input-images' option,
initramfs image can have more than one squash'ed images. Make squash
image setup flexible to leverage the new option.

For that purpose, add 'setup-sqaush-conditional.sh' script which is
same as 'setup-squash.sh' script except for a couple of changes.

One, it sources 'squash-image-conditional.sh' script. Two, it calls
setup_squash_image_conditional() function implemented in the sourced
script before mounting the squash image (/squash/root.img).

'squash-image-conditional.sh' script here has a dummy implementation
for setup_squash_image_conditional() function. Introduce a new dracut
option '--squash-image-conditional' to overwrite the stock script
(squash/squash-image-conditional.sh) with a custom script.

    Usage: dracut --squash-image-conditional custom-script.sh

The 'custom-script.sh' script file is expected to be implemented in
such a way that /squash/root.img file is updated appropriately, on
calling setup_squash_image_conditional() function, for every possible
boot scenario.

Signed-off-by: Hari Bathini <hbathini-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>
---
 dracut.sh                                      |   26 ++++++++--
 modules.d/99squash/module-setup.sh             |   17 ++++++
 modules.d/99squash/setup-squash-conditional.sh |   65 ++++++++++++++++++++++++
 modules.d/99squash/squash-image-conditional.sh |    5 ++
 4 files changed, 109 insertions(+), 4 deletions(-)
 create mode 100755 modules.d/99squash/setup-squash-conditional.sh
 create mode 100755 modules.d/99squash/squash-image-conditional.sh

diff --git a/dracut.sh b/dracut.sh
index 1a84a707..5fdb4104 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -90,6 +90,14 @@ Creates initial ramdisk images for preloading modules
                          /squash/root1.img, /squash/root2.img, etc., squash
                          images are created, one each for each input initramfs
                          image provided, in that order.
+  --squash-image-conditional [FILE]
+                        Install a custom script [FILE] in place of
+                         '/squash/squash-image-conditional.sh' file to override
+                         setup_squash_image_conditional() function's dummy
+                         implementation with the one that updates squash image
+                         appropriately for every possible boot scenario on the
+                         given system. (Ideally, used in combination with
+                        --squash-input-images option).
   -m, --modules [LIST]  Specify a space-separated list of dracut modules to
                          call when building the initramfs. Modules are located
                          in /usr/lib/dracut/modules.d.
@@ -382,6 +390,7 @@ rearrange_params()
         --long prefix: \
         --long rebuild: \
         --long squash-input-images: \
+        --long squash-image-conditional: \
         --long force \
         --long kernel-only \
         --long no-kernel \
@@ -588,7 +597,8 @@ eval set -- "$TEMP"
 
 while :; do
     if [[ $1 != "--" ]] && [[ $1 != "--rebuild" ]]; then
-        [[ $1 != "--squash-input-images" ]] && PARMS_TO_STORE+=" $1";
+        [[ $1 != "--squash-input-images" ]] \
+            && [[ $1 != "--squash-image-conditional" ]] && PARMS_TO_STORE+=" $1";
     fi
     case $1 in
         --kver)        kernel="$2";                           PARMS_TO_STORE+=" '$2'"; shift;;
@@ -627,6 +637,7 @@ while :; do
                        shift
                        ;;
         --squash-input-images)     squash_input_images_l=("$2"); shift;;
+	--squash-image-conditional)   squash_image_conditional="$2"; shift;;
         -f|--force)    force=yes;;
         --kernel-only) kernel_only="yes"; no_kernel="no";;
         --no-kernel)   kernel_only="no"; no_kernel="yes";;
@@ -728,7 +739,7 @@ while (($# > 0)); do
     shift
 done
 
-# error check --squash-input-images & prepare squash_input_images
+# error check squash related options & get absolute paths for the files provided.
 unset squash_input_images
 for _input_file in $squash_input_images_l; do
     if [[ ! -e "$_input_file" ]]; then
@@ -739,6 +750,12 @@ for _input_file in $squash_input_images_l; do
     squash_input_images+=("$_input_file ")
 done
 
+if [[ -n "$squash_image_conditional" ]] && [[ ! -e "$squash_image_conditional" ]]; then
+    echo "dracut: script file '$squash_image_conditional' to setup squash image, does not exist!"
+    exit 1
+fi
+_abs_sqsh_img_cond="$(readlink -f "$squash_image_conditional")" && squash_image_conditional="$_abs_sqsh_img_cond"
+
 [[ $sysroot_l ]] && dracutsysrootdir="$sysroot_l"
 
 if [[ $regenerate_all == "yes" ]]; then
@@ -1704,7 +1721,7 @@ export initdir dracutbasedir \
     systemdutildir systemdutilconfdir systemdcatalog systemdntpunits \
     systemdntpunitsconfdir systemdsystemunitdir systemdsystemconfdir \
     hostonly_cmdline loginstall \
-    squash_input_images \
+    squash_input_images squash_image_conditional \
     tmpfilesdir
 
 mods_to_load=""
@@ -2133,6 +2150,9 @@ if dracut_module_included "squash"; then
     # We have moved them inside the squashed image, but they need to be
     # accessible before mounting the image.
     inst_multiple "echo" "sh" "mount" "modprobe" "mkdir"
+    if [[ -n "$squash_input_images" ]] || [[ -f "$squash_image_conditional" ]]; then
+        inst_multiple "mv" "rm"
+    fi
     hostonly="" instmods "loop" "squashfs" "overlay"
     # Only keep systemctl outsite if we need switch root
     if [[ ! -f "$initdir/lib/dracut/no-switch-root" ]]; then
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
index 9f973bda..a5d356ba 100644
--- a/modules.d/99squash/module-setup.sh
+++ b/modules.d/99squash/module-setup.sh
@@ -10,6 +10,11 @@ check() {
         fi
     done
 
+    # Include if '--squash-input-images' or '--squash-image-conditional' is used.
+    if [[ -n "$squash_input_images" ]] || [[ -f "$squash_image_conditional" ]]; then
+        return 0
+    fi
+
     return 255
 }
 
@@ -24,7 +29,17 @@ installkernel() {
 
 install() {
     inst_multiple kmod modprobe mount mkdir ln echo
-    inst "$moddir"/setup-squash.sh /squash/setup-squash.sh
+    if [[ -n "$squash_input_images" ]] || [[ -f "$squash_image_conditional" ]]; then
+        inst $moddir/setup-squash-conditional.sh /squash/setup-squash.sh
+        if [[ -f "$squash_image_conditional" ]]; then
+            inst "$squash_image_conditional" /squash/squash-image-conditional.sh
+            chmod 0755 "$initdir/squash/squash-image-conditional.sh"
+        else
+            inst $moddir/squash-image-conditional.sh /squash/squash-image-conditional.sh
+        fi
+    else
+        inst $moddir/setup-squash.sh /squash/setup-squash.sh
+    fi
     inst "$moddir"/clear-squash.sh /squash/clear-squash.sh
     inst "$moddir"/init.sh /squash/init.sh
 
diff --git a/modules.d/99squash/setup-squash-conditional.sh b/modules.d/99squash/setup-squash-conditional.sh
new file mode 100755
index 00000000..41616756
--- /dev/null
+++ b/modules.d/99squash/setup-squash-conditional.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+PATH=/bin:/sbin
+
+SQUASH_IMG=/squash/root.img
+SQUASH_MNT=/squash/root
+SQUASH_MNT_REC=/squash/mounts
+
+. /squash/squash-image-conditional.sh
+
+echo $SQUASH_MNT > $SQUASH_MNT_REC
+
+# Following mount points are neccessary for mounting a squash image
+
+[ ! -d /proc/self ] && \
+    mount -t proc -o nosuid,noexec,nodev proc /proc
+
+[ ! -d /sys/kernel ] && \
+    mount -t sysfs -o nosuid,noexec,nodev sysfs /sys
+
+[ ! -e /dev/loop-control ] && \
+    mount -t devtmpfs -o mode=0755,noexec,nosuid,strictatime devtmpfs /dev
+
+# Need a loop device backend, overlayfs, and squashfs module
+modprobe loop
+if [ $? != 0 ]; then
+    echo "Unable to setup loop module"
+fi
+
+modprobe squashfs
+if [ $? != 0 ]; then
+    echo "Unable to setup squashfs module"
+fi
+
+modprobe overlay
+if [ $? != 0 ]; then
+    echo "Unable to setup overlay module"
+fi
+
+setup_squash_image_conditional
+
+[ ! -d "$SQUASH_MNT" ] && \
+	mkdir -m 0755 -p $SQUASH_MNT
+
+# Mount the squashfs image
+mount -t squashfs -o ro,loop $SQUASH_IMG $SQUASH_MNT
+
+if [ $? != 0 ]; then
+    echo "Unable to mount squashed initramfs image"
+fi
+
+for file in $SQUASH_MNT/*; do
+	file=${file#$SQUASH_MNT/}
+	lowerdir=$SQUASH_MNT/$file
+	workdir=/squash/overlay-work/$file
+	upperdir=/$file
+	mntdir=/$file
+
+	mkdir -m 0755 -p $workdir
+	mkdir -m 0755 -p $mntdir
+
+	mount -t overlay overlay -o\
+		lowerdir=$lowerdir,upperdir=$upperdir,workdir=$workdir $mntdir
+
+	echo $mntdir >> $SQUASH_MNT_REC
+done
diff --git a/modules.d/99squash/squash-image-conditional.sh b/modules.d/99squash/squash-image-conditional.sh
new file mode 100755
index 00000000..2097b767
--- /dev/null
+++ b/modules.d/99squash/squash-image-conditional.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+setup_squash_image_conditional() {
+    return 0
+}



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image
  2021-05-13 20:57 [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Hari Bathini
  2021-05-13 20:57 ` [PATCH 1/2] dracut: add a new argument "--squash-input-images" Hari Bathini
  2021-05-13 20:57 ` [PATCH 2/2] dracut/99squash: make sqaush image setup flexible Hari Bathini
@ 2021-05-14  9:10 ` Kairui Song
       [not found]   ` <CACPcB9ccTfD+NEH8Sj1=UWuvOkiMnmJqvaV9ic8m0-MbQxFwQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2 siblings, 1 reply; 5+ messages in thread
From: Kairui Song @ 2021-05-14  9:10 UTC (permalink / raw)
  To: Hari Bathini
  Cc: Harald Hoyer, initramfs-u79uwXL29TY76Z2rM5mHXA,
	Mahesh J Salgaonkar, Sourabh Jain, Dave Young

Hi Hari,

On Fri, May 14, 2021 at 4:57 AM Hari Bathini <hbathini-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org> wrote:
>
> With the addition of modules.d/99squash module, most of the files in
> the initramfs image can now be squash'ed. While this saves space, this
> can also be extended further to provide support for having different
> initramfs images built into a single image, each squash'ed separately
> & activated based on different boot scenarios.
>
> For that, introduce two dracut options. One, '--squash-input-images':
> takes a space-separated list of input initramfs images to squash &
> include in the initramfs image. Patch one adds this option.
>
> Two, '--squash-image-conditional': takes a script file that sets up
> the appropriate squash image for every possible boot scenario. The
> second patch introduces this option.
>
> ---
>
> Hari Bathini (2):
>       dracut: add a new argument "--squash-input-images"
>       dracut/99squash: make sqaush image setup flexible
>
>
>  dracut.sh                                     | 26 +++++++-
>  modules.d/99squash/module-setup.sh            | 17 ++++-
>  .../99squash/setup-squash-conditional.sh      | 65 +++++++++++++++++++
>  .../99squash/squash-image-conditional.sh      |  5 ++
>  4 files changed, 109 insertions(+), 4 deletions(-)
>  create mode 100755 modules.d/99squash/setup-squash-conditional.sh
>  create mode 100755 modules.d/99squash/squash-image-conditional.sh
>
> --
> 2.31.1
>

There are some major refactoring of the dracut squash module, see:
https://github.com/dracutdevs/dracut/pull/1088

With this refactor, now the whole initramfs is compressed in the
squash image, no longer blended with the original initramfs.
So the re-squash of the "input image content" in this series can be skipped.

I think at least the series needs a rebase.

And I think maybe we can make things easier and flexible here to just
add an argument like a `--custom-init` (or any other name, I'm bad at
naming things), to allow user to use a custom init process, dracut can
just move the old `init` to something like `init.dracut`, and custom
init can either `exec init.dracut`, or do custom init in its own way.

User can combine dracut's `--include` and new `--custom-init` to do
things like this patch.

I know this patch series will benefit fadump, so use that as an
example. The initarmfs can be generated with `dracut --custom-init
/path/fadump-init.sh --include /path/fadump-squash.img ... <other
args>`. fadump-init.sh here will judge if it's fadump boot, and
switch_root into fadump-squash.img if it is, or `exec /init.dracut` if
it's not. fadump-squash.img is just the image extracted from a normal
kdump initramfs with `lsinitrd /path/initramfs-kdump.img
squash-root.img` (after the squash refactor, the squash-root.img is a
complete environment so it can be used directly).

And I also have another idea about this. Since linux's initramfs can
be simply contacted together, user can just create it's own overlay
initramfs and append into the original initramfs. The later appended
initramfs content will just override the original, any custom
modifications can be done that way, no need to rebuild the original
initramfs. Still use fadump as an example, create a `fadump.img`,
which contain three parts: a custom init, dracut's default init
(extracted from the original initramfs), and fadump-squash.img
(extracted from kdump initramfs). Then just `cat fadump.img >>
original-initramfs.img`.

And perhaps you can use Github PR to submit patch updates? Most dracut
related patches are processed using Github PR workflow.

--
Best Regards,
Kairui Song

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image
       [not found]   ` <CACPcB9ccTfD+NEH8Sj1=UWuvOkiMnmJqvaV9ic8m0-MbQxFwQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-05-15  9:57     ` Hari Bathini
  0 siblings, 0 replies; 5+ messages in thread
From: Hari Bathini @ 2021-05-15  9:57 UTC (permalink / raw)
  To: Kairui Song
  Cc: Harald Hoyer, initramfs-u79uwXL29TY76Z2rM5mHXA,
	Mahesh J Salgaonkar, Sourabh Jain, Dave Young

Hi Kairui,

On 14/05/21 2:40 pm, Kairui Song wrote:
> Hi Hari,
> 
> On Fri, May 14, 2021 at 4:57 AM Hari Bathini <hbathini-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org> wrote:
>>
>> With the addition of modules.d/99squash module, most of the files in
>> the initramfs image can now be squash'ed. While this saves space, this
>> can also be extended further to provide support for having different
>> initramfs images built into a single image, each squash'ed separately
>> & activated based on different boot scenarios.
>>
>> For that, introduce two dracut options. One, '--squash-input-images':
>> takes a space-separated list of input initramfs images to squash &
>> include in the initramfs image. Patch one adds this option.
>>
>> Two, '--squash-image-conditional': takes a script file that sets up
>> the appropriate squash image for every possible boot scenario. The
>> second patch introduces this option.
>>
>> ---
>>
>> Hari Bathini (2):
>>        dracut: add a new argument "--squash-input-images"
>>        dracut/99squash: make sqaush image setup flexible
>>
>>
>>   dracut.sh                                     | 26 +++++++-
>>   modules.d/99squash/module-setup.sh            | 17 ++++-
>>   .../99squash/setup-squash-conditional.sh      | 65 +++++++++++++++++++
>>   .../99squash/squash-image-conditional.sh      |  5 ++
>>   4 files changed, 109 insertions(+), 4 deletions(-)
>>   create mode 100755 modules.d/99squash/setup-squash-conditional.sh
>>   create mode 100755 modules.d/99squash/squash-image-conditional.sh
>>
>> --
>> 2.31.1
>>
> 
> There are some major refactoring of the dracut squash module, see:
> https://github.com/dracutdevs/dracut/pull/1088
> 
> With this refactor, now the whole initramfs is compressed in the
> squash image, no longer blended with the original initramfs.
> So the re-squash of the "input image content" in this series can be skipped.
> 
> I think at least the series needs a rebase.
> 
> And I think maybe we can make things easier and flexible here to just
> add an argument like a `--custom-init` (or any other name, I'm bad at
> naming things), to allow user to use a custom init process, dracut can
> just move the old `init` to something like `init.dracut`, and custom
> init can either `exec init.dracut`, or do custom init in its own way.
> 
> User can combine dracut's `--include` and new `--custom-init` to do
> things like this patch.
> 
> I know this patch series will benefit fadump, so use that as an
> example. The initarmfs can be generated with `dracut --custom-init
> /path/fadump-init.sh --include /path/fadump-squash.img ... <other
> args>`. fadump-init.sh here will judge if it's fadump boot, and
> switch_root into fadump-squash.img if it is, or `exec /init.dracut` if
> it's not. fadump-squash.img is just the image extracted from a normal
> kdump initramfs with `lsinitrd /path/initramfs-kdump.img
> squash-root.img` (after the squash refactor, the squash-root.img is a
> complete environment so it can be used directly).
> 
> And I also have another idea about this. Since linux's initramfs can
> be simply contacted together, user can just create it's own overlay
> initramfs and append into the original initramfs. The later appended
> initramfs content will just override the original, any custom
> modifications can be done that way, no need to rebuild the original
> initramfs. Still use fadump as an example, create a `fadump.img`,
> which contain three parts: a custom init, dracut's default init
> (extracted from the original initramfs), and fadump-squash.img
> (extracted from kdump initramfs). Then just `cat fadump.img >>
> original-initramfs.img`.
> 
> And perhaps you can use Github PR to submit patch updates? Most dracut
> related patches are processed using Github PR workflow.

Thanks for the review. I assumed code on kernel.org & github.com would 
be the same. I should have checked that.Naive on my part. Sorry!

I will rebase, work on you suggestions and submit a PR.

Thanks
Hari

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-15  9:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 20:57 [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Hari Bathini
2021-05-13 20:57 ` [PATCH 1/2] dracut: add a new argument "--squash-input-images" Hari Bathini
2021-05-13 20:57 ` [PATCH 2/2] dracut/99squash: make sqaush image setup flexible Hari Bathini
2021-05-14  9:10 ` [PATCH 0/2] Add support to have multi-purpose builds into a single initramfs image Kairui Song
     [not found]   ` <CACPcB9ccTfD+NEH8Sj1=UWuvOkiMnmJqvaV9ic8m0-MbQxFwQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-05-15  9:57     ` Hari Bathini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.