2023-10-22 23:56:37

by gmssixty gmssixty

[permalink] [raw]
Subject: How can I add "busybox sh" as init during boot of the custom kernel?

How can I add "busybox sh" as init during boot of the custom kernel? I
have compiled the kernel and put the bzImage in /dev/sda3 (/mnt/sda3).
Booted that kernel. After booting, I got a message to set the init
process. I have put the busybox in /bin. Now I want to add this
"busybox sh" as an init process. How can I do this?

Note that, I did not install any other software in that /dev/sda3
(/mnt/sda3). I have only bzImage and busybox.


2023-10-23 00:15:32

by Randy Dunlap

[permalink] [raw]
Subject: Re: How can I add "busybox sh" as init during boot of the custom kernel?



On 10/22/23 16:56, gmssixty gmssixty wrote:
> How can I add "busybox sh" as init during boot of the custom kernel? I
> have compiled the kernel and put the bzImage in /dev/sda3 (/mnt/sda3).
> Booted that kernel. After booting, I got a message to set the init
> process. I have put the busybox in /bin. Now I want to add this
> "busybox sh" as an init process. How can I do this?
>
> Note that, I did not install any other software in that /dev/sda3
> (/mnt/sda3). I have only bzImage and busybox.

from Documentation/admin-guide/kernel-parameters.txt:
(or https://docs.kernel.org/admin-guide/kernel-parameters.html)

init= [KNL]
Format: <full_path>
Run specified binary instead of /sbin/init as init
process.

--
~Randy

2023-10-23 00:34:33

by gmssixty gmssixty

[permalink] [raw]
Subject: Re: How can I add "busybox sh" as init during boot of the custom kernel?

I tried this: init=/bin/busybox sh, but it got Kernel panic and
failed. On the other hand, what should I write in /sbin/init?

On Mon, Oct 23, 2023 at 6:15 AM Randy Dunlap <[email protected]> wrote:
>
>
>
> On 10/22/23 16:56, gmssixty gmssixty wrote:
> > How can I add "busybox sh" as init during boot of the custom kernel? I
> > have compiled the kernel and put the bzImage in /dev/sda3 (/mnt/sda3).
> > Booted that kernel. After booting, I got a message to set the init
> > process. I have put the busybox in /bin. Now I want to add this
> > "busybox sh" as an init process. How can I do this?
> >
> > Note that, I did not install any other software in that /dev/sda3
> > (/mnt/sda3). I have only bzImage and busybox.
>
> from Documentation/admin-guide/kernel-parameters.txt:
> (or https://docs.kernel.org/admin-guide/kernel-parameters.html)
>
> init= [KNL]
> Format: <full_path>
> Run specified binary instead of /sbin/init as init
> process.
>
> --
> ~Randy

2023-10-23 01:59:57

by Randy Dunlap

[permalink] [raw]
Subject: Re: How can I add "busybox sh" as init during boot of the custom kernel?




> On Mon, Oct 23, 2023 at 6:15 AM Randy Dunlap <[email protected]> wrote:
>>
>>
>>
>> On 10/22/23 16:56, gmssixty gmssixty wrote:
>>> How can I add "busybox sh" as init during boot of the custom kernel? I
>>> have compiled the kernel and put the bzImage in /dev/sda3 (/mnt/sda3).
>>> Booted that kernel. After booting, I got a message to set the init
>>> process. I have put the busybox in /bin. Now I want to add this
>>> "busybox sh" as an init process. How can I do this?
>>>
>>> Note that, I did not install any other software in that /dev/sda3
>>> (/mnt/sda3). I have only bzImage and busybox.
>>
>> from Documentation/admin-guide/kernel-parameters.txt:
>> (or https://docs.kernel.org/admin-guide/kernel-parameters.html)
>>
>> init= [KNL]
>> Format: <full_path>
>> Run specified binary instead of /sbin/init as init
>> process.
>>

On 10/22/23 17:34, gmssixty gmssixty wrote:
> I tried this: init=/bin/busybox sh, but it got Kernel panic and
> failed. On the other hand, what should I write in /sbin/init?
>

Please don't top-post.

You need a file name after init=.
"/bin/busybox sh" is not a file name AFAIK.

To use /sbin/init, enter
init=/sbin/init

To use bash (e.g.), enter
init=/usr/bin/bash

The kernel init code already tries to use /sbin/init if that file is
present, along with /etc/init, /bin/init, and /bin/sh .


--
~Randy

2023-10-23 11:07:03

by gmssixty gmssixty

[permalink] [raw]
Subject: Re: How can I add "busybox sh" as init during boot of the custom kernel?

On Mon, Oct 23, 2023 at 7:59 AM Randy Dunlap <[email protected]> wrote:
>
>
>
>
> > On Mon, Oct 23, 2023 at 6:15 AM Randy Dunlap <[email protected]> wrote:
> >>
> >>
> >>
> >> On 10/22/23 16:56, gmssixty gmssixty wrote:
> >>> How can I add "busybox sh" as init during boot of the custom kernel? I
> >>> have compiled the kernel and put the bzImage in /dev/sda3 (/mnt/sda3).
> >>> Booted that kernel. After booting, I got a message to set the init
> >>> process. I have put the busybox in /bin. Now I want to add this
> >>> "busybox sh" as an init process. How can I do this?
> >>>
> >>> Note that, I did not install any other software in that /dev/sda3
> >>> (/mnt/sda3). I have only bzImage and busybox.
> >>
> >> from Documentation/admin-guide/kernel-parameters.txt:
> >> (or https://docs.kernel.org/admin-guide/kernel-parameters.html)
> >>
> >> init= [KNL]
> >> Format: <full_path>
> >> Run specified binary instead of /sbin/init as init
> >> process.
> >>
>
> On 10/22/23 17:34, gmssixty gmssixty wrote:
> > I tried this: init=/bin/busybox sh, but it got Kernel panic and
> > failed. On the other hand, what should I write in /sbin/init?
> >
>
> Please don't top-post.
>
> You need a file name after init=.
> "/bin/busybox sh" is not a file name AFAIK.
>
> To use /sbin/init, enter
> init=/sbin/init
>
> To use bash (e.g.), enter
> init=/usr/bin/bash
>
> The kernel init code already tries to use /sbin/init if that file is
> present, along with /etc/init, /bin/init, and /bin/sh .
>
>
> --
> ~Randy

What would I write in /sbin/init? I mean, what will be the content of
/sbin/init? Should I write: "exec /bin/busybox sh" in /sbin/init? Or
should I write "/bin/busybox sh" in /sbin/init?

BTW, what is top-post?

2023-10-23 11:41:23

by Bagas Sanjaya

[permalink] [raw]
Subject: Re: How can I add "busybox sh" as init during boot of the custom kernel?

On Mon, Oct 23, 2023 at 05:06:38PM +0600, gmssixty gmssixty wrote:
>
> What would I write in /sbin/init? I mean, what will be the content of
> /sbin/init? Should I write: "exec /bin/busybox sh" in /sbin/init? Or
> should I write "/bin/busybox sh" in /sbin/init?

Since you have Busybox system, /sbin/init should be a symlink to
/bin/busybox.

>
> BTW, what is top-post?

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Thanks.

--
An old man doll... just what I always wanted! - Clara


Attachments:
(No filename) (839.00 B)
signature.asc (235.00 B)
Download all attachments

2023-10-23 13:34:53

by gmssixty gmssixty

[permalink] [raw]
Subject: Re: How can I add "busybox sh" as init during boot of the custom kernel?

On Mon, Oct 23, 2023 at 5:41 PM Bagas Sanjaya <[email protected]> wrote:
>
> On Mon, Oct 23, 2023 at 05:06:38PM +0600, gmssixty gmssixty wrote:
> >
> > What would I write in /sbin/init? I mean, what will be the content of
> > /sbin/init? Should I write: "exec /bin/busybox sh" in /sbin/init? Or
> > should I write "/bin/busybox sh" in /sbin/init?
>
> Since you have Busybox system, /sbin/init should be a symlink to
> /bin/busybox.
>
> >
> > BTW, what is top-post?
>
> A: http://en.wikipedia.org/wiki/Top_post
> Q: Were do I find info about this thing called top-posting?
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing in e-mail?
>
> A: No.
> Q: Should I include quotations after my reply?
>
> http://daringfireball.net/2007/07/on_top
>
> Thanks.
>
> --
> An old man doll... just what I always wanted! - Clara

I have not installed bash. In that case, how can I run "busybox sh"? I
have tried linking /bin/busybox to /sbin/init. After boot, it prompts
to press Enter to activate console. But after pressing Enter, it
prompts the same message again.