|
| 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