From dbdbb552e94e7d8766d89e1a77e60447d4b5eaaf Mon Sep 17 00:00:00 2001 From: Thomas Duckworth Date: Mon, 26 Jan 2026 15:46:57 +1100 Subject: [PATCH] Add a script to mount a root erofs to soft reboot into Allows a developer to build an image with their local changes, then test it on their own system by soft rebooting into the generated *-root.erofs. This is ephemeral, and doesn't last a reboot. --- set-nextroot.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 set-nextroot.sh diff --git a/set-nextroot.sh b/set-nextroot.sh new file mode 100755 index 0000000..2119890 --- /dev/null +++ b/set-nextroot.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +# SPDX-FileCopyrightText: 2026 Thomas Duckworth +# SPDX-FileCopyrightText: 2026 Nikolay Kochulin + +set -euo pipefail + +# Mount a new root filesystem which can be used upon a soft reboot. +# This can be used to test locally-built images without needing to setup a new VM. + +# To use, build an image. Then, with the produced kde-linux_*_root-*.erofs file, +# run this script with `sudo ./set-nextroot.sh kde-linux_*_root-*.erofs`. + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" >&2 + exit 1 +fi + +if ! grep -q "^ID=kde-linux$" /etc/os-release; then + echo "This script must be run on a KDE Linux system." >&2 + exit 1 +fi + +if [[ $# -ne 1 ]]; then + echo "Usage: $0 /path/to/new/root.erofs" >&2 + exit 1 +fi + +NEW_ROOT="$1" + +if [[ ! -f "$NEW_ROOT" ]]; then + echo "File $NEW_ROOT does not exist." >&2 + exit 1 +fi + +mkdir /run/nextroot +mount /dev/disk/by-designator/root /run/nextroot -o subvol=/@system +mount /dev/disk/by-designator/root /run/nextroot/system -o subvol=/ +mount "$NEW_ROOT" /run/nextroot/usr -o X-mount.subdir=usr + +echo "New root filesystem mounted at /run/nextroot." +echo "To switch to the new root, run: systemctl soft-reboot"