Raid0LayoutMigration

Multi-Zone RAID0 Layout Migration

An unintentional RAID0 layout change was introduced in the v3.14 kernel. This effectively means there are 2 different layouts Linux will use to write data to RAID0 arrays in the wild - the "pre-3.14" way and the "3.14 and later" way. Mixing these layouts by writing to an array while booted on these different kernel versions can lead to corruption.

Note that this only impacts RAID0 arrays that include devices of different sizes. If your devices are all the same size, both layouts are equivalent, and your array is not at risk of corruption due to this issue.

Unfortunately, the kernel cannot detect which layout was used for writes to pre-existing arrays, and therefore requires input from the administrator. This input can be provided via the kernel command line with the raid0.default_layout=<N> parameter, or by setting the default_layout module parameter when loading the raid0 module. You can also set the layout version when assembling a stopped array using an updated mdadm. For example:

  mdadm --stop /dev/md0
  mdadm --assemble -U layout-alternate /dev/md0 /dev/sda1 /dev/sda2

See the mdadm manpage for more details. Once set in this manner, the layout will be recorded in the array and will not need to be explicitly specified in the future.

The following table shows the minimum version of mdadm required for the associated Ubuntu release:

Release

mdadm Version

19.10

Not yet available

19.04

Not yet available

18.04 LTS

Not yet available

16.04 LTS

Not yet available

14.04 ESM

Not yet available

Which layout version should I use?

If your RAID array has only been written to by a 3.14 or later kernel, then you should specify default_layout=2, or set layout-alternate in mdadm. If your kernel has only been written to by a < 3.14 kernel, then you should specify default_layout=1 or set layout-original in mdadm. If the array may have already been written to by both kernels < 3.14 and >= 3.14, then it is possible that your data has already suffered corruption. Note that mdadm --detail will show you when an array was created, which may be useful in helping determine the kernel version that was in-use at the time.

When determining the scope of corruption, it may also be useful to know that the area susceptible to this corruption is limited to the area of the array after "MIN_DEVICE_SIZE * NUM DEVICES".

For new arrays you may choose either layout version. Neither version is inherently better than the other.

Kernel/Raid0LayoutMigration (last edited 2020-01-28 20:10:52 by dannf)