Re: raid1 on uneven-sized disks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 9, 2015 at 8:47 AM, Hugo Mills <hugo@xxxxxxxxxxxxx> wrote:
> On Sun, Aug 09, 2015 at 02:29:53PM +0200, Jim MacBaine wrote:
>> Hi,
>>
>> How does btrfs handle raid1 on a bunch of uneven sized disks? Can I
>> just keep adding arbitrarily sized disks to an existing raid1 and
>> expect the file system to continue to keep two copies of everything,
>> so I could survive the loss of any single disk without data loss? Does
>> btrfs work this way?
>
>    Yes, exactly.
>
>    You may find that http://carfax.org.uk/btrfs-usage/ is helpful.
>

The key is that btrfs manages "raid" at the chunk level, not the
device level.  When btrfs needs more disk space it allocates a new
chunk from unallocated space on a device.  If it is in raid1 mode it
will allocate a pair of chunks from two different drives, storing the
same data in each.  The allocation algorithm is reasonably smart so if
you have 2x1TB drives and 1x3TB drive you'll end up with about 2TB of
data stored and not 1TB on each of the two 1TB drives and an empty
unusable 3TB drive.

This is also why you can switch between raid modes "on the fly" -
switching modes only affects newly-allocated chunks, and the old ones
operate in whatever mode they were previously in.  A balance operation
rewrites the existing data to new chunks which would force everything
to use the new mode.

This also lets you do things like add a disk to a raid5.  If you have
5 disks and add one more, existing chunks will be striped across 5
drives, and new chunks will be striped across 6, unless you balance
them.

That may be a bit oversimplified, and obviously others on the list
know all the details...

--
Rich
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux