|
| 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 | + |
0 commit comments