Skip to content

Commit 9093697

Browse files
authored
Merge pull request #502 from cgwalters/doc-sysroot
docs: Talk about sysroot, growing
2 parents 69f5033 + e2ce608 commit 9093697

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
- [Image layout](bootc-images.md)
4040
- [Filesystem](filesystem.md)
41+
- [Filesystem: sysroot](filesystem-sysroot.md)
4142

4243
# More information
4344

docs/src/filesystem-sysroot.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Filesystem: Physical /sysroot
2+
3+
The bootc project uses [ostree](https://github.com/ostreedev/ostree/) as a backend,
4+
and maps fetched container images to a [deployment](https://ostreedev.github.io/ostree/deployment/).
5+
6+
## stateroot
7+
8+
The underlying `ostree` CLI and API tooling expose a concept of `stateroot`, which
9+
is not yet exposed via `bootc`. The `stateroot` used by `bootc install`
10+
is just named `default`.
11+
12+
The stateroot concept allows having fully separate parallel operating
13+
system installations with fully separate `/etc` and `/var`, while
14+
still sharing an underlying root filesystem.
15+
16+
In the future, this functionality will be exposed and used by `bootc`.
17+
18+
## /sysroot mount
19+
20+
When booted, the physical root will be available at `/sysroot` as a
21+
read-only mount point. This is a key aspect of how `bootc upgrade` operates:
22+
it fetches the updated container image and writes new files to `/sysroot/ostree`.
23+
24+
Beyond that and debugging/introspection, there are few use cases for tooling to
25+
operate on the physical root.
26+
27+
## Expanding the root filesystem
28+
29+
One notable use case that *does* need to operate on `/sysroot`
30+
is expanding the root filesystem.
31+
32+
Some higher level tools such as e.g. `cloud-init` may (reasonably)
33+
expect the `/` mount point to be the physical root. Tools like
34+
this will need to be adjusted to instead detect this and operate
35+
on `/sysroot`.
36+
37+
### Growing the block device
38+
39+
Fundamentally bootc is agnostic to the underlying block device setup.
40+
How to grow the root block device depends on the underlying
41+
storage stack, from basic partitions to LVM. However, a
42+
common tool is the [growpart](https://manpages.debian.org/testing/cloud-guest-utils/growpart.1.en.html)
43+
utility from `cloud-init`.
44+
45+
### Growing the filesytem
46+
47+
The systemd project ships a [systemd-growfs](https://www.freedesktop.org/software/systemd/man/latest/systemd-growfs.html#)
48+
tool and corresponding `systemd-growfs@` services. This is
49+
a relatively thin abstraction over detecting the target
50+
root filesystem type and running the underlying tool such as
51+
`xfs_growfs`.
52+
53+
At the current time, most Linux filesystems require
54+
the target to be mounted writable in order to grow. Hence,
55+
an invocation of `system-growfs /sysroot` or `xfs_growfs /sysroot`
56+
will need to be further wrapped in a temporary mount namespace.
57+
58+
Using a `MountFlags=slave` drop-in stanza for `[email protected]`
59+
is recommended, along with an `ExecStartPre=mount -o remount,rw /sysroot`.
60+
61+
### Detecting bootc/ostree systems
62+
63+
For tools like `cloud-init` that want to operate generically,
64+
conditionally detecting this situation can be done via e.g.:
65+
66+
- Checking for `/` being an `overlay` mount point
67+
- Checking for `/sysroot/ostree`
68+
69+

docs/src/filesystem.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ enabled = true
1616

1717
This will ensure that the entire `/` is a read-only filesystem.
1818

19+
## Understanding physical vs logical root with `/sysroot`
20+
21+
When the system is fully booted, it is into the equivalent of a `chroot`.
22+
The "physical" host root filesystem will be mounted at `/sysroot`.
23+
For more on this, see [filesystem: sysroot](filesystem-sysroot.md).
24+
25+
This `chroot` filesystem is called a "deployment root". All the remaining
26+
filesystem paths below are part of a deployment root which is used as a
27+
final target for the system boot. The target deployment is determined
28+
via the `ostree=` kernel commandline argument.
29+
1930
## `/usr`
2031

2132
The overall recommendation is to keep all operating system content in `/usr`,

0 commit comments

Comments
 (0)