mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 20:44:26 +01:00
Add init_env_poweroff.sh
This commit is contained in:
@@ -45,6 +45,7 @@ See the [getting started section](getting-started.md) for further details.
|
|||||||
1. [KGDB](kgdb.md)
|
1. [KGDB](kgdb.md)
|
||||||
1. [gdbserver](gdbserver.md)
|
1. [gdbserver](gdbserver.md)
|
||||||
1. [Other architectures](other-architectures.md)
|
1. [Other architectures](other-architectures.md)
|
||||||
|
1. [init](init.md)
|
||||||
1. [modprobe](modprobe.md)
|
1. [modprobe](modprobe.md)
|
||||||
1. [X11](x11.md)
|
1. [X11](x11.md)
|
||||||
1. [Count boot instructions](count-boot-instructions.md)
|
1. [Count boot instructions](count-boot-instructions.md)
|
||||||
|
|||||||
17
init.md
17
init.md
@@ -14,7 +14,7 @@ systemd is a "popular" `/init` implementation for desktop distros as of 2017.
|
|||||||
|
|
||||||
BusyBox provides its own minimalistic init implementation which Buildroot uses by default.
|
BusyBox provides its own minimalistic init implementation which Buildroot uses by default.
|
||||||
|
|
||||||
### Custom init
|
## Custom init
|
||||||
|
|
||||||
Is the default BusyBox `/init` too bloated for you, minimalism freak?
|
Is the default BusyBox `/init` too bloated for you, minimalism freak?
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ Also remember that if your init returns, the kernel will panic, there are just t
|
|||||||
- run forever in a loop or long sleep
|
- run forever in a loop or long sleep
|
||||||
- `poweroff` the machine
|
- `poweroff` the machine
|
||||||
|
|
||||||
### Disable networking
|
## Disable networking
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -42,3 +42,16 @@ To disable networking, use:
|
|||||||
To restore it, run:
|
To restore it, run:
|
||||||
|
|
||||||
./build -t initscripts-reconfigure
|
./build -t initscripts-reconfigure
|
||||||
|
|
||||||
|
## The init environment
|
||||||
|
|
||||||
|
The docs make it clear https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html
|
||||||
|
|
||||||
|
> The kernel parses parameters from the kernel command line up to “–”;
|
||||||
|
> if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init:
|
||||||
|
> parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init.
|
||||||
|
> Everything after “–” is passed as an argument to init.
|
||||||
|
|
||||||
|
And you can try it out with:
|
||||||
|
|
||||||
|
./run -e 'init=/init_env_poweroff.sh - asdf=qwer zxcv' -n
|
||||||
|
|||||||
4
rootfs_overlay/init_env_poweroff.sh
Executable file
4
rootfs_overlay/init_env_poweroff.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
echo "$@"
|
||||||
|
env
|
||||||
|
/poweroff.out
|
||||||
Reference in New Issue
Block a user