Finally have btrfs setup in RAID1
By EricMesa
- 3 minutes read - 441 wordsA little under 3 years ago, I started exploring btrfs for its ability to help me limit data loss. Since then I’ve implemented a snapshot script to take advantage of the Copy-on-Write features of btrfs. But I hadn’t yet had the funds and the PC case space to do RAID1. I finally was able to implement it for my photography hard drive. This means that, together with regular scrubs, I should have a near miniscule chance of bit rot ruining any photos it hasn’t already corrupted.
Here’s a documentation of some commands and how I got the drives into RAID1:
Before RAID:
# btrfs fi df -h /media/Photos
Data, single: total=2.31TiB, used=2.31TiB
System, DUP: total=8.00MiB, used=272.00KiB
System, single: total=4.00MiB, used=0.00B
Metadata, DUP: total=3.50GiB, used=2.68GiB
Metadata, single: total=8.00MiB, used=0.00B
GlobalReserve, single: total=512.00MiB, used=0.00B
# btrfs fi usage /media/Photos
Overall:
Device size: 2.73TiB
Device allocated: 2.32TiB
Device unallocated: 423.48GiB
Device missing: 0.00B
Used: 2.31TiB
Free (estimated): 425.29GiB (min: 213.55GiB)
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 512.00MiB (used: 5.64MiB)
Data,single: Size:2.31TiB, Used:2.31TiB
/dev/sdd1 2.31TiB
Metadata,single: Size:8.00MiB, Used:0.00B
/dev/sdd1 8.00MiB
Metadata,DUP: Size:3.50GiB, Used:2.68GiB
/dev/sdd1 7.00GiB
System,single: Size:4.00MiB, Used:0.00B
/dev/sdd1 4.00MiB
System,DUP: Size:8.00MiB, Used:272.00KiB
/dev/sdd1 16.00MiB
Unallocated:
/dev/sdd1 423.48GiB
[root@supermario ~]# btrfs device add /dev/sda1 /media/Photos/
/dev/sda1 appears to contain an existing filesystem (btrfs).
ERROR: use the -f option to force overwrite of /dev/sda1
[root@supermario ~]# btrfs device add /dev/sda1 /media/Photos/ -f
[root@supermario ~]# btrfs fi usage /media/Photos
Overall:
Device size: 6.37TiB
Device allocated: 2.32TiB
Device unallocated: 4.05TiB
Device missing: 0.00B
Used: 2.31TiB
Free (estimated): 4.05TiB (min: 2.03TiB)
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 512.00MiB (used: 0.00B)
Data,single: Size:2.31TiB, Used:2.31TiB
/dev/sdd1 2.31TiB
Metadata,single: Size:8.00MiB, Used:0.00B
/dev/sdd1 8.00MiB
Metadata,DUP: Size:3.50GiB, Used:2.68GiB
/dev/sdd1 7.00GiB
System,single: Size:4.00MiB, Used:0.00B
/dev/sdd1 4.00MiB
System,DUP: Size:8.00MiB, Used:272.00KiB
/dev/sdd1 16.00MiB
Unallocated:
/dev/sda1 3.64TiB
/dev/sdd1 423.48GiB
[root@supermario ~]# btrfs balance start -dconvert=raid1 -mconvert=raid1 /media/Photos/
Done, had to relocate 2374 out of 2374 chunks
Post-RAID:
[root@supermario ~]# btrfs fi usage /media/Photos
Overall:
Device size: 6.37TiB
Device allocated: 4.63TiB
Device unallocated: 1.73TiB
Device missing: 0.00B
Used: 4.62TiB
Free (estimated): 891.01GiB (min: 891.01GiB)
Data ratio: 2.00
Metadata ratio: 2.00
Global reserve: 512.00MiB (used: 0.00B)
Data,RAID1: Size:2.31TiB, Used:2.31TiB
/dev/sda1 2.31TiB
/dev/sdd1 2.31TiB
Metadata,RAID1: Size:7.00GiB, Used:2.56GiB
/dev/sda1 7.00GiB
/dev/sdd1 7.00GiB
System,RAID1: Size:64.00MiB, Used:368.00KiB
/dev/sda1 64.00MiB
/dev/sdd1 64.00MiB
Unallocated:
/dev/sda1 1.32TiB
/dev/sdd1 422.46GiB
[root@supermario ~]# btrfs fi df -h /media/Photos
Data, RAID1: total=2.31TiB, used=2.31TiB
System, RAID1: total=64.00MiB, used=368.00KiB
Metadata, RAID1: total=7.00GiB, used=2.56GiB
GlobalReserve, single: total=512.00MiB, used=0.00B
And here’s the status of my first scub to test out the commands:
[root@supermario ~]# btrfs scrub status /media/Photos/
scrub status for 27cc1330-c4e3-404f-98f6-f23becec76b5
scrub started at Tue Mar 21 17:18:13 2017, running for 00:09:10
total bytes scrubbed: 145.57GiB with 0 errors