[Buildroot] Boot fails with initramfs and 'console='

Timo Ketola Timo.Ketola at exertus.fi
Mon Sep 23 17:17:05 UTC 2019


Thanks for looking at this.

On 21.9.2019 13.58, Arnout Vandecappelle wrote:
> On 21/09/2019 08:36, Timo Ketola wrote:
>> Hi there,
>> I'm confused.
>> When U-Boot starts Linux with silent flag in effect, it adjusts bootargs
>> with 'console='.
>> BR installs fs/cpio/init as /init into the initramfs cpio archive. It
>> tries to direct stdio into /dev/console. Why? Linux does exactly the
>> same by itself in init/main.c kernel_init_freeable(). Anyways, trying to
>> open /dev/console with 'console=' in command line fails. Linux reports
>> 'Warning: unable to open an initial console.' but continues. BusyBox's
>> /sbin/init has fallbacks and would also survive. But in /init script it
>> is fatal. The first 'exec 0</dev/console' fails, init dies and Linux panics.
>> Is there something I have completely misunderstood? How this should be
>> correctly (tm) fixed?
>> I think the redirections could be removed. Would that patch be accepted?
>> Can anyone see any bad consequences?
>  Apparently, this was introduced because back in the day, the initramfs would
> start without a mounted devtmps and the opening of /dev/console by the kernel
> would fail. AFAIU this should have been fixed on the kernel side in 2.6.34.

I'm working with 4.9.128 kernel and this still seems to be the case -
that devtmpfs is not mounted when booting with initramfs. Booting with

> / # mount -t proc proc /proc
> / # mount
> rootfs on / type rootfs (rw)
> proc on /proc type proc (rw,relatime)

> ...
>  Please do check however that we do get fds 0, 1 and 2 open both in silent and
> non-silent mode, and that in non-silent mode they do point to console.

I think this is the case. If stdios are not open, BB init tries to open
'/dev/null' or '/' as a final fallback. But I'll test that.

I submitted a patch:


I'm still a little bit uneasy with this as a whole because, I have a
feeling that, in the silent case, the system is left with a 'toxic'
/dev/console. Trying to open it from any shell script will kill that
script. Even a comment in Linux source says that "this should never
fail" when opening /dev/console. But in this case just that happens.



More information about the buildroot mailing list