Autodetect
This is about in-kernel autodetection. User-space autodetection is the recommended alternative.
THIS DOES NOT APPLY TO RECENT KERNELS - IN-KERNEL AUTODETECTION HAS BEEN DELETED
Firstly it is worth noting that autodetect, whilst useful in simple situations, can cause real difficulties in more complex environments. It is now deprecated and has been deleted from modern kernels. It should not really be used for new installations. See the RAID Boot page for more details of the suggested approach.
Any md arrays with partition type 0xfd using a 0.9 superblock should be auto-assembled by an ancient (2.6, possibly 3.x, pre-grub2) kernel with the md driver builtin (ie not a module).
Moved from the main overview
If your system still uses autodetect then this requires several things:
- You need autodetection support in the kernel. Check this
- You must be using version 0.9 superblocks (non-persistent or 1.x won't work).
- The partition-types of the devices used in the RAID must be set to 0xFD (use fdisk and set the type to "fd")
NOTE: Be sure that your RAID is NOT RUNNING before changing the
partition types. Use mdadm --stop /dev/md0
to stop the device.
If you set up 1, 2 and 3 from above, autodetection should be set up. Try rebooting. When the system comes up, cat'ing /proc/mdstat should tell you that your RAID is running.
During boot, you could see messages similar to these:
Oct 22 00:51:59 malthe kernel: SCSI device sdg: hdwr sector= 512 bytes. Sectors= 12657717 [6180 MB] [6.2 GB] Oct 22 00:51:59 malthe kernel: Partition check: Oct 22 00:51:59 malthe kernel: sda: sda1 sda2 sda3 sda4 Oct 22 00:51:59 malthe kernel: sdb: sdb1 sdb2 Oct 22 00:51:59 malthe kernel: sdc: sdc1 sdc2 Oct 22 00:51:59 malthe kernel: sdd: sdd1 sdd2 Oct 22 00:51:59 malthe kernel: sde: sde1 sde2 Oct 22 00:51:59 malthe kernel: sdf: sdf1 sdf2 Oct 22 00:51:59 malthe kernel: sdg: sdg1 sdg2 Oct 22 00:51:59 malthe kernel: autodetecting RAID arrays Oct 22 00:51:59 malthe kernel: (read) sdb1's sb offset: 6199872 Oct 22 00:51:59 malthe kernel: bind<sdb1,1> Oct 22 00:51:59 malthe kernel: (read) sdc1's sb offset: 6199872 Oct 22 00:51:59 malthe kernel: bind<sdc1,2> Oct 22 00:51:59 malthe kernel: (read) sdd1's sb offset: 6199872 Oct 22 00:51:59 malthe kernel: bind<sdd1,3> Oct 22 00:51:59 malthe kernel: (read) sde1's sb offset: 6199872 Oct 22 00:51:59 malthe kernel: bind<sde1,4> Oct 22 00:51:59 malthe kernel: (read) sdf1's sb offset: 6205376 Oct 22 00:51:59 malthe kernel: bind<sdf1,5> Oct 22 00:51:59 malthe kernel: (read) sdg1's sb offset: 6205376 Oct 22 00:51:59 malthe kernel: bind<sdg1,6> Oct 22 00:51:59 malthe kernel: autorunning md0 Oct 22 00:51:59 malthe kernel: running: <sdg1><sdf1><sde1><sdd1><sdc1><sdb1> Oct 22 00:51:59 malthe kernel: now! Oct 22 00:51:59 malthe kernel: md: md0: raid array is not clean -- starting background reconstruction
This is output from the autodetection of a RAID-5 array that was not
cleanly shut down (e.g. the machine crashed). Reconstruction is automatically initiated. Mounting this device is perfectly safe, since
reconstruction is transparent and all data are consistent (it's only
the parity information that is inconsistent - but that isn't needed
until a device fails).
Autostarted devices are also automatically stopped at shutdown. Don't worry about init scripts. Just use the /dev/md devices as any other /dev/sd or /dev/hd devices.
Yes, it really is that easy - but it is also full of problems and should be avoided.
How it works
When a kernel with md support builtin boots, md notices any partitions of type 0xfd (raid autodetect) and automatically tries to assemble them into an array. (cfdisk and friends can help you determine the partition types.)
md only considers components with the old (but still default in mdadm 2.5.2) version 0.9 superblocks. This can be checked using mdadm --examine /dev/<component>
The auto-detect and auto-assembly activity happens before the kernel tries to mount the root partition which can make having root on raid very easy.
The newer RAID superblock formats supporting named devices etc will not auto-assemble.
So an autodetect checklist:
- are the partitions 0xfd ?
- is the kernel standard?
- is the md device builtin and not a module?
- are the superblocks version 0.9?
Note that the boot-loader must be able to read the kernel image and AFAIK the only RAID type supported by a bootloader is RAID 1 on grub. This is nothing to do with auto-assembly.