mirror of
https://github.com/KDE/kde-linux.git
synced 2026-02-07 22:42:08 -05:00
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.
This commit is contained in:
42
set-nextroot.sh
Executable file
42
set-nextroot.sh
Executable file
@@ -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 <tduck@filotimoproject.org>
|
||||
# SPDX-FileCopyrightText: 2026 Nikolay Kochulin <basiqueevangelist@yandex.ru>
|
||||
|
||||
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"
|
||||
Reference in New Issue
Block a user