Skip to content

Commit fc168d6

Browse files
committed
Add init_env_poweroff.sh
1 parent c771b40 commit fc168d6

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ See the [getting started section](getting-started.md) for further details.
4545
1. [KGDB](kgdb.md)
4646
1. [gdbserver](gdbserver.md)
4747
1. [Other architectures](other-architectures.md)
48+
1. [init](init.md)
4849
1. [modprobe](modprobe.md)
4950
1. [X11](x11.md)
5051
1. [Count boot instructions](count-boot-instructions.md)

init.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ systemd is a "popular" `/init` implementation for desktop distros as of 2017.
1414

1515
BusyBox provides its own minimalistic init implementation which Buildroot uses by default.
1616

17-
### Custom init
17+
## Custom init
1818

1919
Is the default BusyBox `/init` too bloated for you, minimalism freak?
2020

@@ -31,7 +31,7 @@ Also remember that if your init returns, the kernel will panic, there are just t
3131
- run forever in a loop or long sleep
3232
- `poweroff` the machine
3333

34-
### Disable networking
34+
## Disable networking
3535

3636
The default BusyBox init scripts enable networking, and there is a 15 second timeout in case your network is down or if your kernel / emulator setup does not support it.
3737

@@ -42,3 +42,16 @@ To disable networking, use:
4242
To restore it, run:
4343

4444
./build -t initscripts-reconfigure
45+
46+
## The init environment
47+
48+
The docs make it clear https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html
49+
50+
> The kernel parses parameters from the kernel command line up to “–”;
51+
> if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init:
52+
> parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init.
53+
> Everything after “–” is passed as an argument to init.
54+
55+
And you can try it out with:
56+
57+
./run -e 'init=/init_env_poweroff.sh - asdf=qwer zxcv' -n

rootfs_overlay/init_env_poweroff.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
echo "$@"
3+
env
4+
/poweroff.out

0 commit comments

Comments
 (0)