1

I have setup a BTRFS Raid1, I have re-balanced it 2 weeks ago. Now btrfs df said...

root@slackware:~# btrfs filesystem df /mnt Data, RAID1: total=4.14TiB, used=4.08TiB System, RAID1: total=32.00MiB, used=608.00KiB Metadata, RAID1: total=6.00GiB, used=5.20GiB GlobalReserve, single: total=512.00MiB, used=0.00B 

my questions are..suppose I lost one hd, I will lost data? How to check the distribution of data on btrfs raid1? I have to rebalance it using the dusage and musage=50 to obtain a perfect copy?

2
  • 1
    What do you mean by "distribution"? RAID1 is mirroring. Commented Jan 29, 2023 at 5:39
  • 2
    "Balancing" is kinda like defragmentation in Windows. It may change "distribution" of data on the disk(s) in terms of LBA. But that distribution should be the same on every disk of a RAID1. Commented Jan 29, 2023 at 5:43

1 Answer 1

2

If you create your btrfs with 2 hard disks with raid1 metadata and raid1 data that is, example below

mkfs.btrfs -L Test -m raid1 -d raid1 /dev/sda /dev/sdb 

In this case of two hard disks all files will be stored 2 times ( one copy of each file on each hard disk ) and if you remove one hard disk

You can mount (the attached hard disk to ur PC) with:

mount -o degraded /dev/sda /mnt/Test 

You can recover your data here


Now you won't be able to recover your data if you created mkfs.btrfs| and added 3 hard disk at a time with a raid1data andraid1` metadata such as

mkfs.btrfs -L Test2 -m raid1 -d raid1 /dev/sda /dev/sdb /dev/sdc 

In this setting, data is divided and spread on all hard disk such as a 1gb file will be stored as

333 mb on sda 333 mb on sdb 333 mb on sdc 

Sure you can remove 1 hard disk and mount the remaining 1st or 2nd hard disk in degraded but that 300 mb in hard disk which is not connected is not going to be there so just stick with 2 hard disk , do scrub command daily , and all good


The GParted shows true disk usage and btrfs filesystem show command shows somewhat fake disk usage so check disk usage in GParted.

I have been testing btrfs and this test was done on btrfs 5.4.1

update : i just came to know btrfs with raid1c3 can store 3 copies which is ment for 3 hard disk and raid1c4 stores 4 copies which is ment for 4 hard disk

it stores full copy of files and metadata on all hard disks without splitting files

we just need to use

btrfs -L Test -m raid1c3 and -d raid1c3 /dev/sda /dev/sdb /dev/sdc

for creating filesystem for 3 hard disks ( it will delete/format all files in those hard disks when creating this )

or -m raid1c4 -d raidc4 when creating filesystem for 4 hard disks


in raid1c3 or raid1c4 , data can be recovered by mounting the hard disk in degraded option even if other 1 or 2 hard disk are missing

4
  • Huh, so you are saying, if one tries to set up a btrfs raid1 with three disks, it actually ignores your instruction and make a raid0 for you? (This sounds like a bug to me.) Commented Jan 30, 2023 at 0:51
  • @elbarna apparently btrfs raid 1 is something like "mirror on any two": btrfs.wiki.kernel.org/index.php/… Commented Jan 30, 2023 at 8:23
  • @Tom Yan unfortunately yes , i was expecting full copies of all files on all 3 hard disk but it didnt . when i remove 1 hard disk and mounted 1 hard disk in degraded option , it had 3 big 600 mb iso files only 1 file was in good condition , other 2 iso files gave me read error when i tried to create checksum of them Commented Jan 30, 2023 at 21:21
  • 1
    This is not correct. Even in raid1 with 3 devices you still have 2 copies of each data block, thus you can remove one drive and have 100% of data. With raid1c3 you have 3 copies of each data block and thus you can remove two drives (raid1c4 => 4 copies => 3 drives). Have a look at the official documentation btrfs.readthedocs.io/en/latest/mkfs.btrfs.html#profile-layout Commented Mar 28, 2024 at 21:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.