[HowTo] Btrfs and Snapper

Difficulty: ★★★☆☆

How-To BTRFS and SNAPSHOTS for N@@bs

  1. Install system in BTRFS format on a sdd disk
  • Partitions
    • boot:
      • File System: FAT32
      • Mount point: /boot/efi
      • Size: 512M
      • Partition flags: EFI, BOOT
    • root:
      • File System: BTRFS
      • Mount point: /
      • Size: 48GB for normal user, 64GB for power user
      • Mount options: noatime,sdd,clear_cache,commit=120,compress=zstd,subvolid=256
    • home:
      • File System: BTRFS
      • Mount point: /home
      • Size: 64GB for small user, 128GB for power user, the rest of your disk -10% for super-user
      • Mount Options: noatime,sdd,clear_cache,commit=120,compress=zstd,subvolid=256
  • Subvolumes
  1. Snapper
  • Create config files for each Partition

    • We need root acces
    • snapper -c root create-config /
    • snapper -c home create-config /home
  • Config the snapper config files

    • We need root acces

    • The method is the same for any config file (I.E. / and /home)

    • nano /etc/snapper/configs/root

    • Set the variable ALLOW_USERS="@USER" in /etc/environment

    • Set limits for timeline cleanup to:

      #this is my own
      Hourly=“0”
      Daily=“2”
      Weekly=“4”
      Monthly=“12”
      Yearly=“1” 
      
  • Adding @USER permissions to the snapshots directories:

    chmod a+rw /.snapshots/
    chmod a+rw /home/.snapshots/
    
  • Enable and start snapper services:

    • We need root access

      systemctl start snapper-timeline.timer
      systemctl enable snapper-timeline.timer
      systemctl start snapper-cleanup.timer
      systemctl enable snapper-cleanup.timer
      
  • Enable grub-btrfs services

    • Install grub-btrfs:

      pamac install grub-btrfs
      
    • We need root acces

      systemctl start grub-btrfs.path
      systemctl enable grub-btrfs.path
      
  • List the snapshots created

    • As @USER

      snapper -c list
      
  • Create a snapshot manually:

    • As @USER

        snapper -c create -c timeline --description
      
  • Changing permissions of snapshots

    • By default all snapshots are set as Read-Only

    • Check snapshops permissions as @USER:

      btrfs property list -ts /.snapshots//snapshot/ # for @
      btrfs property list -ts /home/.snapshops//snapshot # for @home
      
    • Changing snaphots permissions to Write

      • We need root acces

        btrfs property set -ts /.snapshots//snapshot/ ro false #for @
        btrfs property set -ts /home/.snaphots//snapshot/ ro false #for @home
        

How-To Convert an ext2/3/4 filesystem in a BTRFS system

  1. Do a full backup of your system, / and /home with Timeshift or other application who use RSYNC
  2. Boot up with a live system
  3. Do the partitioning using btrfs; in my case, I created /boot/efi, / and /home
  • Checking subvolumes

    • We need root acces

      btrfs subvolume list
      
  • Mount / partition

    mount /dev/sdXN /mnt
    btrfs subvolume list /mnt
    
  1. Creating other subvolumes
  • Create BTRFS subvolume for /home

  • With our / partition mounted in /mnt, we’re going to delete the EXT4 /home folder

    rm -rf /mnt/home
    
  • Create the @home subvolume

    btrfs subvolume create /mnt/@home
    
  • Now we can mount the /home partition into the subvolume

    mount /dev/sdXN /mnt/@home
    
  1. Restoring the backup

    • You could use any application or you could use rsync to do it.
  2. Edit /etc/fstab

  • Change the old UUID to the news, the partitions format and mount options

    sudo nano --backup /mnt/etc/fstab
    
  1. Reinstall Grub

    sudo update-grub
    

Source for documentation:
Btrfs Arch Wiki
Snapper Arch Wiki

5 Likes

Please have a look at my edits and disregard anything you don’t like… :wink: (:heart: and :+1: will remain in place even if you revert completely, but this way it’s easier on the :eyes:…)

2 Likes

Hi!
Like you said, It’s easy to see this way. Nothing to add, just Thanks!!!1

1 Like