BTRFS & snapper & I'm lost

I’m trying to understand snapper & btrfs and “ain’t working” :frowning:

I’m trying to follow openSUSE:Snapper Tutorial - openSUSE Wiki

It states that, for 16Gb + drives, the install should create the config:

  1. Config /etc/snapper/configs/root (0 single) is created automatically.

I have:


 > ls -alF /etc/snapper/configs 

total 0 
drwxr-xr-x 1 root root  0 Jun  8 05:33 **.**/ 
drwxr-xr-x 1 root root 14 Jun  8 05:33 **..**/
>

Here are my drives:

[FONT=monospace]


[FONT=monospace][FONT=monospace]> df -hT -x squashfs -x tmpfs 

Filesystem     Type      Size  Used Avail Use% Mounted on 
devtmpfs       devtmpfs  4.0M     0  4.0M   0% /dev 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% / 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /boot/grub2/i386-pc 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /opt 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /boot/grub2/x86_64-efi 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /root 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /srv 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /usr/local 
/dev/nvme0n1p2 btrfs      64G  6.0G   57G  10% /var 
/dev/nvme0n1p1 vfat      511M  5.1M  506M   1% /boot/efi 
/dev/nvme0n1p3 ext4      392G   78G  294G  21% /home 
> 
[/FONT]

[/FONT]

  1. How do I configure to have snapshots only pre/post: zypper dup?
  2. I want to keep only a max of 5 snapshots

Thanks
[/FONT]

Hi elfroggio,

Looking into “man snapper” it says:

**Automatic Snapshot Creation**
       Next to manual snapshot creation, snapshots are also created automatically. 

       ·   A cron-job creates hourly snapshots. 

       ·   Certain programs like YaST and zypper create pre/post snapshot pairs when modifying the system.

Hourly snapshots by default are disabled. So, apparently it is not snapper itself but other programs calling snapper to create the snapshots. It may be tedious to trace and (if possible) stop that.
You may rather care for the clean up and the maximum space to set up. My /etc/snapper/configs/root is as follows (I didn’t modify it):


# subvolume to snapshot
SUBVOLUME="/"

# filesystem type
FSTYPE="btrfs"


# btrfs qgroup for space aware cleanup algorithms
QGROUP="1/0"


# fraction of the filesystems space the snapshots may use
SPACE_LIMIT="0.5"


# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""

# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="no"


# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"


# run daily number cleanup
NUMBER_CLEANUP="yes"

# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="2-10"
NUMBER_LIMIT_IMPORTANT="4-10"


# create hourly snapshots
TIMELINE_CREATE="no"

# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"

# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="10"
TIMELINE_LIMIT_WEEKLY="0"
TIMELINE_LIMIT_MONTHLY="10"
TIMELINE_LIMIT_YEARLY="10"


# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"

# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="1800"

Maybe this helps you when checking “man snapper-configs”.

Based on the output above, it means that snapshots are not present due to the lack of the /.snapshots subvolume. Even though automatically enabled during install time based on conditions, it’s possible they were manually disabled during that time.

Refer to these:

First, Gb means Gigabit which is likely not what you mean. Pay attention, we cannot read your mind.

As for wiki - minimal size of root partition to (automatically) enable snapshots is distribution (and time) dependent. For current Tumbleweed and Leap it is 25GB, but it may change in the future.

Good news from host erlangen. Snapper works flawlessly since enabling it May 2020: https://forums.opensuse.org/showthread.php/538062-Btrfs-Snapper-Amazing-Stuff! Some 2000 snapshots created without a single hickup.

**erlangen:~ #** fdisk -l /dev/nvme0n1            
**Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors**
Disk model: Samsung SSD 950 PRO 512GB                
Units: sectors of 1 * 512 = 512 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disklabel type: gpt 
Disk identifier: A84F222E-0177-499B-A7EA-BDA6F31E2196 

**Device        **** Start****       End****   Sectors****  Size****Type**
/dev/nvme0n1p1   2048     206847     204800   100M EFI System 
/dev/nvme0n1p2 206848 1000214527 1000007680 476.8G Linux filesystem 
**erlangen:~ #** lsblk -f /dev/nvme0n1       
NAME        FSTYPE FSVER LABEL                UUID                                 FSAVAIL FSUSE% MOUNTPOINTS 
nvme0n1                                                                                            
├─nvme0n1p1 vfat   FAT16                      6DEC-64F9                              97.7M     2% /boot/efi 
└─nvme0n1p2 btrfs        tumbleweed-nvme0n1p2 e7ad401f-4f60-42ff-a07e-f54372bc1dbc  330.4G    30% /var 
                                                                                                  /root 
                                                                                                  /opt 
                                                                                                  /usr/local 
                                                                                                  /srv 
                                                                                                  /home 
                                                                                                  /boot/grub2/x86_64-efi 
                                                                                                  /boot/grub2/i386-pc 
                                                                                                  /.snapshots 
                                                                                                  / 
**erlangen:~ #** btrfs subvolume list -t / 
ID      gen     top level       path 
--      ---     ---------       ---- 
256     308742  5               @ 
257     335547  256             @/var 
258     335518  256             @/usr/local 
259     310625  256             @/tmp 
260     334556  256             @/srv 
261     335530  256             @/root 
262     334556  256             @/opt 
263     332806  256             @/boot/grub2/x86_64-efi 
264     294985  256             @/boot/grub2/i386-pc 
265     335258  256             @/.snapshots 
2131    335547  256             @/home 
2546    335547  265             @/.snapshots/1777/snapshot 
2689    335276  265             @/.snapshots/1906/snapshot 
...
2770    335276  265             @/.snapshots/1979/snapshot 
**erlangen:~ #**

Creation of timeline snapshots is turned off. Number limit is 20:

**erlangen:~ #** snapper get-config              
Key                    | Value 
-----------------------+------ 
ALLOW_GROUPS           |       
ALLOW_USERS            |       
BACKGROUND_COMPARISON  | yes   
EMPTY_PRE_POST_CLEANUP | yes   
EMPTY_PRE_POST_MIN_AGE | 1800  
FREE_LIMIT             | 0.2   
FSTYPE                 | btrfs 
NUMBER_CLEANUP         | yes   
**NUMBER_LIMIT           | 20    **
NUMBER_LIMIT_IMPORTANT | 10    
NUMBER_MIN_AGE         | 1800  
QGROUP                 | 1/0   
SPACE_LIMIT            | 0.5   
SUBVOLUME              | /     
SYNC_ACL               | no    
TIMELINE_CLEANUP       | yes   
**TIMELINE_CREATE        | no    **
TIMELINE_LIMIT_DAILY   | 10    
TIMELINE_LIMIT_HOURLY  | 10    
TIMELINE_LIMIT_MONTHLY | 10    
TIMELINE_LIMIT_WEEKLY  | 0     
TIMELINE_LIMIT_YEARLY  | 10    
TIMELINE_MIN_AGE       | 1800  
**erlangen:~ #**

You may show yours:

**erlangen:~ #** systemctl list-unit-files snapper* 
UNIT FILE                STATE    VENDOR PRESET 
snapper-boot.service     static   -             
snapper-cleanup.service  static   -             
snapper-timeline.service static   -             
snapperd.service         static   -             
snapper-boot.timer       **disabled disabled     ** 
snapper-cleanup.timer    **enabled  enabled      ** 
snapper-timeline.timer   **enabled  enabled      ** 

7 unit files listed. 
**erlangen:~ #**