Skip to content

initrd: cleanup and erofs support

Julian Stecklina b4-sent linux-erofs linux-fsdevel lkml llvm oe-kbuild-all 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20250320-initrd-erofs-76e925fdf68c

Versions newest first

  1. v2 Latest9 patches 2 repliesIn review
  2. v11 patch 27 repliesSuperseded

Changes in v2 from the cover letter

- Remove more legacy code
- Introduce initrd_fs_detect
- Move all other initrd filesystems to the new API
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9initrd: remove ASCII spinnerinit/do_mounts_rd.c+0 -111 reply
2/9initrd: fix double fput for truncated ramdisksinit/do_mounts_rd.c+7 -70 replies
3/9initrd: add a generic mechanism to add fs detectorsinclude/asm-generic/vmlinux.lds.h include/linux/initrd.h init/do_mounts_rd.c+70 -11 reply
4/9fs: minix: register an initrd fs detectorfs/minix/Makefile fs/minix/initrd.c init/do_mounts_rd.c+29 -150 replies
5/9fs: cramfs: register an initrd fs detectorfs/cramfs/Makefile fs/cramfs/initrd.c init/do_mounts_rd.c+48 -260 replies
6/9fs: romfs: register an initrd fs detectorfs/romfs/Makefile fs/romfs/initrd.c init/do_mounts_rd.c+26 -140 replies
7/9fs: squashfs: register an initrd fs detectorfs/squashfs/Makefile fs/squashfs/initrd.c init/do_mounts_rd.c+28 -140 replies
8/9fs: ext2, ext4: register an initrd fs detectorfs/ext2/Makefile fs/ext2/initrd.c fs/ext4/Makefile +2 more+36 -280 replies
9/9fs: erofs: register an initrd fs detectorfs/erofs/Makefile fs/erofs/initrd.c+24 -00 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchDavid Disseldorp
1/9R-b
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/9] initrd: cleanup and erofs support

On my journey towards adding erofs support for initrd, Al Viro suggested to move the filesystem detection code into the respective filesystem modules. This patch series implements this, while also adding erofs support.

To achieve this, I added a macro initrd_fs_detect() that allows filesystem modules to add a filesystem detection hooks. I then moved all existing filesystem detection code to this new API. While I was there I also tried to clean up some of the code.

I've tested these changes with the following kinds of initrd images:

- ext2
- Minix v1
- cramfs (padded/unpadded)
- romfs
- squashfs
- erofs

initrds are still relevant, because they have some advantages over initramfs. They don't require unpacking all files before starting the init process and allows them to stay compressed in memory. They also allow using advanced file system features, such as extended attributes. In the NixOS community, we are heavy users of erofs, due to its sweet spot of compression, speed and features.

That being said, I'm totally in favor of cutting down the supported filesystems for initrd and further simplify the code. I would be surprised, if anyone is using ext2 or Minix v1 filesystems (64 MiB filesystem size limit!) or cramfs (16 MiB file size limit!) as an initrd these days! Squashfs and erofs seem genuinely useful, though.

---
Changes in v2:
- Remove more legacy code
- Introduce initrd_fs_detect
- Move all other initrd filesystems to the new API
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Julian Stecklina (9):
initrd: remove ASCII spinner
initrd: fix double fput for truncated ramdisks
initrd: add a generic mechanism to add fs detectors
fs: minix: register an initrd fs detector
fs: cramfs: register an initrd fs detector
fs: romfs: register an initrd fs detector
fs: squashfs: register an initrd fs detector
fs: ext2, ext4: register an initrd fs detector
fs: erofs: register an initrd fs detector

 fs/cramfs/Makefile                |   5 ++
 fs/cramfs/initrd.c                |  41 +++++++++++++
 fs/erofs/Makefile                 |   5 ++
 fs/erofs/initrd.c                 |  19 ++++++
 fs/ext2/Makefile                  |   5 ++
 fs/ext2/initrd.c                  |  27 +++++++++
 fs/ext4/Makefile                  |   4 ++
 fs/minix/Makefile                 |   5 ++
 fs/minix/initrd.c                 |  23 +++++++
 fs/romfs/Makefile                 |   4 ++
 fs/romfs/initrd.c                 |  22 +++++++
 fs/squashfs/Makefile              |   5 ++
 fs/squashfs/initrd.c              |  23 +++++++
 include/asm-generic/vmlinux.lds.h |   6 ++
 include/linux/ext2_fs.h           |   9 ---
 include/linux/initrd.h            |  37 ++++++++++++
 init/do_mounts_rd.c               | 122 ++++++++------------------------------
 17 files changed, 257 insertions(+), 105 deletions(-)

---
base-commit: 88d324e69ea9f3ae1c1905ea75d717c08bdb8e15
change-id: 20250320-initrd-erofs-76e925fdf68c

Best regards,

Signature · 1 line
Julian Stecklina <[email protected]>