Re: [RFC PATCH] rootfs: Use tmpfs for rootfs even if root= is given
From: Rob Landley
Date: Wed Nov 01 2023 - 10:46:24 EST
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/8244c75f-445e-b15b-9dbf-266e7ca666e2@xxxxxxxxxxx/
>
> 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