How to start the busybox shell in initramfs in Linux?

I am working on an embedded Linux system (kernel-5.10.24), and now I am trying to create the initramfs where there is an interactive shell.

The rootfs is mainly based on busybox, and the initramfs source has following layout.

├── bin
├── dev
├── etc
├── lib
├── lib32 -> lib/
├── linuxrc -> bin/busybox
├── mnt
├── root
├── sbin
├── sys
└── usr

and,
initramfs/dev/
├── console
├── fd -> ../proc/self/fd
├── log -> ../tmp/log
├── null
├── stderr -> ../proc/self/fd/2
├── stdin -> ../proc/self/fd/0
└── stdout -> ../proc/self/fd/1

The initramfs/etc/inittab is

# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# now run any rc scripts
::sysinit:/etc/init.d/rcS
#no login
::respawn:-/bin/sh
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
null::shutdown:/etc/init.d/rcK
null::shutdown:/bin/umount -a -r
null::shutdown:/sbin/swapoff -a
  • When the kernel command line is
loglevel=8 console=ttyS0,115200 rdinit=/linuxrc

The kernel bootup showing,

[    2.684513] Freeing unused kernel memory: 4156K
[    2.689193] This architecture does not have kernel memory protection.
[    2.695885] Run /linuxrc as init process
[    2.699931]   with arguments:
[    2.703000]     /linuxrc
[    2.705610]   with environment:
[    2.708849]     HOME=/
[    2.711289]     TERM=linux
[    2.714262] process '/bin/busybox' started with executable stack


There is NO shell prompt for interaction.

  • When the kernel command line is,
loglevel=8 console=ttyS0,115200 rdinit=/bin/sh

kernel booted up, showing

[    2.684492] Freeing unused kernel memory: 4156K
[    2.689172] This architecture does not have kernel memory protection.
[    2.695861] Run /bin/sh as init process
[    2.699818]   with arguments:
[    2.702888]     /bin/sh
[    2.705409]   with environment:
[    2.708646]     HOME=/
[    2.711086]     TERM=linux
[    2.714059] process '/bin/busybox' started with executable stack
[    2.722175] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
[    2.730109] Rebooting in 10 seconds..

Kernel panic!

  • Thirdly, I built a hello into initramfs/bin/hello, it printed out Hello World! to its stdout and looped forever.
    The command line is set to
loglevel=8 console=ttyS0,115200 rdinit=/bin/hello

There is NO Hello World! shown!!!

So, now I am wondering how can I start the busybox shell in the initramfs, what configuration should I do?

Thanks,