2023-10-31 15:44:48

by Stefan Berger

[permalink] [raw]
Subject: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

rootfs currently does not use tmpfs if the root= boot option is passed
even though the documentation about rootfs (added in 6e19eded3684) in
Documentation/filesystems/ramfs-rootfs-initramfs.rst states:

If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
default. To force ramfs, add "rootfstype=ramfs" to the kernel command
line.

However, this currently does not work when root= is passed on the boot
command line since then saved_root_name contains a string and prevents
usage of tmpfs. Therefore, remove the check on saved_root_name to
enable tmpfs for rootfs.

Fixes: 6e19eded3684 ("initmpfs: use initramfs if rootfstype= or root= specified")
Signed-off-by: Stefan Berger <[email protected]>
Cc: "Milton D. Miller II" <[email protected]>
Cc: Rob Landley <[email protected]>
Cc: Jeff Layton <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Jim Cromie <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Mimi Zohar <[email protected]>
---
init/do_mounts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 5dfd30b13f48..6567cf5807ee 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -510,7 +510,7 @@ struct file_system_type rootfs_fs_type = {

void __init init_rootfs(void)
{
- if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
+ if (IS_ENABLED(CONFIG_TMPFS) &&
(!root_fs_names || strstr(root_fs_names, "tmpfs")))
is_tmpfs = true;
}
--
2.40.1


2023-10-31 16:58:46

by Greg KH

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
> rootfs currently does not use tmpfs if the root= boot option is passed
> even though the documentation about rootfs (added in 6e19eded3684) in
> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>
> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
> line.

At this point in time, is there even any difference between ramfs and
tmpfs anymore? Why would you want to choose one over the other here?

thanks,

greg k-h

2023-10-31 20:34:17

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On October 31, 2023 10:11:01 AM PDT, Stefan Berger <[email protected]> wrote:
>
>On 10/31/23 12:56, Greg Kroah-Hartman wrote:
>> On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
>>> rootfs currently does not use tmpfs if the root= boot option is passed
>>> even though the documentation about rootfs (added in 6e19eded3684) in
>>> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>>>
>>> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
>>> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
>>> line.
>> At this point in time, is there even any difference between ramfs and
>> tmpfs anymore? Why would you want to choose one over the other here?
>
>CONFIG_TPMFS_XATTRS allows us to set xattrs, such as security.ima.
>
>   Stefan
>
>>
>> thanks,
>>
>> greg k-h
Why do we even keep ramfs as a standalone file system? To guarantee it cannot be swapped out? Does anyone actually use it?

2023-10-31 21:03:55

by Stefan Berger

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given



On 10/31/23 16:33, H. Peter Anvin wrote:
> On October 31, 2023 10:11:01 AM PDT, Stefan Berger <[email protected]> wrote:
>>
>> On 10/31/23 12:56, Greg Kroah-Hartman wrote:
>>> On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
>>>> rootfs currently does not use tmpfs if the root= boot option is passed
>>>> even though the documentation about rootfs (added in 6e19eded3684) in
>>>> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>>>>
>>>> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
>>>> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
>>>> line.
>>> At this point in time, is there even any difference between ramfs and
>>> tmpfs anymore? Why would you want to choose one over the other here?
>>
>> CONFIG_TPMFS_XATTRS allows us to set xattrs, such as security.ima.
>>
>>    Stefan
>>
>>>
>>> thanks,
>>>
>>> greg k-h
> Why do we even keep ramfs as a standalone file system? To guarantee it cannot be swapped out? Does anyone actually use it?

Probably all machines that have root= on the boot command line use it...

2023-11-01 11:31:14

by Rob Landley

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On 10/31/23 11:56, Greg Kroah-Hartman wrote:
> On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
>> rootfs currently does not use tmpfs if the root= boot option is passed
>> even though the documentation about rootfs (added in 6e19eded3684) in
>> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>>
>> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
>> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
>> line.
>
> At this point in time, is there even any difference between ramfs and
> tmpfs anymore? Why would you want to choose one over the other here?

I submitted a patch to fix this to the list multiple times, which got ignored as
always. Most recently here:

https://lore.kernel.org/lkml/[email protected]/

Rob

2023-11-01 12:18:23

by Stefan Berger

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given



On 11/1/23 07:35, Rob Landley wrote:
> On 10/31/23 11:56, Greg Kroah-Hartman wrote:
>> On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
>>> rootfs currently does not use tmpfs if the root= boot option is passed
>>> even though the documentation about rootfs (added in 6e19eded3684) in
>>> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>>>
>>> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
>>> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
>>> line.
>>
>> At this point in time, is there even any difference between ramfs and
>> tmpfs anymore? Why would you want to choose one over the other here?
>
> I submitted a patch to fix this to the list multiple times, which got ignored as
> always. Most recently here:
>
> https://lore.kernel.org/lkml/[email protected]/

I just tried it with your patch and the machine I am using this with
(OpenBMC) uses the boot command line 'console=ttyS4,115200n8
root=/dev/ram rw'. When I append rootfstype=tmpfs to this boot command
line then it starts actually using tmpfs. So I think this would work for me.
I can add my Tested-by tag to the patch if this helps to get it merged.
Ideally it would also propagate back with a Fixes tag...

Stefan

>
> Rob

2023-11-01 14:17:15

by Stefan Berger

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given



On 11/1/23 07:35, Rob Landley wrote:
> On 10/31/23 11:56, Greg Kroah-Hartman wrote:
>> On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
>>> rootfs currently does not use tmpfs if the root= boot option is passed
>>> even though the documentation about rootfs (added in 6e19eded3684) in
>>> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>>>
>>> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
>>> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
>>> line.
>>
>> At this point in time, is there even any difference between ramfs and
>> tmpfs anymore? Why would you want to choose one over the other here?
>
> I submitted a patch to fix this to the list multiple times, which got ignored as
> always. Most recently here:
>
> https://lore.kernel.org/lkml/[email protected]/

Everyone,
I now responded to Rob's patch over here:
https://lkml.org/lkml/2023/11/1/333


>
> Rob

2023-11-01 14:28:59

by Greg KH

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On Wed, Nov 01, 2023 at 10:16:37AM -0400, Stefan Berger wrote:
>
>
> On 11/1/23 07:35, Rob Landley wrote:
> > On 10/31/23 11:56, Greg Kroah-Hartman wrote:
> > > On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
> > > > rootfs currently does not use tmpfs if the root= boot option is passed
> > > > even though the documentation about rootfs (added in 6e19eded3684) in
> > > > Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
> > > >
> > > > If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
> > > > default. To force ramfs, add "rootfstype=ramfs" to the kernel command
> > > > line.
> > >
> > > At this point in time, is there even any difference between ramfs and
> > > tmpfs anymore? Why would you want to choose one over the other here?
> >
> > I submitted a patch to fix this to the list multiple times, which got ignored as
> > always. Most recently here:
> >
> > https://lore.kernel.org/lkml/[email protected]/
>
> Everyone,
> I now responded to Rob's patch over here:
> https://lkml.org/lkml/2023/11/1/333

Note, we can't do anything with lkml.org links, they don't even work at
times, please always use lore.kernel.org

Also, one patch out of a longer series also will not work as we can't
pick it up from there either.

Can someone resend it, as a stand-alone patch, with the proper people
cc:ed and then we can handle that. You all know this...

thanks,

greg k-h

>
>
> >
> > Rob

2023-11-01 14:32:48

by Mimi Zohar

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On Wed, 2023-11-01 at 15:28 +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 01, 2023 at 10:16:37AM -0400, Stefan Berger wrote:
> >
> >
> > On 11/1/23 07:35, Rob Landley wrote:
> > > On 10/31/23 11:56, Greg Kroah-Hartman wrote:
> > > > On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
> > > > > rootfs currently does not use tmpfs if the root= boot option is passed
> > > > > even though the documentation about rootfs (added in 6e19eded3684) in
> > > > > Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
> > > > >
> > > > > If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
> > > > > default. To force ramfs, add "rootfstype=ramfs" to the kernel command
> > > > > line.
> > > >
> > > > At this point in time, is there even any difference between ramfs and
> > > > tmpfs anymore? Why would you want to choose one over the other here?
> > >
> > > I submitted a patch to fix this to the list multiple times, which got ignored as
> > > always. Most recently here:
> > >
> > > https://lore.kernel.org/lkml/[email protected]/
> >
> > Everyone,
> > I now responded to Rob's patch over here:
> > https://lkml.org/lkml/2023/11/1/333
>
> Note, we can't do anything with lkml.org links, they don't even work at
> times, please always use lore.kernel.org
>
> Also, one patch out of a longer series also will not work as we can't
> pick it up from there either.
>
> Can someone resend it, as a stand-alone patch, with the proper people
> cc:ed and then we can handle that. You all know this...

The [email protected] mailing list should be Cc'ed as well.

--
thanks,

Mimi

2023-11-01 14:47:24

by Rob Landley

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On 11/1/23 07:11, Stefan Berger wrote:
> On 11/1/23 07:35, Rob Landley wrote:
>> On 10/31/23 11:56, Greg Kroah-Hartman wrote:
>>> On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
>>>> rootfs currently does not use tmpfs if the root= boot option is passed
>>>> even though the documentation about rootfs (added in 6e19eded3684) in
>>>> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
>>>>
>>>> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
>>>> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
>>>> line.
>>>
>>> At this point in time, is there even any difference between ramfs and
>>> tmpfs anymore? Why would you want to choose one over the other here?
>>
>> I submitted a patch to fix this to the list multiple times, which got ignored as
>> always. Most recently here:
>>
>> https://lore.kernel.org/lkml/[email protected]/
>
> I just tried it with your patch and the machine I am using this with
> (OpenBMC) uses the boot command line 'console=ttyS4,115200n8
> root=/dev/ram rw'. When I append rootfstype=tmpfs to this boot command
> line then it starts actually using tmpfs. So I think this would work for me.
> I can add my Tested-by tag to the patch if this helps to get it merged.
> Ideally it would also propagate back with a Fixes tag...

Regarding the "why ramfs" question, one bug report I periodically get is people
using initramfs.cpio.gz that works on ramfs but fails to extract when they try
tmpfs, and the reason is tmpfs defaults to size=50% of memory and their archive
extracts to more than that. Since ramfs hasn't got a limit, it extracted and ran
fine (generally a dedicated init app doing its IoT thing) and so far they've
always gone back to ramfs as their fix.

I vaguely recall I had some todo item to let them supply arguments so they could
specify their own size= for initmpfs (ramfs doesn't take any so it hadn't been
wired up last time I looked), but somewhere between
https://lkml.org/lkml/2016/6/22/686 and
https://lkml.iu.edu/hypermail/linux/kernel/2302.2/05597.html still being out of
tree 7 years later I kind of lost interest...

Rob

2023-11-02 11:57:20

by Mimi Zohar

[permalink] [raw]
Subject: Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given

On Wed, 2023-11-01 at 06:35 -0500, Rob Landley wrote:
> On 10/31/23 11:56, Greg Kroah-Hartman wrote:
> > On Tue, Oct 31, 2023 at 11:44:17AM -0400, Stefan Berger wrote:
> >> rootfs currently does not use tmpfs if the root= boot option is passed
> >> even though the documentation about rootfs (added in 6e19eded3684) in
> >> Documentation/filesystems/ramfs-rootfs-initramfs.rst states:
> >>
> >> If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by
> >> default. To force ramfs, add "rootfstype=ramfs" to the kernel command
> >> line.
> >
> > At this point in time, is there even any difference between ramfs and
> > tmpfs anymore? Why would you want to choose one over the other here?
>
> I submitted a patch to fix this to the list multiple times, which got ignored as
> always. Most recently here:
>
> https://lore.kernel.org/lkml/[email protected]/

Rob, the patch set wasn't upstreamed, but it certainly wasn't ignored.
There were multiple comments.

Can you at least re-post "[PATCH 5/5] fix rootfstype=tmpfs" after
addressing the checkpatch.pl complaints?

--
thanks,

Mimi