Skip to content

Commit 068a8e6

Browse files
author
Ian Kent
committed
fs: Add 'initramfs_options' to set initramfs mount options
JIRA: https://issues.redhat.com/browse/RHEL-121113 Upstream status: Linus Conflicts: There's a fuzz 2 in fs/namespace.c with hunk #1 due to upstream commit 7f9bfaf ("fs: use xarray for old mount id") not being present in RHEL-9 and looks out of scope for this change. commit 278033a Author: Lichen Liu <lichliu@redhat.com> Date: Fri Aug 15 20:14:59 2025 +0800 fs: Add 'initramfs_options' to set initramfs mount options When CONFIG_TMPFS is enabled, the initial root filesystem is a tmpfs. By default, a tmpfs mount is limited to using 50% of the available RAM for its content. This can be problematic in memory-constrained environments, particularly during a kdump capture. In a kdump scenario, the capture kernel boots with a limited amount of memory specified by the 'crashkernel' parameter. If the initramfs is large, it may fail to unpack into the tmpfs rootfs due to insufficient space. This is because to get X MB of usable space in tmpfs, 2*X MB of memory must be available for the mount. This leads to an OOM failure during the early boot process, preventing a successful crash dump. This patch introduces a new kernel command-line parameter, initramfs_options, which allows passing specific mount options directly to the rootfs when it is first mounted. This gives users control over the rootfs behavior. For example, a user can now specify initramfs_options=size=75% to allow the tmpfs to use up to 75% of the available memory. This can significantly reduce the memory pressure for kdump. Consider a practical example: To unpack a 48MB initramfs, the tmpfs needs 48MB of usable space. With the default 50% limit, this requires a memory pool of 96MB to be available for the tmpfs mount. The total memory requirement is therefore approximately: 16MB (vmlinuz) + 48MB (loaded initramfs) + 48MB (unpacked kernel) + 96MB (for tmpfs) + 12MB (runtime overhead) ≈ 220MB. By using initramfs_options=size=75%, the memory pool required for the 48MB tmpfs is reduced to 48MB / 0.75 = 64MB. This reduces the total memory requirement by 32MB (96MB - 64MB), allowing the kdump to succeed with a smaller crashkernel size, such as 192MB. An alternative approach of reusing the existing rootflags parameter was considered. However, a new, dedicated initramfs_options parameter was chosen to avoid altering the current behavior of rootflags (which applies to the final root filesystem) and to prevent any potential regressions. Also add documentation for the new kernel parameter "initramfs_options" This approach is inspired by prior discussions and patches on the topic. Ref: https://www.lightofdawn.org/blog/?viewDetailed=00128 Ref: https://landley.net/notes-2015.html#01-01-2015 Ref: https://lkml.org/lkml/2021/6/29/783 Ref: https://www.kernel.org/doc/html/latest/filesystems/ramfs-rootfs-initramfs.html#what-is-rootfs Signed-off-by: Lichen Liu <lichliu@redhat.com> Link: https://lore.kernel.org/20250815121459.3391223-1-lichliu@redhat.com Tested-by: Rob Landley <rob@landley.net> Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Ian Kent <ikent@redhat.com>
1 parent 0855e43 commit 068a8e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5765,6 +5765,9 @@
57655765

57665766
rootflags= [KNL] Set root filesystem mount option string
57675767

5768+
initramfs_options= [KNL]
5769+
Specify mount options for for the initramfs mount.
5770+
57685771
rootfstype= [KNL] Set root filesystem type
57695772

57705773
rootwait [KNL] Wait (indefinitely) for root device to show up.

fs/namespace.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ static int __init set_mphash_entries(char *str)
6565
}
6666
__setup("mphash_entries=", set_mphash_entries);
6767

68+
static char * __initdata initramfs_options;
69+
static int __init initramfs_options_setup(char *str)
70+
{
71+
initramfs_options = str;
72+
return 1;
73+
}
74+
75+
__setup("initramfs_options=", initramfs_options_setup);
76+
6877
static u64 event;
6978
static DEFINE_IDA(mnt_id_ida);
7079
static DEFINE_IDA(mnt_group_ida);
@@ -4302,7 +4311,7 @@ static void __init init_mount_tree(void)
43024311
struct mnt_namespace *ns;
43034312
struct path root;
43044313

4305-
mnt = vfs_kern_mount(&rootfs_fs_type, 0, "rootfs", NULL);
4314+
mnt = vfs_kern_mount(&rootfs_fs_type, 0, "rootfs", initramfs_options);
43064315
if (IS_ERR(mnt))
43074316
panic("Can't create rootfs");
43084317

0 commit comments

Comments
 (0)