Skip to content

Commit d9f38de

Browse files
committed
docs: Explain how base images grow the root filesystem
Base image authors need to know that disk images booted on larger disks, as in the cloud, need their root grown, and that bootc leaves this to the image. Provisioning tools are often assumed to take care of it, but the image based systems that do it (the Fedora and CentOS Stream bootc base images, Fedora CoreOS, Flatcar) each use a separate service, and cloud-init's growpart and resizefs can't find the device when / is a composefs mount. Point to those services and their docs from bootc-sysroot(7), note that minimal image variants may need one layered in, and link there from the image requirements and provisioning sections. Also fix the systemd-growfs typo. Assisted-by: AI Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
1 parent 5e2ce88 commit d9f38de

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

‎docs/src/bootc-compatible-images.7.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ e.g. `dracut` to ensure the initramfs is set up, etc.
6464

6565
The `bootc container lint` command will check this.
6666

67+
Disk images made from your image will often be booted on a larger
68+
disk, for example in the cloud, and something in the image needs to
69+
grow the root filesystem to fill it; bootc does not. See
70+
[expanding the root filesystem](bootc-sysroot.7.md#expanding-the-root-filesystem)
71+
for how existing base images do this.
72+
6773
## SELinux
6874

6975
The default mechanism for labeling today is that bootc will load the file contexts from the image (e.g. `/etc/selinux/policy`) and apply labels dynamically. This is the only mechanism that will work today with a generic bootc-unaware build tooling.

‎docs/src/bootc-installation.7.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ works on Linux will work with bootc. Common approaches include:
663663
The choice of provisioning tool depends on your base image and deployment
664664
environment—bootc itself is agnostic.
665665

666+
Growing the root filesystem to fill a larger disk is commonly done by
667+
a separate service in the image rather than by the provisioning tool;
668+
see [expanding the root filesystem](bootc-sysroot.7.md#expanding-the-root-filesystem).
669+
666670
### SSH key injection
667671

668672
For simple SSH access without a full provisioning system, bootc provides the

‎docs/src/bootc-sysroot.7.md‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ backend), the logical root `/` is a read-only composefs mount of the
2525
deployed image; otherwise it is a bind mount of a deployment directory
2626
under `/sysroot/ostree`. This is a key aspect of how `bootc upgrade`
2727
operates: it fetches the updated container image and writes the base
28-
image files (using OSTree storage to `/sysroot/ostree/repo`).
28+
image files (in `/sysroot/ostree/repo` with the OSTree backend, or in
29+
`/sysroot/composefs` with the composefs backend).
2930

3031
Beyond that and debugging/introspection, there are few use cases for tooling to
3132
operate on the physical root.
@@ -47,10 +48,44 @@ This [unified storage issue](https://github.com/bootc-dev/bootc/issues/20) track
4748
One notable use case that *does* need to operate on `/sysroot`
4849
is expanding the root filesystem.
4950

51+
Disk images are often booted on a disk larger than the image, for
52+
example in the cloud, so the root partition and filesystem need to be
53+
grown at boot. bootc does not do this itself; the base image (or an
54+
image derived from it) needs to include something that does.
55+
56+
Provisioning tools such as cloud-init or Ignition are commonly expected
57+
to handle this, but the image based systems below each do it with a
58+
dedicated systemd service:
59+
60+
- The [Fedora and CentOS Stream bootc base images](https://gitlab.com/fedora/bootc/base-images/-/tree/9b469901d99583d59b270e802795be8676dc8d19/standard)
61+
ship `bootc-generic-growpart.service`, which runs early in boot on
62+
virtual machines, grows the root partition with `growpart`, and then
63+
grows the filesystem as described [below](#growing-the-filesystem).
64+
Despite its name, it is not part of bootc. Only the `standard` variant
65+
includes it; the `minimal` and `minimal-plus` variants do not.
66+
- Fedora CoreOS grows the root on first boot with
67+
`ignition-ostree-growfs.service`, which runs in the initramfs after
68+
Ignition has set up the disks; see its
69+
[storage documentation](https://docs.fedoraproject.org/en-US/fedora-coreos/storage/#_disk_layout).
70+
- Flatcar Container Linux checks on every boot and grows the root when
71+
the disk has grown, with `extend-filesystems.service`; see
72+
[adding disk space](https://www.flatcar.org/docs/latest/setup/storage/adding-disk-space/).
73+
74+
Your distribution may also have image variants that don't include
75+
a solution, such as the minimal variants above. If you build on one of
76+
those and need the root grown, add a service like these in your
77+
derived image.
78+
5079
Some higher level tools such as e.g. `cloud-init` may (reasonably)
5180
expect the `/` mount point to be the physical root. Tools like
5281
this will need to be adjusted to instead detect this and operate
53-
on `/sysroot`.
82+
on `/sysroot`. For example, cloud-init's
83+
[growpart](https://docs.cloud-init.io/en/latest/reference/modules.html#growpart)
84+
and [resizefs](https://docs.cloud-init.io/en/latest/reference/modules.html#resizefs)
85+
modules find the device from the source of the `/` mount, which is
86+
`composefs` when composefs is enabled, so they currently grow neither
87+
the partition nor the filesystem on such a system (see
88+
[cloud-init#6293](https://github.com/canonical/cloud-init/issues/6293)).
5489

5590
### Growing the block device
5691

@@ -70,11 +105,13 @@ root filesystem type and running the underlying tool such as
70105

71106
At the current time, most Linux filesystems require
72107
the target to be mounted writable in order to grow. Hence,
73-
an invocation of `system-growfs /sysroot` or `xfs_growfs /sysroot`
108+
an invocation of `systemd-growfs /sysroot` or `xfs_growfs /sysroot`
74109
will need to be further wrapped in a temporary mount namespace.
75110

76111
Using a `MountFlags=slave` drop-in stanza for `systemd-growfs@sysroot.service`
77112
is recommended, along with an `ExecStartPre=mount -o remount,rw /sysroot`.
113+
`bootc-generic-growpart.service` above uses the same approach, with
114+
`MountFlags=slave` on its own unit.
78115

79116
### Detecting bootc/ostree systems
80117

0 commit comments

Comments
 (0)