Making Software RAID 0 Arrays in Modern Linux
With a new disk, you have to prepare or create partitions, using the parted command.
For md RAID arrays here is only a need for a single partition (ie, number 1, as in /dev/sdc1).
See the following web page on preparation (but not for mdadm, since this page used raidtools instead):
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID
It summarizes as follows:
Prepare The Partitions With FDISK:
fdisk /dev/sdc
Use FDISK Help (command is m)
Set The ID Type To FD
Make Sure The Change Occurred (command p yields the next two lines)
Device Boot Start End Blocks Id System
/dev/sdc1 1 48641 390708801 fd Linux raid autodetect
Save The Changes (command is w)
To recreate a new array, first unmount the old array.
To disassemble the old array (temporarily):
[root@mps-pc10 ~]# mdadm --stop /dev/md0
To verify that array is temporarily disassembled:
[root@mps-pc10 ~]# cat /proc/mdstat
Personalities : [raid0]
unused devices: <none>
To look at component disks in old array:
[root@mps-pc10 ~]# mdadm --query /dev/md0
/dev/md0: is an md device which is not active
[root@mps-pc10 ~]# mdadm --examine /dev/sdd1
/dev/sdd1:
Magic : a92b4efc
Version : 00.90.00
UUID : 023c49a0:72d521d1:223c6636:4abdbfc7
Creation Time : Mon May 8 17:36:39 2006
Raid Level : raid0
Device Size : 390708736 (372.61 GiB 400.09 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 0
Update Time : Mon May 8 17:36:39 2006
State : dirty
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Checksum : 2b4167f3 - correct
Events : 0.1
Chunk Size : 64K
Number Major Minor RaidDevice State
this 3 8 49 3 active sync /dev/sdd1
0 0 8 1 0 active sync /dev/sda1
1 1 8 17 1 active sync /dev/sdb1
2 2 8 33 2 active sync /dev/sdc1
3 3 8 49 3 active sync /dev/sdd1
[
Making a new smaller md array:
[root@mps-pc10 ~]# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: /dev/sda1 appears to contain an ext2fs file system
size=1562834944K mtime=Wed Jul 12 20:11:41 2006
mdadm: /dev/sda1 appears to be part of a raid array:
level=0 devices=4 ctime=Mon May 8 17:36:39 2006
mdadm: /dev/sdb1 appears to be part of a raid array:
level=0 devices=4 ctime=Mon May 8 17:36:39 2006
Continue creating array? y
mdadm: array /dev/md0 started.
[root@mps-pc10 ~]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdb1[1] sda1[0]
781417472 blocks 64k chunks
unused devices: <none>
To create a filesystem on the new smaller md0 and run the badblocks program.
mke2fs -b 4096 -c -j -T largefile4 -v /dev/md0
I wanted to have a journal on these filesystems, so the second one (/dev/md1, made from /dev/sd[cd]1) is done with the ext3 option
(I believe that this is equivalent to adding -j to the above command line).
mkfs.ext3 -b 4096 -c -T largefile4 -v /dev/md1
Finally, all you have to do is to edit /etc/fstab to make things mount automatically. Fist mount them by hand and test.
The only thing that I did not do is to use the -R option in mke2fs. I thought that the default was probably fine, but maybe this is a problem. But the web page said as follows:
Format The New RAID Set
Your new RAID device now has to be formatted. The next example uses the -j qualifier to ensure that a journaling filesystem is created. Here a block size of 4KB (4096 bytes) is used with each chunk, which is comprised of 8 blocks. It is very important that the chunk-size parameter in the /etc/raidtab file match the value of the block size multiplied by the stride value in the command below. If the values don't match, you will get parity errors:
[root@bigboy tmp]# mke2fs -j -b 4096 -R stride=8 /dev/md0
I think that mdadm takes care of this automatically, by default.
To check for bad blocks on the fielsystem, run
e2fsck -c -c -k -C -y /dev/md1
The filesystem MUST be unmounted before checking for bad blocks.