Skip to content

Commit f5bfc7f

Browse files
cgwaltersckyrouac
authored andcommitted
docs: Add man page for bootc-destructive-cleanup.service
Document the bootc-destructive-cleanup.service systemd unit that runs on first boot after an alongside installation with --cleanup. The man page explains how the service is enabled via the systemd generator, what the Fedora cleanup script does, and how distributions can customize the cleanup behavior. Resolves: https://issues.redhat.com/browse/RHEL-131317 Assisted-by: OpenCode (Claude Sonnet 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 2287043 commit f5bfc7f

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
- [`man bootc-install-to-disk`](man/bootc-install-to-disk.8.md)
4141
- [`man bootc-install-to-filesystem`](man/bootc-install-to-filesystem.8.md)
4242
- [`man bootc-install-to-existing-root`](man/bootc-install-to-existing-root.8.md)
43+
- [`man bootc-destructive-cleanup.service`](man/bootc-destructive-cleanup.service.5.md)
4344

4445
# Bootc usage in containers
4546

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# NAME
2+
3+
bootc-destructive-cleanup.service
4+
5+
# DESCRIPTION
6+
7+
This systemd service runs on first boot after an "alongside" installation
8+
using `bootc install to-existing-root --cleanup`. Its purpose is to clean up
9+
files from the previous operating system.
10+
11+
The service runs as a oneshot unit and executes a distribution-specific cleanup
12+
script located at `/usr/lib/bootc/fedora-bootc-destructive-cleanup` (for Fedora
13+
derivatives).
14+
15+
## How it works
16+
17+
1. During `bootc install to-existing-root --cleanup`, a stamp file is created
18+
at `/sysroot/etc/bootc-destructive-cleanup`
19+
2. A systemd generator (`bootc-systemd-generator`) detects this stamp file at
20+
boot time and enables the `bootc-destructive-cleanup.service` unit
21+
3. The service runs the cleanup script on first boot
22+
23+
## What the cleanup script does
24+
25+
On Fedora derivatives, the cleanup script performs the following actions:
26+
27+
- Remounts `/sysroot` as read-write
28+
- Removes all RPM packages installed in the physical root (the previous OS)
29+
- Removes all container images from `/sysroot/var/lib/containers` using
30+
`podman system prune --all -f`
31+
32+
**Note:** The cleanup script does not remove stopped containers, so some storage
33+
may remain. This behavior may change in the future.
34+
35+
# CUSTOMIZING THE CLEANUP SCRIPT
36+
37+
The current implementation ships a Fedora-specific cleanup script. Other
38+
distributions can provide their own cleanup script by creating an executable
39+
at `/usr/lib/bootc/fedora-bootc-destructive-cleanup` or by modifying the
40+
systemd unit file to reference a different path.
41+
42+
For an example implementation, see the
43+
[Fedora cleanup script](https://github.com/bootc-dev/bootc/blob/main/contrib/scripts/fedora-bootc-destructive-cleanup).
44+
45+
# PREVIOUS FILESYSTEM DATA
46+
47+
After an alongside installation, the previous root filesystem data is accessible
48+
at `/sysroot` (the "physical root"). Previous mount points or subvolumes will
49+
not be automatically mounted in the new system; for example, a btrfs subvolume
50+
for /home will not be automatically mounted to /sysroot/home. These filesystems
51+
persist and can be handled manually or defined as mount points in the bootc image.
52+
53+
# SEE ALSO
54+
55+
**bootc**(8), **bootc-install-to-existing-root**(8), **system-reinstall-bootc**(8)
56+
57+
# VERSION
58+
59+
<!-- VERSION PLACEHOLDER -->

0 commit comments

Comments
 (0)