|
| 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