Everything I know about Linux software raid (mdadm)
I hope this post could help some people when dealing with Linux software RAID (mdadm).
- Recently, mdadm is updated to use metadata 1.2 as default, be careful when you try to recover your software raid which created by older version of mdadm. Look at the option ‘-e’, try ‘-e 0.90’
- Newer mdadm will use 512KB as chunk size as default VS 64KB as before, be careful when rebuild your old array in newer system. Look at the option ‘-c’.
- Recover your array may using following command: e.g.,
mdadm -C /dev/md0 -l 5 -n 4 -e 0.90 -c 64 --assume-clean missing /dev/sda4 /dev/sdb4 /dev/sdd4
- New system will use md126, md127 as the device name for the array when boot up, anyway I overcome the problem by using ‘name’ instead of ‘number’ as the device name, e.g.,
-
mdadm -C /dev/md/storage -l 1 -n 2 --assume-clean /dev/sda2 /dev/sdb2 -N 'storage'
- However, the real device will be appear as /dev/md/[hostname]:storage, the problem seem mdadm will make the device prefix with hostname when the homehost of the array if difference from the metadata. You may get rid of the hostname part by specify homehost value in mdadm.conf.
- When you cat /proc/mdstat, you may get a array marked ‘auto-read-only’. You may feel free to ignore it since it will become read-write after the first write to the array.
- When your root device is a software raid, remember tag it as ‘Linux autoraid’ using fdisk or sfdisk similar tools, otherwise, Linux will not form the raid when it boot. After system has mounted the filesystem, all other raid partition could be form by reading mdadm.conf, if they are not marked as Linux RAID autodetect.