From: Julian Stecklina via B4 Relay <devnull+julian.stecklina.cyberus-technology.de@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Julian Stecklina <julian.stecklina@cyberus-technology.de>
Subject: [PATCH] initrd: support erofs as initrd
Date: Thu, 20 Mar 2025 20:28:23 +0100 [thread overview]
Message-ID: <20250320-initrd-erofs-v1-1-35bbb293468a@cyberus-technology.de> (raw)
From: Julian Stecklina <julian.stecklina@cyberus-technology.de>
Add erofs detection to the initrd mount code. This allows systems to
boot from an erofs-based initrd in the same way as they can boot from
a squashfs initrd.
Just as squashfs initrds, erofs images as initrds are a good option
for systems that are memory-constrained.
Signed-off-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
---
init/do_mounts_rd.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index ac021ae6e6fa78c7b7828a78ab2fa3af3611bef3..7c3f8b45b5ed2eea3c534d7f2e65608542009df5 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -11,6 +11,7 @@
#include "do_mounts.h"
#include "../fs/squashfs/squashfs_fs.h"
+#include "../fs/erofs/erofs_fs.h"
#include <linux/decompress/generic.h>
@@ -47,6 +48,7 @@ static int __init crd_load(decompress_fn deco);
* romfs
* cramfs
* squashfs
+ * erofs
* gzip
* bzip2
* lzma
@@ -63,6 +65,7 @@ identify_ramdisk_image(struct file *file, loff_t pos,
struct romfs_super_block *romfsb;
struct cramfs_super *cramfsb;
struct squashfs_super_block *squashfsb;
+ struct erofs_super_block *erofsb;
int nblocks = -1;
unsigned char *buf;
const char *compress_name;
@@ -77,6 +80,7 @@ identify_ramdisk_image(struct file *file, loff_t pos,
romfsb = (struct romfs_super_block *) buf;
cramfsb = (struct cramfs_super *) buf;
squashfsb = (struct squashfs_super_block *) buf;
+ erofsb = (struct erofs_super_block *) buf;
memset(buf, 0xe5, size);
/*
@@ -165,6 +169,21 @@ identify_ramdisk_image(struct file *file, loff_t pos,
goto done;
}
+ /* Try erofs */
+ pos = (start_block * BLOCK_SIZE) + EROFS_SUPER_OFFSET;
+ kernel_read(file, buf, size, &pos);
+
+ if (erofsb->magic == EROFS_SUPER_MAGIC_V1) {
+ printk(KERN_NOTICE
+ "RAMDISK: erofs filesystem found at block %d\n",
+ start_block);
+
+ nblocks = ((erofsb->blocks << erofsb->blkszbits) + BLOCK_SIZE - 1)
+ >> BLOCK_SIZE_BITS;
+
+ goto done;
+ }
+
printk(KERN_NOTICE
"RAMDISK: Couldn't find valid RAM disk image starting at %d.\n",
start_block);
---
base-commit: 5fc31936081919a8572a3d644f3fbb258038f337
change-id: 20250320-initrd-erofs-76e925fdf68c
Best regards,
--
Julian Stecklina <julian.stecklina@cyberus-technology.de>
next reply other threads:[~2025-03-20 19:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 19:28 Julian Stecklina via B4 Relay [this message]
2025-03-21 2:08 ` Al Viro
2025-03-21 8:46 ` Christian Brauner
2025-03-21 12:49 ` Julian Stecklina
2025-03-21 5:01 ` Christoph Hellwig
2025-03-21 5:27 ` Gao Xiang
2025-03-21 13:17 ` Julian Stecklina
2025-03-21 13:57 ` Gao Xiang
2025-04-07 8:57 ` hch
2025-04-07 11:19 ` Julian Stecklina
2025-04-07 16:05 ` Gao Xiang
2025-08-25 18:27 ` Askar Safin
2025-08-26 7:59 ` Christoph Hellwig
2025-08-26 14:21 ` Byron Stanoszek
2025-08-26 15:32 ` Gao Xiang
2025-08-26 16:00 ` Gao Xiang
2025-08-27 9:22 ` Askar Safin
2025-08-27 9:48 ` Gao Xiang
2025-08-27 9:58 ` Gao Xiang
2025-08-28 16:44 ` Askar Safin
2025-08-28 17:00 ` Gao Xiang
2025-08-28 17:14 ` Gao Xiang
2025-08-30 11:49 ` Askar Safin
2025-08-30 12:23 ` Gao Xiang
2025-08-26 17:00 ` Askar Safin
2025-03-21 8:48 ` Christian Brauner
2025-03-21 9:16 ` Thomas Weißschuh
2025-03-21 13:26 ` Julian Stecklina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250320-initrd-erofs-v1-1-35bbb293468a@cyberus-technology.de \
--to=devnull+julian.stecklina.cyberus-technology.de@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=julian.stecklina@cyberus-technology.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®