17

To my surprise the CentOS 7 installer allowed me to create a RAID0 device consisting of roughly a 17 GB disk and a 26 GB disk. I would've expected that even if it allows that, that the logical size would be 2 * min(17 GB, 26 GB) ~= 34 GB. Yet I can really see a usable size of 44 GB on the filesystem level:

$ cat /sys/block/md127/md/dev*/size
16955392
26195968
$ df -h |grep md
/dev/md127   44G 1.9G 40G 5% /

How will the md subsystem behave performance wise, compared to a situation where the disks are equal? As it's impossible to do a straightforward balanced stripe across 2 disks.

4
  • 1
    More of a question out of curiosity, than related to answering your question: are these two disks something like SD cards? These are surprisingly diminutive for something you'd risk using in a RAID 0! Jan 25, 2022 at 13:04
  • Awkward sizes for SD cards too! They often seem to be (approximate) powers of two in size.
    – ilkkachu
    Jan 25, 2022 at 13:07
  • 4
    @MarcusMüller no this is part of a QA suite for pxe/network installs and uses virtual machines with relatively small virtualized block devices.
    – hbogert
    Jan 25, 2022 at 13:24
  • @hbogert cool stuff :) Jan 25, 2022 at 13:27

3 Answers 3

26

raid.wiki.kernel.org says:

RAID0/Stripe Mode: The devices should (but don't HAVE to) be the same size. [...] If one device is much larger than the other devices, that extra space is still utilized in the RAID device, but you will be accessing this larger disk alone, during writes in the high end of your RAID device. This of course hurts performance.

That's a bit awkward phrasing, but the Wikipedia page for mdadm puts it like this:

RAID 0 – Block-level striping. MD can handle devices of different lengths, the extra space on the larger device is then not striped.

So, what you get probably looks like this, for a simplified case of two disks of 4 and 2 "blocks" in size:

disk0  disk1
00     01
02     03
04
05

Reading "blocks" 04-05 would have to be done just from disk0, so no striping advantage there. md devices should be partitionable, so you could probably test with partitions at the start and at the end of the device to see if the speed difference becomes evident.

0
11

From the man pages of md(4):

   The RAID0 driver assigns the first chunk of the array to the
   first device, the second chunk to the second device, and so on
   until all drives have been assigned one chunk.  This collection
   of chunks forms a stripe.  Further chunks are gathered into
   stripes in the same way, and are assigned to the remaining space
   in the drives.

   If devices in the array are not all the same size, then once the
   smallest device has been exhausted, the RAID0 driver starts
   collecting chunks into smaller stripes that only span the drives
   which still have remaining space.
4

Yes, performance suffers. In your case you have two partitions on two disks, the first partition is 17GB while the second is 26G.

The resulting size of the raid0 disk is around 17+26=43GB. When writing to the first 2*17=34GB performance is as usual: roughly double that of a single disk, assuming the bus throughput is sufficient. When writing to the last 26-17=9GB, performance is the same as a single disk.

So if you use raid0 mostly for performance reasons, significant differences between partition sizes should be avoided.

If you use it just like a convenient way of creating a larger partition out of smaller partitions, then that will not generally a problem. In this case, you will have the added benefit of some performance gain. If you don't care about performance, use linear instead of raid0, to make data recovery easier in case of a hardware failure.

2
  • I wonder if there'd be any point in the md driver supporting size ratios like 3 blocks from one disk to 1 block from the other disk (so each group of blocks is still a small power of 2 in size). Or a 3:5 split or something. Probably there aren't enough use-cases for it to be worth implementing and tuning, and building a config interface to let user-space set up such a RAID. And to store the metadata details on disk in the superblock. Jan 26, 2022 at 3:41
  • @PeterCordes storage stacks like powe-of-2 blocks much better in regard to both performance and wear.
    – fraxinus
    Jan 26, 2022 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .