Re: [PATCH 1/2] init: ensure that /dev/console is (nearly) always available in initramfs

Rob Landley
2026-02-23T19:45:39Z

On 2/23/26 11:34, Askar Safin wrote:
> Rob Landley <rob@landley.net>:
>> The real problem isn't cpio, it's that the kernel interface
>
> So there is some bug here?
>
> Then, please, describe properly this bug.
>
> I. e. using usual formula "steps to reproduce - what I got - what I expected to see".

I think that the kernel special case creating files in initramfs is the
wrong design approach, but it would address the problem and it's what
the kernel already did in a different codepath.

> Also, does the kernel broke *documented* feature? If indeed some
> *documented* feature doesn't work, then this is indeed very real bug.

Documentation/filesystems/ramfs-rootfs-initramfs.txt section "populating
initramfs" described using the text file format back in 2005
(https://github.com/mpe/linux-fullhistory/commit/7f46a240b0a1 line 135)
and then commit
https://github.com/mpe/linux-fullhistory/commit/99aef427e206f a year
later described running usr/gen_init_cpio to create those files from a
directory to give you an easy starting point to edit.

But I wrote that documentation, so it probably doesn't count.

> I kindly ask you, please, please, describe this bug. I really want
> to help you.
Back when the gen_init_cpio stuff let you create the file and consume
the file separately so you could edit it in between, there was an easy
way to address this problem by creating a cpio containing /dev/console
as a regular user using the kernel plumbing. Then the kernel broke that
and created a regression, which they decided to fix with special case
code doing mknod within the kernel before launching PID 1, but only for
one of two codepaths.

I think adding the special case hack to the other codepath is the wrong
_WAY_ to fix it... but I guess that ship has sailed. I agree doing that
can avoid the "init has no stdin/stdout/stderr" problem and thus address
the issue.

(I still think if you have a CONFIG_DEVTMPFS_MOUNT config symbol, it
should actually work, but that's a somewhat separate issue and a
half-dozen patches ignored by linux-kernel for a decade now apparently
argue otherwise...)

Rob