btrfs convert from raid1 to raid5

Posted on

Problem :

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.

Solution :

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.

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.

Leave a Reply

Your email address will not be published.