Skip to content

Latest commit

 

History

History
114 lines (99 loc) · 2.64 KB

btrfs.md

File metadata and controls

114 lines (99 loc) · 2.64 KB

Get infos about your btrfs filesystem

btrfs filesystem show
btrfs filesystem usage /mnt/data

Wipe some drives !! caution !!

wipefs --all -t btrfs /dev/sdX /dev/sdX

Create a raid 1 and mount it (btrfs does not supports raid5 well - discouraged)

mkfs.btrfs -m raid1 -d raid1 /dev/sdX /dev/sdX
mkdir /mnt/data
mount /dev/sdX /mnt/data
btrfs device usage /mnt/data/

Mount in fstab:

  • identify the btrfs UUID
btrfs filesystem show | grep uuid
nano /etc/fstab

add the folowwing

UUID=$youruuid /mnt/data         btrfs   defaults,nofail      0  0

Replace a drive:

  • File system has to be mounted.
mount -o degraded /dev/sdX /mnt/data
  • Identify the ID of the missing drive with
btrfs filesystem show
btrfs device usage /mnt/data | grep missing

In this case, the missing drive is the "1" as i have devid 2 and my raid is raid1

        Total devices 2 FS bytes used 1.00GiB
        devid    2 size 3.00GiB used 1.49GiB path /dev/sdd
        *** Some devices missing

Add new drive to system and wipe it if needed

btrfs replace start $id /dev/newdrivepath  /mnt/data

Check progress:

btrfs replace status /mnt/data

Check again using "btrfs filesystem show" that the drive has been correctly replaced After a disk has been failing or being replaced, rebalance the data

btrfs filesystem balance /mnt/data

image image

Grow filesystem

If you replaced drive with bigger ones you can grow your filesystem on every drive:

btrfs filesystem resize 1:max /mnt/btrfs/
btrfs filesystem resize 2:max /mnt/btrfs/

Status before:

lsblk
sde      8:64   0   6G  0 disk /mnt/btrfs
sdf      8:80   0   6G  0 disk
Label: none  uuid: 706e4f5a-c829-45f4-a8aa-56375ea4d850
        Total devices 2 FS bytes used 256.00KiB
        devid    1 size 3.00GiB used 896.00MiB path /dev/sde
        devid    2 size 3.00GiB used 896.00MiB path /dev/sdf

Status after:

Label: none  uuid: 706e4f5a-c829-45f4-a8aa-56375ea4d850
        Total devices 2 FS bytes used 256.00KiB
        devid    1 size 6.00GiB used 608.00MiB path /dev/sde
        devid    2 size 6.00GiB used 608.00MiB path /dev/sdf

Sources and links:

https://wiki.tnonline.net/w/Btrfs/Replacing_a_disk#Status_monitoring https://btrfs.readthedocs.io/en/latest/btrfs-replace.html