How does one enable --write-mostly with Linux RAID?

Unfortunately the mdadm and mdadm.conf man pages are not quite up to par. I would like to enable the --write-mostly flag for my RAID, but neither the man pages nor the internet will tell me how. I am not aware of any place to put default arguments for mdadm, nor aware of when it would be launched and by what.

It seems the logical place to add this information is mdadm.conf, but the flag is unmentioned in man mdadm.conf. Where and how can I enable --write-mostly? Thank you.


You can set a device to be write mostly with, for example,

echo writemostly > /sys/block/md0/md/dev-sda1/state

and clear the write-mostly status with

echo -writemostly > /sys/block/md0/md/dev-sda1/state

Note that you probably need to be root for this to succeed, and that

sudo echo state > /sys/block/md0/md/dev-sda1/state

won't work.

If you have other questions about mdadm or Linux Software RAID, please post them to

[email protected]

(you do not need to be subscribed).

The kernel panic bug that you mentioned in your answer is fixed in Linux kernel versions released in Jan 2012 and later – 3.1.10, 3.2.2, and 3.3-rc1. It only affected arrays in which all devices are 'write-mostly'.


It's been over a week, so to answer my own question:

Apparently you pass it as a command-line argument to mdadm when you create a new RAID array; just take the example in the man page and add --write-mostly. The man page says all devices after it will have write-mostly enabled; this is vague language so I can only assume it means the reasonable thing: that it applies to the next argument.

On kernel 3.1 (released Oct 2011), however, trying --write-mostly / --write-behind triggered a panic in [something...]scsi.c during some critical step, and destroyed my RAID array.

Also if you are splitting your array, make sure you know what you're doing. I found that my array had new UUIDs (possibly due to a new major metadata version) and was unsure how to proceed.