Debian has a BTRFS Wiki. One item there, which affected me, is that kernel 4.11 has issues and will cause corruption. I am now on kernel 4.12. I'm not sure if having duplicated metadata would have prevented some of the pain of recovery. To see if metadata is redundant:
btrfs fi df /
Data, single: total=14.00GiB, used=12.63GiB
System, single: total=32.00MiB, used=16.00KiB
Metadata, single: total=520.00MiB, used=317.27MiB
GlobalReserve, single: total=31.22MiB, used=0.00B
This is on laptop with a single ssd. It has been written elsewhere, that even if metadata duplication is requested, the ssd may deduplicate it anyway.
So... regular maintenance and scanning is recommended.
For maintenance, the wiki article suggests regular defragmentation (the -t 32M is not needed since Debian 9 (Stretch):
sudo ionice -c idle btrfs filesystem defragment -f -t 32M -r $PATH
The -f parameter is recommended for flushing after each file, particularly when there are snapshots or reflinked files.
One way to find btrfs formatted file systems:
# grep btrfs /etc/fstab
UUID=b5714bf3-eec4-431d-8e3e-6b062f7e5c55 / btrfs noatime,nodiratime 0 0
UUID=affc8ed9-c1c0-403d-8ba1-b8ca68d2d7d7 /var btrfs noatime,nodiratime 0 0
UUID=b662aa71-5b72-4028-a10a-e286c56b87cf /home/rpb btrfs noatime,nodiratime 0 0
To check for errors:
# btrfs dev stats /home
[/dev/nvme0n1p2].write_io_errs 0
[/dev/nvme0n1p2].read_io_errs 0
[/dev/nvme0n1p2].flush_io_errs 0
[/dev/nvme0n1p2].corruption_errs 0
[/dev/nvme0n1p2].generation_errs 0
To manually initiate an online scrub and monitor status:
# btrfs scrub start /mnt
scrub started on /mnt, fsid ab27f528-d417-4ff9-9eb4-b59ad940290f (pid=14535)
# btrfs scrub status /mnt
scrub status for ab27f528-d417-4ff9-9eb4-b59ad940290f
scrub started at Sun Sep 24 19:55:56 2017, running for 00:00:10
total bytes scrubbed: 2.08GiB with 0 errors
A scrub with detailed results running in foreground:
# btrfs scrub start -B -d -R /
scrub device /dev/nvme0n1p2 (id 1) done
scrub started at Sun Oct 8 12:16:54 2017 and finished after 00:00:05
data_extents_scrubbed: 373524
tree_extents_scrubbed: 20306
data_bytes_scrubbed: 13566894080
tree_bytes_scrubbed: 332693504
read_errors: 0
csum_errors: 0
verify_errors: 0
no_csum: 25579
csum_discards: 0
super_errors: 0
malloc_errors: 0
uncorrectable_errors: 0
unverified_errors: 0
corrected_errors: 0
last_physical: 15590227968
Useful BTRFS pages:
Continue reading "BTRFS on Debian" »