You are not logged in.

#1 2025-11-10 20:44:42

itarill
Member
Registered: 2020-06-03
Posts: 60

Snapper cleanup not workig and BTRFS subvolume scheme

Apparently my system is hoarding BTRFS snapper snapshots, even though their number is supposed to be limited to 50.
Using artificial unintelligence, it seems that my subvolume sheme is incorrect:

this command returns an empty list, so no nested subvolumes:

sudo btrfs subvolume list -o /

this command returns hundreds of snapshots:

sudo btrfs subvolume list /

ID 3404 gen 115761 top level 264 path @home/.snapshots/1386/snapshot
ID 3405 gen 115761 top level 260 path @.snapshots/1748/snapshot
ID 3406 gen 115788 top level 264 path @home/.snapshots/1387/snapshot
ID 3407 gen 115788 top level 260 path @.snapshots/1749/snapshot
ID 3408 gen 115854 top level 264 path @home/.snapshots/1388/snapshot
ID 3409 gen 115854 top level 260 path @.snapshots/1750/snapshot
ID 3410 gen 115875 top level 264 path @home/.snapshots/1389/snapshot
ID 3411 gen 115876 top level 260 path @.snapshots/1751/snapshot
ID 3412 gen 115885 top level 264 path @home/.snapshots/1390/snapshot
ID 3413 gen 115885 top level 260 path @.snapshots/1752/snapshot

and my current configuration for snapper:

sudo grep SUBVOLUME /etc/snapper/configs/* 

/etc/snapper/configs/home:SUBVOLUME="/home" 
/etc/snapper/configs/root:SUBVOLUME="/"

this does nothing:

sudo snapper -c root cleanup number
sudo snapper -c home cleanup number

So the suspect is that snapper is managing / and /home, whereas my scheme to be managed is /@ and /@home. The latter two folders do not exist:

sudo ls -ld /.snapshots /@/.snapshots /@home/.snapshots

The advised steps which I'm afraid to take before a human advises for or against:

  • Disable --now scheduled backup service and timer

  • Change snapper config to reflect my subvolume scheme

sudo sed -i 's|SUBVOLUME="/"|SUBVOLUME="/@"|' /etc/snapper/configs/root
sudo sed -i 's|SUBVOLUME="/home"|SUBVOLUME="/@home"|' /etc/snapper/configs/home
  • Create missing directories

sudo mkdir -p /@/.snapshots /@home/.snapshots
sudo chown -R root:root /@/.snapshots /@home/.snapshots
  • Remove orphan directories

sudo btrfs subvolume delete /@.snapshots/*/snapshot
sudo btrfs subvolume delete /@home/.snapshots/*/snapshot
sudo rm -rf /@.snapshots /@home/.snapshots
  • Re-enable snapper timeline services and timer

Makes sense to me, but again, I know basically nothing. Is this more or less a safe approach?

Thanks.

P.S.: my next question will be with regards to reviewing my subvolumes, whether I am excluding the appropriate volatile folders etc.

Last edited by itarill (2025-11-10 20:45:50)

Offline

Board footer

Powered by FluxBB