This page describes procedures in Ubuntu 10.04 primarily, though chances are they'll work in many other Linux distributions as well.
For those of you running Linux RAID, by default it does regular consistency checks (once a month) on the drives. This takes a lot of I/O, so you will want to limit it unless you're sure it'll be running at a convenient time. For my system, 5000 KBps seems to be a good choice, put this in rc.local :
echo 5000 > /proc/sys/dev/raid/speed_limit_max
The completion time becomes another story at this point though, so consider this carefully. Or you may even want to control the speed dynamically somehow.
See md(4) man page for details.
An example on how to create a new array (without rebooting, thanks to a tip I found):
# fdisk /dev/sda # create a new partition of type "fd" (Linux RAID autodetect)
# fdisk /dev/sdb # ditto, using the same parameters (specifically, the same size if we want to have RAID1)
# partprobe
# mdadm --create /dev/mdX --level=1 --raid-devices=2 /dev/sd[ab]Y # (RAID1, or mirror, with two disks.) Replace X and Y, of course
It is probably wise to update mdadm.conf in case of trouble at a later point (in fact not doing so may prevent automatic mounting on boot!), I'll let another article go into these particulars and some other details. Oh, and don't forget to edit /etc/fstab as appropriate. For regular file systems you may want something like:
UUID=UUID-HERE /PATH-HERE ext4 relatime 0 2
If you don't know the UUID, try:
$ file -s /dev/mdX
That command will give you information such as the UUID and the file system type for Ext2, Ext3, Ext4, swap partitions etc. For a mounted Ext3+ partition you may get a warning like "needs journal recovery", e.g. like one of the following: (irrelevant details removed)
/dev/mdX: Linux rev 1.0 ext3 filesystem data, UUID=... (needs journal recovery) (large files)
/dev/mdY: Linux rev 1.0 ext4 filesystem data, UUID=... (needs journal recovery) (extents) (large files) (huge files)
When unmounted normally it should instead read respectively:
/dev/mdX: Linux rev 1.0 ext3 filesystem data, UUID=... (large files)
/dev/mdY: Linux rev 1.0 ext4 filesystem data, UUID=... (extents) (large files) (huge files)
Alternatively, if you need just the UUID, try:
$ ls -l /dev/disk/by-uuid
or:
$ sudo blkid /dev/mdX # you can skip sudo if the ID is already in the cache (in fact you could just type blkid then to print what's in the cache)
Information for Ext* file systems can be retrieved with:
$ sudo tune2fs -l /dev/mdX
As always when doing sensitive data operations such as repartitioning, make sure to have any backups you need and so on. Be careful!
The partprobe command (reload the partition table) is what I picked up from the blog post I linked to above. If you forget this part (or do not reboot), you may get an error like:
mdadm: You haven't given enough devices (real or missing) to create this array
when trying to create the array with mdadm. Make sure that the files (/dev/sd[ab]Y) really exist.
The rest will happen in the background, so watch the progress by checking /proc/mdstat .
After it is complete, you can go ahead and use mkfs or the like to build a file system on your new RAID partition (/dev/mdX).