Skip to content

Instantly share code, notes, and snippets.

@salihmarangoz
Last active July 23, 2023 15:48
Show Gist options
  • Save salihmarangoz/4b7efc0fe24d207f8c22fe5114b9c72a to your computer and use it in GitHub Desktop.
Save salihmarangoz/4b7efc0fe24d207f8c22fe5114b9c72a to your computer and use it in GitHub Desktop.
My Backup Drive Notes - Seagate 4TB - LUKS+BTRFS

Salih - Seagate 4TB - BTRFS

My Seagate 4TB backup hard drive (LUKS+BTRFS) instructions.

Introduction

  • Never eject without safe unmount.
  • Setup on the new machine to enable on-the-fly compression.
  • De-duplication can save a lot of space.
  • Snapshots are useful for rollback.

Setup on New Machine (on-the-fly-compression)

Edit fstab:

$ sudo nano /etc/fstab

Add this line: (Note: zstd:15 is super slow but I think it is suitable for a backup medium)

/dev/disk/by-uuid/b2851dc0-ad02-423c-b828-2fae57109dfb /mnt/Salih4TB auto nosuid,nodev,nofail,x-gvfs-show,noatime,compress-force=zstd:15,noauto 0 0

Run to refresh mount info:

$ sudo mount -a

Unmount and mount the device again.

Disk Usage Statistics

$ sudo compsize /mnt/Salih4TB

Deduplication

$ duperemove -dr --hashfile=/mnt/Salih4TB/.backup/duperemove.hash /mnt/Salih4TB

Snaphots

# Take a snapshot named with the current time
$ sudo btrfs subvolume snapshot -r /mnt/Salih4TB /mnt/Salih4TB/.snapshots/$(date +"%Y_%m_%d_%H_%M")

# Remove a snapshot
$ sudo btrfs subvolume delete /mnt/Salih4TB/.snapshots/2023_07_23_14_53

Bad Blocks Test

# Unmount the drive before the test
$ sudo badblocks -v /dev/sdb # read-only

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ sudo badblocks -vn /dev/sdb # read-write !!!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

First Setup of the Device

Format the device with BTRFS + LUKS. After completing Setup on New Machine...

$ mkdir /mnt/Salih4TB/.snapshots
$ sudo btrfs subvolume create /mnt/Salih4TB/.backup
$ sudo chattr +C /mnt/Salih4TB/.backup # noCOW
$ sudo chown $USER:$USER /mnt/Salih4TB/.backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment