From 466918fbb5e493e682620ec67ccaeb019a37b6a2 Mon Sep 17 00:00:00 2001 From: Nippy Date: Sat, 18 Jul 2026 10:31:55 +0200 Subject: teszt --- raveos-calamares-theme/PKGBUILD | 2 +- .../modules/calamares-create-snapshots-subvol.sh | 49 ++++++++++++++++++++++ .../etc/calamares/modules/partition.conf | 11 +++++ .../etc/calamares/modules/shellprocess-loader.conf | 5 +++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 raveos-calamares-theme/etc/calamares/modules/calamares-create-snapshots-subvol.sh diff --git a/raveos-calamares-theme/PKGBUILD b/raveos-calamares-theme/PKGBUILD index 4346a1e..63276af 100644 --- a/raveos-calamares-theme/PKGBUILD +++ b/raveos-calamares-theme/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: AlexC pkgname=raveos-calamares-theme pkgver=2.0.0 -pkgrel=41 +pkgrel=43 pkgdesc="RaveOS Calamares Theme" arch=('any') url="https://git.rp1.hu/RaveOS" diff --git a/raveos-calamares-theme/etc/calamares/modules/calamares-create-snapshots-subvol.sh b/raveos-calamares-theme/etc/calamares/modules/calamares-create-snapshots-subvol.sh new file mode 100644 index 0000000..092b7b9 --- /dev/null +++ b/raveos-calamares-theme/etc/calamares/modules/calamares-create-snapshots-subvol.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +echo ">>> [snapshots-subvol] Running INSIDE target system" + +# Calamares' partition module ignores our btrfsSubvolumes config here and +# always creates its own hardcoded set (/home /root /srv /var/cache +# /var/log /var/tmp as separate subvolumes) -- there's no ".snapshots" +# subvolume among them, which grub-btrfs/Snapper need. Create it by hand +# as a proper top-level (subvolid=5) sibling of the other subvolumes, +# so snapshots of "/" don't recursively include the snapshot store itself. + +ROOT_DEV="$(findmnt -no SOURCE / | sed 's/\[.*\]//')" +ROOT_FS="$(findmnt -no FSTYPE /)" + +if [ "$ROOT_FS" != "btrfs" ]; then + echo ">>> [snapshots-subvol] Root is not btrfs (${ROOT_FS}), skipping." + exit 0 +fi + +if [ -d /.snapshots ] && findmnt -no SOURCE /.snapshots >/dev/null 2>&1; then + echo ">>> [snapshots-subvol] /.snapshots already mounted, skipping." + exit 0 +fi + +mkdir -p /mnt/topvol +mount -o subvolid=5 "${ROOT_DEV}" /mnt/topvol + +if [ ! -d /mnt/topvol/@snapshots ]; then + btrfs subvolume create /mnt/topvol/@snapshots + echo ">>> [snapshots-subvol] Created @snapshots subvolume" +else + echo ">>> [snapshots-subvol] @snapshots subvolume already exists" +fi + +umount /mnt/topvol +rmdir /mnt/topvol + +mkdir -p /.snapshots + +ROOT_UUID="$(blkid -s UUID -o value "${ROOT_DEV}")" +if ! grep -q '/.snapshots' /etc/fstab; then + echo "UUID=${ROOT_UUID} /.snapshots btrfs rw,noatime,compress=zstd:3,discard=async,space_cache=v2,subvol=/@snapshots 0 0" >> /etc/fstab + echo ">>> [snapshots-subvol] Added /.snapshots to fstab" +fi + +mount /.snapshots + +echo ">>> [snapshots-subvol] Done." diff --git a/raveos-calamares-theme/etc/calamares/modules/partition.conf b/raveos-calamares-theme/etc/calamares/modules/partition.conf index f73a24e..f67a679 100644 --- a/raveos-calamares-theme/etc/calamares/modules/partition.conf +++ b/raveos-calamares-theme/etc/calamares/modules/partition.conf @@ -239,6 +239,17 @@ btrfsSubvolumes: # sectors-per-cluster: 128 # size: 100% # + +# btrfsSubvolumes (above) is only honoured when a custom partitionLayout is +# in effect -- Calamares' own hardcoded btrfs subvolume defaults are used +# otherwise, even in plain "erase disk" automatic mode. "unknown" here means +# the user's actual filesystem choice (ext4 or btrfs) is used, same as the +# no-custom-layout default -- this just exists to make btrfsSubvolumes apply. +partitionLayout: + - name: "rootfs" + filesystem: "unknown" + mountPoint: "/" + size: 100% # There can be any number of partitions, each entry having the following attributes: # - name: filesystem label # and diff --git a/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf b/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf index 3b2fde0..13b7dca 100644 --- a/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf +++ b/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf @@ -11,6 +11,11 @@ script: - command: "install -Dm755 /etc/calamares/modules/calamares-fix-bootentry.sh ${ROOT}/root/calamares-fix-bootentry.sh" - command: "arch-chroot ${ROOT} /bin/bash /root/calamares-fix-bootentry.sh" - command: "-rm ${ROOT}/root/calamares-fix-bootentry.sh" + # 3. Calamares' hardcoded btrfs subvolume layout has no .snapshots -- + # create it by hand (needed by grub-btrfs/Snapper). + - command: "install -Dm755 /etc/calamares/modules/calamares-create-snapshots-subvol.sh ${ROOT}/root/calamares-create-snapshots-subvol.sh" + - command: "arch-chroot ${ROOT} /bin/bash /root/calamares-create-snapshots-subvol.sh" + - command: "-rm ${ROOT}/root/calamares-create-snapshots-subvol.sh" # - command: "install -Dm755 /etc/calamares/modules/calamares-microcode-fix.sh ${ROOT}/root/calamares-microcode-fix.sh" -- cgit v1.3