Skip to content

Commit 1b88990

Browse files
committed
fix(rhel): use /mnt/sysroot to locate target root in %post --nochroot
Parsing /proc/mounts for "rl-root" broke on RHEL 10 / Rocky 10 because Anaconda's mount layout changed again. Use Anaconda's canonical /mnt/sysroot mount point instead (with a fallback to the legacy /mnt/sysimage). Works on RHEL 8, 9, 10 and their Rocky counterparts.
1 parent 5489216 commit 1b88990

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11-
tbd
11+
### Fixed
12+
13+
* `lf-rhel.cfg`: Fix `cp` error during the post-install phase on RHEL 10 / Rocky 10 cloud installs. The script no longer parses `/proc/mounts` to locate the installed system's root; it uses Anaconda's canonical `/mnt/sysroot` mount point (with a fallback to the legacy `/mnt/sysimage`), so the same kickstart works on RHEL/Rocky 8, 9 and 10
1214

1315

1416
## [1.2.0] - 2026-04-15

lf-rhel.cfg

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,18 @@ $PYTHON /tmp/pre-script.py
491491

492492

493493
%post --nochroot --erroronfail
494-
root_mount=$(awk '/rl-root/{m=$2} END{print m}' /proc/mounts)
494+
# Locate the target system's root mount. Anaconda exposes two mount points:
495+
# /mnt/sysroot (recommended since Fedora 31 / RHEL 8, see Anaconda's
496+
# docs/developer/mount-points.rst) and the legacy /mnt/sysimage. We prefer
497+
# sysroot and fall back to sysimage so the same kickstart works on RHEL/Rocky
498+
# 8, 9 and 10. Previously we parsed /proc/mounts, which broke on RHEL 10
499+
# because Anaconda's mount layout changed (see Issue #10 and its recurrence).
500+
for candidate in /mnt/sysroot /mnt/sysimage; do
501+
if [ -d "$candidate/root" ]; then
502+
root_mount="$candidate"
503+
break
504+
fi
505+
done
495506
echo "Copying /tmp/dynamic.ks to $root_mount/root/"
496507
cp /tmp/dynamic.ks $root_mount/root/
497508
[ -f /usr/share/anaconda/post-scripts/70-install-ssh-keys.ks ] && cp /usr/share/anaconda/post-scripts/70-install-ssh-keys.ks $root_mount/root/

0 commit comments

Comments
 (0)