Skip to content

Commit a4ce989

Browse files
committed
feat: add rechunker-group-fix safety net for legacy rechunk migration
Adds a one-shot systemd unit that regenerates /etc/gshadow on first boot when migrating from images built with hhd-dev/legacy-rechunk's nss-altfiles handling. Without this, users rebasing to images that no longer use the legacy rechunker hit black screens or fail to boot. The unit is gated by ConditionPathExists=!/var/lib/.rechunker-group-fix-done so it runs once and never again. Lands ahead of the rechunker swap so the fix is baked into running systems before they encounter post-swap images. Split out of #4564 to derisk the change based on feedback by @bsherman. Refs #4510, #3917 Assisted-by: Claude Sonnet 4.5 via Kiro CLI Signed-off-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
1 parent 9ba27cf commit a4ce989

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

build_files/base/17-cleanup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ systemctl enable rpm-ostree-countme.service
1616
systemctl enable tailscaled.service
1717
systemctl enable ublue-system-setup.service
1818

19+
# see /usr/bin/rechunker-group-fix
20+
# DO NOT REMOVE THIS
21+
systemctl enable rechunker-group-fix.service
22+
1923
systemctl enable flatpak-preinstall.service
2024

2125
# Updater
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# To use this script, you'll want to put this in your systemd service:
4+
# rm /etc/gshadow
5+
# systemd-sysusers
6+
# (run this script)
7+
# systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev
8+
# This will populate /etc/group successfully, and then populate /etc/gshadow
9+
# with any missing groups that we nuked when we removed /etc/gshadow
10+
11+
GSHADOW_FILE="/etc/gshadow"
12+
GROUP_FILE="/etc/group"
13+
14+
while IFS= read -r f; do
15+
[ -z "$f" ] && continue
16+
group_name=$(echo "$f" | cut -f1 -d':')
17+
grep -q "^${group_name}:" "$GSHADOW_FILE" || echo "${group_name}:!*::" >> "$GSHADOW_FILE"
18+
done < "$GROUP_FILE"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# We have this script so that people using images with `nss-altfiles` (`/usr/lib/g{roup,shadow}`)
2+
# do not break their systems when rebasing to an image without that
3+
# This usually happens when using https://github.com/hhd-dev/rechunk then rebasing to an image without it.
4+
# Please DO NOT remove this unless this is fully, completely obsolete.
5+
# This is exactly what is making it break: https://github.com/ublue-os/legacy-rechunk/blob/1d2b0c2e99afbdc2eb06788ae28e157a88b03d70/1_prune.sh#L41-L47
6+
# Users WILL experience black screens and systems will NOT boot if this script malfunctions. Please test this properly and always make sure this works
7+
# Relevant issues:
8+
# - https://github.com/bootc-dev/bootc/issues/1179#issuecomment-2708305926
9+
# - https://github.com/ublue-os/main/issues/759
10+
# - https://github.com/ublue-os/bluefin-lts/issues/918
11+
# - https://github.com/ublue-os/image-template/issues/177
12+
# - https://github.com/ublue-os/aurora/issues/1468
13+
# - https://github.com/ublue-os/bluefin/issues/3852
14+
# This got created on Tue, 16 Dec 2025 00:44:58 -0300
15+
[Unit]
16+
Description=Fix groups for Legacy rechunker
17+
ConditionPathExists=/run/ostree-booted
18+
ConditionPathExists=!/var/lib/.rechunker-group-fix-done
19+
Wants=local-fs.target
20+
After=local-fs.target
21+
Before=systemd-user-sessions.service
22+
23+
[Service]
24+
Type=oneshot
25+
ExecStart=/usr/bin/bash -c 'rm -f /etc/gshadow'
26+
ExecStart=/usr/bin/systemd-sysusers
27+
ExecStart=/usr/bin/rechunker-group-fix
28+
ExecStart=/usr/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev
29+
ExecStart=/usr/bin/bash -c 'mkdir -p /var/lib && touch /var/lib/.rechunker-group-fix-done'
30+
31+
[Install]
32+
WantedBy=default.target multi-user.target

0 commit comments

Comments
 (0)