BTRFS#

See also

  • Using Btrfs with Multiple Devices - btrfs Wiki [1]

  • Btrfs - ArchWiki [2]

  • Btrfs/Checksum Algorithms - Forza’s ramblings [3]

RAID#

Commands#

These examples assume that a RAID 1 BTRFS array (not BTRFS over mdadm RAID) is mounted on /data.

Note

After creating, adding or removing devices from an array always run the balance operation. You may want to use GNU screen to put the process in background, like this

apt-get install screen
screen btrfs balance start /data

Create#

  1. create the array

    mkfs.btrfs --csum xxhash -m raid1 -d raid1 /dev/sda1 /dev/sdb1
    
  2. mount normally

    mount /dev/sdb1 /data
    
  3. To add new partitions, for example /dev/sdc1 and /dev/sdd1, run

    btrfs device add /dev/sdc1 /dev/sdd1 /data
    
  4. run the balance operation

Removing devices#

  1. remove two devices at the same time

    btrfs device delete /dev/sdc1 /dev/sdd1 /data
    
  2. run the balance operation

Replace a device#

  1. replace /dev/old with /dev/new. This operation should run in background

    btrfs replace start /dev/old /dev/new /data
    
  2. check

    btrfs replace status /data
    

Convert metadata profile#

You can clone partitions with dd from HDDs to SSDs. After that run:

screen btrfs balance start -v -mconvert=single /data

Check usage#

btrfs filesystem usage /data
btrfs filesystem df /data

Footnotes