Skip to content

Commit e5057fd

Browse files
authored
Merge pull request #631 from cgwalters/doc-kargs
Doc kargs
2 parents c1ecf38 + a67286f commit e5057fd

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

docs/book.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ command = "mdbook-mermaid"
1212
additional-js = ["mermaid.min.js", "mermaid-init.js"]
1313

1414
[output.linkcheck]
15+
optional = true

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Building images](building/guidance.md)
1212
- [Container runtime vs bootc runtime](building/bootc-runtime.md)
1313
- [Users, groups, SSH keys](building/users-and-groups.md)
14+
- [Kernel arguments](building/kernel-arguments.md)
1415
- [Secrets](building/secrets.md)
1516
- [Management Services](building/management-services.md)
1617

docs/src/building/kernel-arguments.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Kernel arguments
2+
3+
The default bootc model uses ["type 1" bootloader config](https://uapi-group.org/specifications/specs/boot_loader_specification/)
4+
files stored in `/boot/loader/entries`, which define arguments
5+
provided to the Linux kernel.
6+
7+
The set of kernel
8+
arguments can be machine-specific state, but can also
9+
be managed via container updates.
10+
11+
The bootloader entries are currently written by the OSTree backend.
12+
13+
More on Linux kernel arguments: <https://docs.kernel.org/admin-guide/kernel-parameters.html>
14+
15+
## /usr/lib/bootc/kargs.d
16+
17+
Many bootc use cases will use generic "OS/distribution" kernels.
18+
In order to support injecting kernel arguments, bootc supports
19+
a small custom config file format in `/usr/lib/bootc/kargs.d` in
20+
TOML format, that have the following form:
21+
22+
```
23+
# /usr/lib/bootc/kargs.d/10-example.toml
24+
kargs = ["mitigations=auto,nosmt"]
25+
```
26+
27+
There is also support for making these kernel arguments
28+
architecture specific via the `match-architectures` key:
29+
30+
```
31+
# /usr/lib/bootc/kargs.d/00-console.toml
32+
kargs = ["console=ttyS0,114800n8"]
33+
match-architectures = ["x86_64"]
34+
```
35+
36+
NOTE: The architecture matching here accepts values defined
37+
by the [Rust standard library](https://doc.rust-lang.org/std/env/consts/constant.ARCH.html)
38+
(using the architecture of the `bootc` binary itself).
39+
40+
In some cases for Linux, this matches the value of `uname -m`, but
41+
definitely not all. For example, on Fedora derivatives there is `ppc64le`,
42+
but in Rust only `powerpc64`. A common discrepancy is that
43+
Debian derivatives use `amd64`, whereas Rust (and Fedora derivatives)
44+
use `x86_64`.
45+
46+
### Changing kernel arguments post-install via kargs.d
47+
48+
Changes to `kargs.d` files included in a container build
49+
are honored post-install; the difference between the set of
50+
kernel arguments is applied to the current bootloader
51+
configuration. This will preserve any machine-local
52+
kernel arguments.
53+
54+
## Kernel arguments injected at installation time
55+
56+
The `bootc install` flow supports a `--karg` to provide
57+
install-time kernel arguments. These become machine-local
58+
state.
59+
60+
Higher level install tools (ideally at least using `bootc install to-filesystem`
61+
can inject kernel arguments this way) too; for example,
62+
the [Anaconda installer](https://github.com/rhinstaller/anaconda)
63+
has a `bootloader` verb which ultimately uses an API
64+
similar to this.
65+
66+
Post-install, it is supported for any tool to edit
67+
the `/boot/loader/entries` files, which are in a standardized
68+
format.
69+
70+
Typically, `/boot` is mounted read-only to limit
71+
the set of tools which write to this filesystem.
72+
73+
At the current time, `bootc` does not itself offer
74+
an API to manipulate kernel arguments maintained per-machine.
75+
76+
Other projects such as `rpm-ostree` do, via e.g. `rpm-ostree kargs`.
77+
78+
## Injecting default arguments into custom kernels
79+
80+
The Linux kernel supports building in arguments into the kernel
81+
binary, at the time of this writing via the `config CMDLINE`
82+
build option. If you are building a custom kernel, then
83+
it often makes sense to use this instead of `/usr/lib/bootc/kargs.d`
84+
for example.

0 commit comments

Comments
 (0)