Skip to content

Commit 24f2dd0

Browse files
cgwaltersjeckersb
authored andcommitted
Expand/consolidate "detecting bootc"
Continually comes up. Signed-off-by: Colin Walters <[email protected]>
1 parent 1880655 commit 24f2dd0

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

docs/src/filesystem-sysroot.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,4 @@ is recommended, along with an `ExecStartPre=mount -o remount,rw /sysroot`.
7575

7676
### Detecting bootc/ostree systems
7777

78-
For tools like `cloud-init` that want to operate generically,
79-
conditionally detecting this situation can be done via e.g.:
80-
81-
- Checking for `/` being an `overlay` mount point
82-
- Checking for `/sysroot/ostree`
83-
84-
78+
See the [package managers](package-managers.md) section on "Detecting image based systems".

docs/src/package-managers.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ that make the system appear writable, but it's arguably clearer not to do so by
2626
default. Detecting `/usr` as read-only here and providing the same information
2727
would make sense.
2828

29+
To specifically detect if bootc is in use, you can parse its JSON status
30+
(if the binary is present) to tell if a system is tracking an image.
31+
The following command succeeds if an image is *not* being tracked:
32+
`test $(bootc status --format=json | jq .spec.image) = null`.
33+
34+
### The `/run/ostree-booted` file
35+
36+
This is created by ostree, and hence created by bootc (with the ostree)
37+
backend. You can use it to detect ostree. However, *most* cases
38+
should instead detect via one of the recommendations above.
39+
2940
### Running a read-only system via podman/docker
3041

3142
The historical default for docker (inherited into podman) is that
@@ -72,15 +83,6 @@ $ podman run --read-only --rm --tmpfs /var -ti debian /bin/sh -c 'apt update &&
7283
error: read-only /usr detected, refusing to operate. See `man apt-image-based` for more information.
7384
```
7485

75-
### Detecting bootc specifically
76-
77-
You may also reasonably want to detect that the operating system is specifically
78-
using `bootc`. This can be done via e.g.:
79-
80-
`bootc status --format=json | jq -r .spec.image`
81-
82-
If the output of that field is non-`null`, then the system is a bootc system
83-
tracking the specified image.
8486

8587
## Transient overlays
8688

0 commit comments

Comments
 (0)