Skip to content

btrfs

check and scrub btrfs filesystem

scrub

this just checks checksums of the data, it does not repair a filesystem

start the process:

sudo btrfs scrub start /

check the status:

sudo btrfs scrub status /

check

should be done on a readonly or not mounted filesystem, however it can be run on a mounted filesystem as well, with the --readonly and --force flag you can make sure that nothing will be modified:

btrfs check --readonly --force /dev/md0

resizing btrfs filesystems

to max:

btrfs filesystem resize max /

by gb:

btrfs filesystem resize +10g /

managing btrfs snapshots

you should use them more often, perhaps in combination with a a backup tool

snapshot utilities

  • snapper - automatically create snapshots based on a configuration
  • snap-sync - send snapshots to a target destination, another disk locally, ssh etc.

list snapshots

sudo btrfs subvolume list /

get more information about a snapshot

btrfs subvol show /.snapshots/1236/snapshot/

create a read only snapshot

sudo btrfs subvolume snapshot / /my_snapshot # root partition
sudo btrfs subvolume snapshot /mnt /mnt/my_snapshot # partition mounted at /mnt

delete btrfs snapshot

sudo btrfs subvolume delete /my_snapshot
sudo btrfs subvolume delete /mnt/my_snapshot

btrfs raid configuration

convert raid levels, from raid0 to raid1

btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt

raid1

with kernel version 5.5+ raid1c3 can be used for the metadata (-m)

mkfs.btrfs -m raid1 -d raid1 /dev/sdb /dev/sdc