dracut/0019-feat-squash-add-module-95squash-erofs.patch
Pavel Valena 52fb8f6eda Rebase to dracut-102, and additional fixes.
From-source-git-commit: 56bf1917de004cd3f9032a68a6cd09d5bd972b04

Additional fixes:

 - support for erofs in squash modules
 - always include the resume module
 - include systemd config files from /usr/lib/systemd
 - only return block devices from get_persistent_dev
 - allow for \ in get_maj_min file path
 - install blk modules using symbol blk_alloc_disk

Resolves: RHEL-32237,RHEL-32506,RHEL-43460,RHEL-47145,RHEL-49744,RHEL-53350
2024-08-08 04:43:00 +02:00

129 lines
3.8 KiB
Diff

From 4e8ea763cb10ab4f3b65e865d2ad03c8a5393e04 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 23 Jul 2024 17:42:33 +0200
Subject: [PATCH 19/24] feat(squash): add module 95squash-erofs
Allow squashing the image in 99squash using erofs. Keep squashfs as
default to not change existing systems. I.e. only use erofs if the user
explicitly include 95squash-erofs or when the prereqs for squashfs are
missing.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
(cherry picked from commit e185d6ae1cc38af90f741d3d6c677458d69a345f)
Resolves: RHEL-43460
---
modules.d/95squash-erofs/module-setup.sh | 45 ++++++++++++++++++++++++
modules.d/99squash/init-squash.sh | 12 +++++--
modules.d/99squash/module-setup.sh | 4 ++-
3 files changed, 58 insertions(+), 3 deletions(-)
create mode 100755 modules.d/95squash-erofs/module-setup.sh
diff --git a/modules.d/95squash-erofs/module-setup.sh b/modules.d/95squash-erofs/module-setup.sh
new file mode 100755
index 00000000..71c2b672
--- /dev/null
+++ b/modules.d/95squash-erofs/module-setup.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+check() {
+ require_binaries mkfs.erofs || return 1
+ require_kernel_modules erofs || return 1
+
+ return 255
+}
+
+depends() {
+ echo "squash"
+ return 0
+}
+
+erofs_install() {
+ hostonly="" instmods "erofs"
+}
+
+erofs_installpost() {
+ local _img="$squashdir/erofs-root.img"
+ local -a _erofs_args
+
+ _erofs_args+=("--exclude-path=$squashdir")
+ _erofs_args+=("-E" "fragments")
+
+ if [[ -n $squash_compress ]]; then
+ if mkfs.erofs "${_erofs_args[@]}" -z "$squash_compress" "$_img" "$initdir" &> /dev/null; then
+ return
+ fi
+ dwarn "mkfs.erofs doesn't support compressor '$squash_compress', failing back to default compressor."
+ fi
+
+ if ! mkfs.erofs "${_erofs_args[@]}" "$_img" "$initdir" &> /dev/null; then
+ dfatal "Failed making squash image"
+ exit 1
+ fi
+}
+
+install() {
+ if [[ $DRACUT_SQUASH_POST_INST ]]; then
+ erofs_installpost
+ else
+ dstdir="$squashdir" erofs_install
+ fi
+}
diff --git a/modules.d/99squash/init-squash.sh b/modules.d/99squash/init-squash.sh
index 42a9a86f..31a39cfd 100755
--- a/modules.d/99squash/init-squash.sh
+++ b/modules.d/99squash/init-squash.sh
@@ -13,15 +13,23 @@ grep -q '^devtmpfs /dev devtmpfs' /proc/self/mounts \
grep -q '^tmpfs /run tmpfs' /proc/self/mounts \
|| (mkdir -p /run && mount -t tmpfs -o mode=755,noexec,nosuid,strictatime tmpfs /run)
+if [ -e /erofs-root.img ]; then
+ _fs=erofs
+ _img=erofs-root.img
+else
+ _fs=squashfs
+ _img=squashfs-root.img
+fi
+
# Load required modules
modprobe loop
-modprobe squashfs
+modprobe "$_fs"
modprobe overlay
# Mount the squash image
mount -t ramfs ramfs /squash
mkdir -p /squash/root /squash/overlay/upper /squash/overlay/work
-mount -t squashfs -o ro,loop /squashfs-root.img /squash/root
+mount -t "$_fs" -o ro,loop /"$_img" /squash/root
# Setup new root overlay
mkdir /newroot
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
index 015944c2..5cbbec63 100755
--- a/modules.d/99squash/module-setup.sh
+++ b/modules.d/99squash/module-setup.sh
@@ -18,7 +18,7 @@ depends() {
squash_get_handler() {
local _module _handler
- for _module in squash-squashfs; do
+ for _module in squash-squashfs squash-erofs; do
if dracut_module_included "$_module"; then
_handler="$_module"
break
@@ -28,6 +28,8 @@ squash_get_handler() {
if [ -z "$_handler" ]; then
if check_module "squash-squashfs"; then
_handler="squash-squashfs"
+ elif check_module "squash-erofs"; then
+ _handler="squash-erofs"
else
dfatal "No valid handler for found"
return 1
--
2.42.0