## Partitions and Subvolumes Layout | Partition | Size | Filesystem | Mount Point | | ------------ | -------- | ---------- | ----------- | | `/dev/vda1` | 1 GiB | vfat | `/boot/efi` | | `/dev/vda2` | Remaining | btrfs | (top-level) | > No separate `/boot` partition — kernel lives inside Btrfs root so rollbacks also roll back the kernel. > No swap partition — Fedora uses SwapOnZRAM automatically. ### Btrfs Subvolumes | Name | Mount Point | Purpose | | --------- | ------------------- | -------------------------------------------- | | `root` | `/` | Root filesystem (snapshot-enabled) | | `home` | `/home` | User data (snapshot-enabled) | | `opt` | `/opt` | Third-party software | | `cache` | `/var/cache` | Package cache (excluded from snapshots) | | `gdm` | `/var/lib/gdm` | GNOME login data (use `sddm` for KDE) | | `libvirt` | `/var/lib/libvirt` | VM data | | `log` | `/var/log` | Log files (excluded from snapshots) | | `spool` | `/var/spool` | Print/mail queue data | | `tmp` | `/var/tmp` | Temporary files | ## Post-Installation ```bash # Fix GRUB menu always visible (needed for booting into snapshots) sudo grub2-editenv - unset menu_auto_hide # Verify filesystem layout sudo btrfs filesystem show / lsblk -p /dev/vda sudo btrfs subvolume list / # Update system sudo dnf update && sudo reboot ``` ## Prepare Home for Snapshots Isolate Firefox data so it is not affected by `/home` rollbacks: ```bash mv -v ~/.mozilla/ ~/.mozilla-old btrfs subvolume create ~/.mozilla cp -arv ~/.mozilla-old/. ~/.mozilla/ rm -rfv ~/.mozilla-old/ restorecon -vRF ~/$(ls -A) ``` ## Set Up Snapper, grub-btrfs, and Btrfs Assistant ### Install Packages ```bash sudo dnf install snapper libdnf5-plugin-actions btrfs-assistant \ inotify-tools git make ``` ### Configure DNF Auto-Snapshots ```bash sudo bash -c "cat > /etc/dnf/libdnf5-plugins/actions.d/snapper.actions" <<'EOF' # Get snapshot description pre_transaction::::/usr/bin/sh -c echo\ "tmp.cmd=$(ps\ -o\ command\ --no-headers\ -p\ '${pid}')" # Creates pre snapshot before the transaction pre_transaction::::/usr/bin/sh -c echo\ "tmp.snapper_pre_number=$(snapper\ create\ -t\ pre\ -c\ number\ -p\ -d\ '${tmp.cmd}')" # Creates post snapshot after the transaction post_transaction::::/usr/bin/sh -c [\ -n\ "${tmp.snapper_pre_number}"\ ]\ &&\ snapper\ create\ -t\ post\ --pre-number\ "${tmp.snapper_pre_number}"\ -c\ number\ -d\ "${tmp.cmd}"\ ;\ echo\ tmp.snapper_pre_number\ ;\ echo\ tmp.cmd EOF ``` ### Create Snapper Configs ```bash sudo snapper -c root create-config / sudo snapper -c home create-config /home # Verify sudo snapper list-configs # Restore SELinux contexts sudo restorecon -RFv /.snapshots sudo restorecon -RFv /home/.snapshots # Allow user access to snapshots sudo snapper -c root set-config ALLOW_USERS=$USER SYNC_ACL=yes sudo snapper -c home set-config ALLOW_USERS=$USER SYNC_ACL=yes # Prevent updatedb from indexing .snapshots echo 'PRUNENAMES = ".snapshots"' | sudo tee -a /etc/updatedb.conf ``` ### Install grub-btrfs ```bash git clone https://github.com/Antynea/grub-btrfs cd grub-btrfs # Apply Fedora-specific config sed -i.bkp \ -e '/^#GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS=/a \ GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"' \ -e '/^#GRUB_BTRFS_GRUB_DIRNAME=/a \ GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"' \ -e '/^#GRUB_BTRFS_MKCONFIG=/a \ GRUB_BTRFS_MKCONFIG=/usr/bin/grub2-mkconfig' \ -e '/^#GRUB_BTRFS_SCRIPT_CHECK=/a \ GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check' \ config sudo make install sudo systemctl enable --now grub-btrfsd.service cd .. && rm -rfv grub-btrfs ``` > **KDE note:** If `make install` fails, also set in `config`: > `GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig` and `GRUB_BTRFS_MKCONFIG_LIB=/usr/share/grub/grub-mkconfig_lib` ## Enable Automatic Timeline Snapshots ```bash # Disable timeline for /home (avoids clutter) sudo snapper -c home set-config TIMELINE_CREATE=no # Enable timers sudo systemctl enable --now snapper-timeline.timer sudo systemctl enable --now snapper-cleanup.timer ``` ## Snapshot Management ```bash # List snapshots snapper ls # root snapper -c home ls # home # Delete a range of snapshots sudo snapper delete 10-50 # Check actual disk usage of snapshots sudo btrfs filesystem du -s --human-readable /.snapshots/*/snapshot ``` ## Rollback (Btrfs Assistant GUI) 1. Boot into a snapshot from the GRUB **Fedora Linux snapshots** submenu. 2. Open **Btrfs Assistant**. 3. Go to **Snapper** → **Browse/Restore** tab. 4. Set **Select target** to `root`. 5. Choose the desired snapshot and click **Restore** → **Yes**. 6. Reboot — root subvolume is restored.