btrfs convert from raid1 to raid5

5,899

Solution 1

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.

Solution 2

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.

Share:
5,899

Related videos on Youtube

David Stocking
Author by

David Stocking

Updated on September 18, 2022

Comments

  • David Stocking
    David Stocking over 1 year

    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.

    • Russell Uhl
      Russell Uhl about 9 years
      check your question. are you converting from raid0 or raid1?
    • David Stocking
      David Stocking about 9 years
      @RussellUhl sorry I fixed it.
    • Lapsio
      Lapsio over 7 years
      lol 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...
    • David Stocking
      David Stocking over 7 years
      @user2111737 Good thing I was to lazy and poor to buy a 3rd hard drive.
    • Lapsio
      Lapsio over 7 years
      I wasn't :| now I have a problem...
    • pipe
      pipe over 7 years
      @user2111737 Converting from raid5 to raid1 should be safe, as long as your disks don't break down before the operation is completed.
  • David Stocking
    David Stocking over 8 years
    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)
  • Grunthos
    Grunthos over 8 years
    I personally buy drives by picking the most reliable drives from 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.
  • lunarfyre
    lunarfyre almost 4 years
    It's safer to use raid1 for metadata. btrfs balance start -dconvert=raid5 -mconvert=raid1 /mnt