A cleanup script that works with snapper-rollback to clean up temporary Btrfs subvolumes.
To install the script, move it to /usr/local/bin and make it executable:
sudo mv snapper-cleanup /usr/local/bin/
sudo chmod +x /usr/local/bin/snapper-cleanupBefore running the script, open it and configure the following variables according to your system setup:
DEVICE: The Btrfs partition device path (e.g.,/dev/nvme0n1p2).MOUNT_POINT: A temporary mount point directory (e.g.,/mnt/temp_top).MATCH_PATTERN: The pattern matching the temporary subvolumes to be deleted (e.g.,@rootfs20*).
Run the script with root privileges:
sudo snapper-cleanupThis script has been tested and is personally used on Debian 13.
If you are using other non-Debian-based platforms, please review the script logic before running it to ensure there are no compatibility issues with your system.