Skip to content

Instantly share code, notes, and snippets.

@pjobson
Last active October 19, 2021 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjobson/08bdef73402d982c88defe4eead95ccd to your computer and use it in GitHub Desktop.
Save pjobson/08bdef73402d982c88defe4eead95ccd to your computer and use it in GitHub Desktop.
btrfs notes

Filesystem Creation

Create a filesystem across four drives (metadata mirrored, linear data allocation)

mkfs.btrfs -d single /dev/sdb /dev/sdc /dev/sdd /dev/sde

Stripe the data without mirroring, metadata are mirrored

mkfs.btrfs -d raid0 /dev/sdb /dev/sdc

Use raid10 for both data and metadata

mkfs.btrfs -m raid10 -d raid10 /dev/sdb /dev/sdc /dev/sdd /dev/sde

Don't duplicate metadata on a single drive (default on single SSDs)

mkfs.btrfs -m single /dev/sdb

Balance

https://www.thegeekdiary.com/how-to-check-btrfs-filesystem-usage-and-perform-balancing/

Balance bash script.

#!/bin/bash

for i in 0 5 10 15 20 25 30 40 50 60 70 80 90 100
do
  echo "${0}: Running with ${i}%"
  btrfs balance start -dusage=$i -musage=$i /dvr
done

Delete Disk

btrfs device remove /dev/sdb /dvr

Monitor Device Delete

https://www.reddit.com/r/btrfs/comments/d1pdun/how_can_i_monitor_disk_deletion_progress/

btrfs / watch

sudo watch -d btrfs filesystem usage /dvr

Should show the deleted drive reducing in size.

dmesg

sudo dmesg -w

Should show you output messages like:

[1211252.120882] BTRFS info (device sdb): relocating block group 83273458581504 flags data|raid0
[1211280.334447] BTRFS info (device sdb): found 1439 extents
[1211291.661672] BTRFS info (device sdb): found 1439 extents

iotop

sudo iotop

Should show you the active process.

 8462 be/4 root        0.00 B/s   48.74 M/s  0.00 %  2.15 % btrfs device remove /dev/sdb /dvr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment