Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for erofs #7

Merged
merged 12 commits into from
Aug 8, 2024
Merged

Add support for erofs #7

merged 12 commits into from
Aug 8, 2024

Conversation

pvalena
Copy link
Collaborator

@pvalena pvalena commented Jul 27, 2024

PR#546 & PR#490 on dracut-ng

Resolves: RHEL-43460

lsinitrd.sh Fixed Show fixed Hide fixed
lsinitrd.sh Fixed Show fixed Hide fixed
@pvalena pvalena force-pushed the rhel10-fix-43460 branch from 6bcfe67 to 08b7480 Compare July 27, 2024 07:47
@pvalena pvalena changed the title feat(squash): Add module 95squash-erofs Add support for erofs Jul 27, 2024
Copy link
Member

@lnykryn lnykryn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't reviewed the code, but works on my machine.

@pvalena
Copy link
Collaborator Author

pvalena commented Aug 8, 2024

LGTM. I've checked the code & did the reviews upstream.

prudo1 and others added 11 commits August 8, 2024 03:24
…st et al

When using 99squash dracut actually builds two separate initrds. The
"normal" one, that gets squashed into a squashfs image, and a
"minimalistic" one, whose only task is to mount and switch_root to the
squashfs image.

This is currently done the following way:
1. Skipp install() for 99squash during the "normal" installation phase.
2. Trigger a special postinstall hook in 99squash that moves the content
   of $initdir to $squashdir and installs the "minimalistic" initrd to
   $initdir.
3. Strip the binaries in $initdir (of which $squashdir is a sub
   directory of).
4. Squash the content of $squashdir into the squashfs image and remove
   $squashdir.

The problem with this approach is that the steps 2 and 4 specific to
99squash but need to be done in dracut.sh. Thus a lot of special
handling for 99squash is needed in dracut.sh. This will get even more
complex once support for different filesystem images, e.g. erofs, are
implemented.

In order to be able to move most of the functionality into 99squash
itself a new approach will be chosen, i.e.
1. During the installation phase install the "normal" initrd into
   $initdir and the "minimalistic" initrd into $squashdir.
2. Strip the binaries in $initdir.
3. Trigger a special postinstall hook in 99squash that squashes the
   content of $initdir (excluding $squashdir) into the squashfs image,
   removes the content of $intidir (excluding $suqashdir) and, moves the
   content of $squashdir into $initdir.

With that the only special handling remaining in dracut.sh is triggering
the postinstall hook.

However, in inst et al. the destination directory is hard coded to
$initdir. Thus allow setting a different destination directory in inst
et al. to get the new approach to work. For the time being only do that
for the functions required by 99squash.

Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit 5ab4470cf136c2d9983564b84b49fd700d4b8514)

Related: RHEL-43460
…dencies

When implementing erofs support for 99squash we end up with three
modules 99squash, 95squash-squashfs and 95squash-erofs. Where 99squash
contains the common code for filesystem images and
95squash-{squashfs,erofs} the special handing depending on the
filesystem used. This leads to a dependency cycle as we want to allow
users both to choose 99squash, when the exact filesystem doesn't matter,
as well as 95squash-{squashfs,erofs} when a specific filesystem is
required.

But when 99squash is added as a dependency calling
dracut_module_included fails in its depends() function. This lead to
cases where both handlers, 95squash-squashfs and 95squash-erofs, were
added to the initrd.

Reason for the failure is that a module only is marked to be loaded
after all it's dependencies have been checked as well. Thus a child
module cannot detect which parent module wants it to be included. Fix
this by marking modules to be loaded before checking its dependencies in
check_module. Do the same change in check_mount for consistency.

Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit 634b4a5c6fbe595eb240cd529d669d21eadd510c)

Related: RHEL-43460
When using 99squash dracut actually builds two separat initrds. The
"normal" one, that gets squashed into a squashfs image, and a
"minimalistic" one, whose only task is to mount and switch_root to the
squashfs image.

For that 99squash currently requires a lot of special handling in
dracut.sh. Move most of this special handling into 99squash itself. This
requires a new approach when building the "minimalistic" initrd. The new
approach works the following way

1. During the installation phase install the "normal" initrd into
   $initdir and the "minimalistic" initrd into $squashdir.
2. Strip the binaries in $initdir.
3. Trigger a special postinstall hook in 99squash that squashes the
   content of $initdir (excluding $squashdir) into the squashfs image,
   removes the content of $intidir (excluding $suqashdir) and, moves the
   content of $squashdir into $initdir.

Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit 7a4dd89ca732329893628b886fe8e78337d896e8)

Related: RHEL-43460
99squash only allows squashing the files using squashfs. In order to
make the implementation for different filesystems easier split out the
squashfs specific parts into 95squash-squashfs.

While at it rename the root image contained in the initrd to
squashfs-root.img. This allows tools like lsinitrd to detect the
filesystem used later on.

Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit f281606f110be1549cd6b1cd34828653879a5f50)

Related: RHEL-43460
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 <[email protected]>

(cherry picked from commit e185d6ae1cc38af90f741d3d6c677458d69a345f)

Resolves: RHEL-43460
Add support to handle erofs images in lsinitrd. Unfortunately the erofs
tooling is missing some functionality of unsquashfs, esp. the ability to
extract single files and list the content of the image. Work around this
deficiency by always extracting the full image and emulate the missing
functionality as close as possible.

While at it also handle the rename of the squashfs image to
squashfs-root.img.

Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit 009b4ccc94fe3fcf129dddc5aca4f25b1e1b1862)

Resolves: RHEL-43460
Follow the example for squashfs images and also unpack erofs images in
dracut-initramfs-restore.

Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit b390e194911835e6bd24eeeb0946e374852b8ddc)

Resolves: RHEL-43460
At the moment 99squash relies on dracut-install to create the required
directories it later links to. This approach is error prone and will
cause problems when switching to use 99busybox later on, which tries to
add a link to /usr/sbin that hasn't been created. Thus explicitly
create the expected directories before installing the minimal initrd.

Signed-off-by: Philipp Rudo <[email protected]>
(cherry picked from commit dde95b10ff6b28330370fd697350f8bc5da422da)

Related: RHEL-43460
Make use of 99busybox in 99squash rather than installing it manually.
This not only removes duplicate code but allows mixing of busybox with
tools from coreutils. This requires a small change in 99busybox to
remove the hard coded use of $initdir.

Suggested-by: Laszlo Gombos <[email protected]>
Signed-off-by: Philipp Rudo <[email protected]>

(cherry picked from commit 395366278f473038badba239f76cac391428b149)

Related: RHEL-43460
This adds support for rootfs compressed with erofs. Either as a plain
erofs image or a LiveOS/rootfs.img ext4 filesystem compressed with
erofs.

This patch does not make any attempt to change the squashfs directory
naming (or variable names) in order to make these changes as small as
possible and easy to review. It also does not make any attempt to
support the multitude of available options other than what is needed by
anaconda-dracut calling this script to setup the boot.iso root
filesystem.

(which isn't to say it doesn't work, it just hasn't been tested and is
outside the scope of this change).

(cherry picked commit ca5ae5d)

Resolves: RHEL-43460
@pvalena pvalena merged commit c601f62 into main Aug 8, 2024
22 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants