diff options
Diffstat (limited to 'raveos-calamares-theme')
8 files changed, 235 insertions, 2 deletions
diff --git a/raveos-calamares-theme/PKGBUILD b/raveos-calamares-theme/PKGBUILD index 8319cb6..0500c0b 100644 --- a/raveos-calamares-theme/PKGBUILD +++ b/raveos-calamares-theme/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: AlexC <alexc@alexc.hu> pkgname=raveos-calamares-theme pkgver=2.0.0 -pkgrel=38 +pkgrel=44 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/calamares-fix-bootentry.sh b/raveos-calamares-theme/etc/calamares/modules/calamares-fix-bootentry.sh new file mode 100644 index 0000000..a462bc9 --- /dev/null +++ b/raveos-calamares-theme/etc/calamares/modules/calamares-fix-bootentry.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -e + +echo ">>> [fix-bootentry] Running INSIDE target system" + +ENTRYDIR="/boot/loader/entries" +[ -d "${ENTRYDIR}" ] || { echo ">>> [fix-bootentry] No ${ENTRYDIR}, skipping."; exit 0; } + +# 95-raveos.install (kernel-install hook, fired during pacstrap/mkinitcpio) +# detects the root device via findmnt at hook-time. Depending on the +# chroot/mount-namespace context that detection can silently come back +# empty, producing a loader entry with no "root=" in its options line +# (system then drops to an emergency shell on boot: "Failed to mount '' +# on real root"). By this point in the install sequence /etc/fstab is +# already correctly generated, so use it as the authoritative source and +# patch any entry that is missing root=. + +ROOT_UUID="$(findmnt -no UUID / || true)" +if [ -z "${ROOT_UUID}" ]; then + ROOT_UUID="$(awk '$2 == "/" && $1 ~ /^UUID=/ {print $1; exit}' /etc/fstab | sed 's/^UUID=//')" +fi + +if [ -z "${ROOT_UUID}" ]; then + echo ">>> [fix-bootentry] Could not determine root UUID from findmnt or fstab, leaving entries untouched." + exit 0 +fi + +echo ">>> [fix-bootentry] Root UUID: ${ROOT_UUID}" + +for f in "${ENTRYDIR}"/*.conf; do + [ -f "$f" ] || continue + + if grep -qE '^options[[:space:]].*\broot=' "$f"; then + echo ">>> [fix-bootentry] Already has root=, skipping: $f" + continue + fi + + echo ">>> [fix-bootentry] Patching missing root= in: $f" + sed -i -E "s#^options[[:space:]]+#options root=UUID=${ROOT_UUID} #" "$f" +done + +echo ">>> [fix-bootentry] Done." diff --git a/raveos-calamares-theme/etc/calamares/modules/calamares-normalize-subvolumes.sh b/raveos-calamares-theme/etc/calamares/modules/calamares-normalize-subvolumes.sh new file mode 100644 index 0000000..83b42c4 --- /dev/null +++ b/raveos-calamares-theme/etc/calamares/modules/calamares-normalize-subvolumes.sh @@ -0,0 +1,88 @@ +#!/bin/bash +set -e + +echo ">>> [subvol-normalize] Running INSIDE target system" + +ROOT_DEV="$(findmnt -no SOURCE / | sed 's/\[.*\]//')" +ROOT_FS="$(findmnt -no FSTYPE /)" + +if [ "$ROOT_FS" != "btrfs" ]; then + echo ">>> [subvol-normalize] Root is not btrfs (${ROOT_FS}), skipping." + exit 0 +fi + +# Calamares' partition module ignores our btrfsSubvolumes config entirely +# and always creates its own hardcoded set: @, @home, @root, @srv, @cache, +# @log, @tmp. We only want @, @home, @log, @pkg (just /var/cache/pacman/pkg, +# not all of /var/cache) and @snapshots (created separately). Drop the rest +# here, after everything else has already run, merging any content back +# into the parent (@) subvolume first. + +mkdir -p /mnt/topvol +mount -o subvolid=5 "${ROOT_DEV}" /mnt/topvol + +unmount_retry() { + local path="$1" + local i + for i in 1 2 3 4 5; do + if umount "$path" 2>/dev/null; then + return 0 + fi + fuser -km "$path" >/dev/null 2>&1 || true + sleep 1 + done + umount -l "$path" 2>/dev/null || true +} + +for entry in "root:@root" "srv:@srv" "var/tmp:@tmp"; do + path="/${entry%%:*}" + subvol="${entry##*:}" + if findmnt -no SOURCE "$path" >/dev/null 2>&1; then + echo ">>> [subvol-normalize] Removing separate subvolume ${subvol} (${path})" + unmount_retry "$path" + # $path is now a plain empty dir in @ again -- copy the old + # subvolume's content back into it before deleting the subvolume. + if [ -d "/mnt/topvol/${subvol}" ] && ! findmnt -no SOURCE "$path" >/dev/null 2>&1; then + cp -a "/mnt/topvol/${subvol}/." "$path/" 2>/dev/null || true + btrfs subvolume delete "/mnt/topvol/${subvol}" || true + fi + fi + sed -i "\#[[:space:]]${path}[[:space:]]#d" /etc/fstab +done + +# Narrow /var/cache: drop the whole-@cache subvolume (keep it as a plain +# directory), and create a dedicated @pkg subvolume just for pacman's +# package cache -- that's the only part of /var/cache archinstall separates. +if findmnt -no SOURCE /var/cache >/dev/null 2>&1; then + echo ">>> [subvol-normalize] Narrowing /var/cache -> only pacman/pkg as @pkg" + unmount_retry /var/cache + if [ -d /mnt/topvol/@cache ] && ! findmnt -no SOURCE /var/cache >/dev/null 2>&1; then + cp -a /mnt/topvol/@cache/. /var/cache/ 2>/dev/null || true + btrfs subvolume delete /mnt/topvol/@cache || true + fi +fi +sed -i "\#[[:space:]]/var/cache[[:space:]]#d" /etc/fstab + +if [ ! -d /mnt/topvol/@pkg ]; then + btrfs subvolume create /mnt/topvol/@pkg + echo ">>> [subvol-normalize] Created @pkg subvolume" +fi + +unmount_retry /mnt/topvol +rmdir /mnt/topvol 2>/dev/null || true + +mkdir -p /var/cache/pacman +rm -rf /var/cache/pacman/pkg +mkdir -p /var/cache/pacman/pkg + +ROOT_UUID="$(blkid -s UUID -o value "${ROOT_DEV}")" +MOUNT_OPTS="rw,noatime,compress=zstd:3,discard=async,space_cache=v2" +if ! grep -q '/var/cache/pacman/pkg' /etc/fstab; then + echo "UUID=${ROOT_UUID} /var/cache/pacman/pkg btrfs ${MOUNT_OPTS},subvol=/@pkg 0 0" >> /etc/fstab + echo ">>> [subvol-normalize] Added /var/cache/pacman/pkg to fstab" +fi + +mount /var/cache/pacman/pkg + +echo ">>> [subvol-normalize] Done. Final subvolume list:" +btrfs subvolume list / diff --git a/raveos-calamares-theme/etc/calamares/modules/partition.conf b/raveos-calamares-theme/etc/calamares/modules/partition.conf index b0a9951..732a5df 100644 --- a/raveos-calamares-theme/etc/calamares/modules/partition.conf +++ b/raveos-calamares-theme/etc/calamares/modules/partition.conf @@ -158,6 +158,28 @@ defaultFileSystemType: "ext4" # warning (this matches traditional no-choice-available behavior best). availableFileSystemTypes: ["ext4","btrfs"] +# Btrfs subvolume layout, used whenever btrfs is picked (erase mode). +# +# Without this, Calamares falls back to a single flat "@" subvolume for +# the whole root filesystem -- no separate @home/@log/@pkg, and no +# @.snapshots. That breaks tools that expect the standard Arch layout +# (e.g. grub-btrfs, which looks for snapshot subvolumes to build its GRUB +# submenu, and Snapper, which is picky about which subvolume it manages). +# +# This mirrors archinstall's default btrfs layout, see: +# https://gitlab.archlinux.org/archlinux/archinstall/-/blob/master/archinstall/lib/disk/disk_menu.py +btrfsSubvolumes: + - mountPoint: / + subvolume: /@ + - mountPoint: /home + subvolume: /@home + - mountPoint: /var/log + subvolume: /@log + - mountPoint: /var/cache/pacman/pkg + subvolume: /@pkg + - mountPoint: /.snapshots + subvolume: /@snapshots + # Show/hide LUKS related functionality in automated partitioning modes. # Disable this if you choose not to deploy early unlocking support in GRUB2 # and/or your distribution's initramfs solution. @@ -217,6 +239,17 @@ availableFileSystemTypes: ["ext4","btrfs"] # 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-final.conf b/raveos-calamares-theme/etc/calamares/modules/shellprocess-final.conf index f89762d..fc06d93 100644 --- a/raveos-calamares-theme/etc/calamares/modules/shellprocess-final.conf +++ b/raveos-calamares-theme/etc/calamares/modules/shellprocess-final.conf @@ -24,6 +24,8 @@ script: - "if [ -x ${ROOT}/usr/lib/raveos-plasma-theme/auto-apply.sh ]; then arch-chroot ${ROOT} /usr/lib/raveos-plasma-theme/auto-apply.sh; fi" - "if [ -x ${ROOT}/usr/lib/raveos-hyprland-theme/auto-apply.sh ]; then arch-chroot ${ROOT} /usr/lib/raveos-hyprland-theme/auto-apply.sh; fi" - "arch-chroot ${ROOT} /bin/bash -c 'pacman -Qi plasma-bigscreen &>/dev/null && pacman -Rcns --noconfirm plasma-bigscreen || true'" + - "arch-chroot ${ROOT} sed -i '/^HOOKS=/ s/udev /udev plymouth /' /etc/mkinitcpio.conf" + - "arch-chroot ${ROOT} mkinitcpio -P" - "install -Dm644 /etc/systemd/system/reflector-once.service ${ROOT}/etc/systemd/system/reflector-once.service" - "chroot ${ROOT} systemctl enable reflector-once.service" - "gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-olive-dark'" diff --git a/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf b/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf index 69d9f30..62fd87d 100644 --- a/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf +++ b/raveos-calamares-theme/etc/calamares/modules/shellprocess-loader.conf @@ -4,6 +4,25 @@ script: # 1. Copy across RaveOS bootloader, loader.conf, remove the other entry - command: "cp -r /root/.loader.conf ${ROOT}/boot/loader/loader.conf || true" - command: "rm -r ${ROOT}/boot/loader/entries/*cachyos* || true" + # 2. Safety net: 95-raveos.install can silently produce a loader entry + # with no root= (findmnt returns empty depending on chroot context + # at kernel-install-hook time during pacstrap). Patch it here from + # the by-now-correct /etc/fstab. + - 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' btrfsSubvolumes config is silently ignored -- it always + # creates its own hardcoded set (@, @home, @root, @srv, @cache, @log, + # @tmp). Drop the ones we don't want (@root, @srv, @tmp) and narrow + # @cache down to just /var/cache/pacman/pkg as @pkg. + - command: "install -Dm755 /etc/calamares/modules/calamares-normalize-subvolumes.sh ${ROOT}/root/calamares-normalize-subvolumes.sh" + - command: "arch-chroot ${ROOT} /bin/bash /root/calamares-normalize-subvolumes.sh" + - command: "-rm ${ROOT}/root/calamares-normalize-subvolumes.sh" + # 4. 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" diff --git a/raveos-calamares-theme/etc/calamares/modules/shellprocess-pacstrap.conf b/raveos-calamares-theme/etc/calamares/modules/shellprocess-pacstrap.conf index e8e2e6d..7b5c659 100644 --- a/raveos-calamares-theme/etc/calamares/modules/shellprocess-pacstrap.conf +++ b/raveos-calamares-theme/etc/calamares/modules/shellprocess-pacstrap.conf @@ -4,5 +4,5 @@ timeout: 3600 script: - command: "/usr/bin/pacman-key --init && /usr/bin/pacman-key --populate" name: "Initializing package signing keys..." - - command: "pacstrap ${ROOT} base base-devel raveos-keyring linux-cachyos linux-cachyos-headers linux-firmware networkmanager iwd broadcom-wl-dkms wireless-regdb nano vim grub rsync efibootmgr bash-completion dkms lsb-release mkinitcpio-openswap" + - command: "pacstrap ${ROOT} base base-devel btrfs-progs raveos-keyring linux-cachyos linux-cachyos-headers linux-firmware networkmanager iwd broadcom-wl-dkms wireless-regdb nano vim grub grub-btrfs rsync efibootmgr bash-completion dkms lsb-release mkinitcpio-openswap" name: "Bootstrapping Arch Linux (Netinstall)..." |