btrfs convert from raid1 to raid5

1

Is it possible to easily convert a btrfs raid1 to a raid5. I mean at the end of the day. Its really just two mirrored drives. So I would think this should be easy to do. I want to now have 3 3TB drives for 6TB of storage instead of 2 3TB for 3TB. I have also been looking at raid5 support for btrfs and its still marked as experimental, but is it really that bad for a home nas set up? I don't want to lose all my media, but I still want space.

Buttink

Posted 2015-04-13T15:16:24.063

Reputation: 113

check your question. are you converting from raid0 or raid1? – Russell Uhl – 2015-04-13T17:38:04.133

as to your question, raid 5 introduces parity. Not only that, but it is DISTRIBUTED parity. That means a large amount of data needs to be moved around your disks. As for how easy the process is to actually perform, I can't help you there. – Russell Uhl – 2015-04-13T17:42:18.527

@RussellUhl sorry I fixed it. – Buttink – 2015-04-13T20:59:58.007

1lol tfw reading it after june 2016 when btrfs RAID5 implementation turned out to be fatally flawed and unable to rebuild array properly after disk failure... – Lapsio – 2016-09-19T11:24:13.700

@user2111737 Good thing I was to lazy and poor to buy a 3rd hard drive. – Buttink – 2016-09-19T13:46:30.447

I wasn't :| now I have a problem... – Lapsio – 2016-09-19T13:52:09.733

@user2111737 Converting from raid5 to raid1 should be safe, as long as your disks don't break down before the operation is completed. – pipe – 2016-09-26T03:53:54.653

Answers

3

I haven't converted from RAID 1 to RAID 5 in BTRFS, but I have done other BTRFS conversions, and according to the documentation they are all equally easy.

It is as simple as

btrfs balance start -dconvert=raid5 -mconvert=raid5 /mnt

It is not difficult, but it will take some time (many hours).

Yes, RAID5 is still marked as experimental. Per the most recent documentation I can find, scrub still doesn't work with RAID5, so any data errors can't be corrected.

One other approach to consider: with BTRFS RAID1, you can use three 3TB drives to get 4.5TB usable space. Yes, you can do mirroring with an odd number of drives. BTRFS doesn't mirror disks, it mirrors blocks. So, for example, some files will be mirrored on drives 1 and 2, some on 2 and 3, and some on 1 and 3.

You can even have different size drives with BTRFS RAID1. I have a set with one 2TB drive and three 1TB drives, giving 2.5TB usable space.

BTRFS RAID1 is really cool.

Grunthos

Posted 2015-04-13T15:16:24.063

Reputation: 402

I never marked this as the answer ... my bad. I still never did update to raid 5. I'm still waiting for the right moment to buy drives. (cursed money lol) – Buttink – 2016-02-01T19:24:20.420

I personally buy drives by picking the most reliable drives from https://www.backblaze.com/blog/hard-drive-reliability-stats-for-q2-2015/ and buying them on EBay. I recently bought several 2TB Hitachi/HGST 7K2000 for about USD $40 each.

– Grunthos – 2016-02-03T01:51:42.053

1

Yes, it is possible to convert from RAID-1 to RAID-5 or (better RAID-6). For example, you could convert a single btrfs filesystem (one drive) to RAID-1 (2+ drives), then to RAID-5 (3+ drives) and to RAID-6 (4+ drives). In every case, you have to add the new drive first (btrfs device add drive /mnt/point), then rebalance and convert (btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt/point).

However, as useless as this may sound to some people who are used to other technologies that do not offer this feature (after all, why would anyone keep converting raid levels back and forth), this actually offers a huge advantage over other technologies like ZFS: It's possible to add a single drive to an existing RAID-6 volume to increase its capacity by that of this drive. So you could scale up, depending on your storage needs.

It should also be mentioned that RAID-5/RAID-6 should not be used before (kernel) 3.19, as there was no support for error detection/correction back then. Always stick to the latest version when using btrfs. Many will say that the RAID-5/RAID-6 implementation in btrfs is still experimental in some ways, but as long as you take care of your system (scrub every now and then to detect silent corruption), monitor your drives and replace bad drives (btrfs replace, straight forward), you'll end up with a very stable filesystem. (Of course, you should have backups anyway.)

As mentioned earlier, converting to RAID-5 or RAID-6 is done by converting both data and metadata.

basic6

Posted 2015-04-13T15:16:24.063

Reputation: 2 032