Now we are ready to create 2 raids on disk hda. First we have to partition our hda disk like the hdc. It's not necessary to make the partitions on hda the same size as on hdc, but i recomment it because it's easier to manage. Set the partition type to "FD" (raid autodetect). AFAIK this is not really neccessary but i am sure it's not a failue.
Note
To make the partitions exactly the same size the settings of heads and sectors on both disks must be equal
My disks now looks like:
fcmaster01:~# fdisk -l /dev/hd[ac]
Disk /dev/hda: 255 heads, 63 sectors, 14593 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 486 3903763+ fd Linux raid autodetect
/dev/hda2 487 608 979965 5 Extended
/dev/hda5 487 608 979933+ fd Linux raid autodetect
Disk /dev/hdc: 255 heads, 63 sectors, 14596 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 1 486 3903763+ 83 Linux
/dev/hdc2 487 608 979965 5 Extended
/dev/hdc5 487 608 979933+ 82 Linux swap
fcmaster01:~#
No we install mdadm for creating and managing our raids.
Important
Do NOT use raidtools2 beacause it is not stable enough to create the root raid in initrd. Also mdadm has more features to manage raid systems and has a better onfiguration file !
fcmaster01:~# apt-get install mdadm
...
Tip
It's a good choice to start the raid daemon and let it send raid error messages to you :)
Now we can create our to raid's (level 1) for root and swap:
fcmaster01:~# mdadm -C /dev/md/1 -l1 -n2 /dev/hda1 missing
mdadm: /dev/hda1 appears to contain an ext2fs file system
size=31104K mtime=Tue Jan 20 13:08:49 2004
Continue creating array? Y[1]
mdadm: array /dev/md/1 started.
fcmaster01:~# mdadm -C /dev/md/5 -l1 -n2 /dev/hda5 missing
mdadm: array /dev/md/5 started.
fcmaster01:~#
Now we can check the array either with mdadm (i.e. /dev/md/1):
fcmaster01:~# mdadm -D /dev/md1
/dev/md1:
Version : 00.90.00
Creation Time : Wed Jan 28 12:20:46 2004
Raid Level : raid1
Array Size : 3903680 (3.72 GiB 3.99 GB)
Device Size : 3903680 (3.72 GiB 3.99 GB)
Raid Disks : 2
Total Disks : 2
Preferred Minor : 1
Persistance : Superblock is persistant
Update Time : Wed Jan 28 12:20:46 2004
State : dirty, no-errors
Active Drives : 1
Working Drives : 1
Failed Drives : 1
Spare Drives : 0
Number Major Minor RaidDisk State
0 3 1 0 active sync /dev/ide/host0/bus0/target0/lun0/part1
1 0 0 1 faulty
UUID : 8dfdd70c:ba733329:6f499349:fb2c1b43
fcmaster01:~#
or with file "mdstat":
fcmaster01:~# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md5 : active raid1 ide/host0/bus0/target0/lun0/part5[0]
979840 blocks [2/1] [U_]
md1 : active raid1 ide/host0/bus0/target0/lun0/part1[0]
3903680 blocks [2/1] [U_]
unused devices: >none<
fcmaster01:~#
We use mdadm so we can also check the superblock on each partitions (i.e. /dev/hdc5):
fcmaster01:~# mdadm -E /dev/hda5
/dev/hda5:
Magic : a92b4efc
Version : 00.90.00
UUID : 967b33ef:970008ee:644b080c:94668a5b
Creation Time : Wed Jan 28 12:21:30 2004
Raid Level : raid1
Device Size : 979840 (956.87 MiB 1003.35 MB)
Raid Disks : 2
Total Disks : 2
Preferred Minor : 5
Update Time : Wed Jan 28 12:21:30 2004
State : dirty, no-errors
Active Drives : 1
Working Drives : 1
Failed Drives : 1
Spare Drives : 0
Checksum : 4f974922 - correct
Events : 0.1
Number Major Minor RaidDisk State
this 0 3 5 0 active sync /dev/ide/host0/bus0/target0/lun0/part5
0 0 3 5 0 active sync /dev/ide/host0/bus0/target0/lun0/part5
1 1 0 0 1 faulty
fcmaster01:~#
Note
The raids are running in "degraded mode". This meanst that in the arrays is only one disk but raid1 needs to for clean state. So we have our currently system on disc hdc all is right at this time :)
Now we initialize our arrays:
fcmaster01:~# mkfs.ext3 /dev/md/1
...
fcmaster01:~# mkswap /dev/md/5
Setting up swapspace version 1, size = 1003352064 bytes
fcmaster01:~#
Tip
IMO it is a good idea naming the raid devices with the same numbers as the disks. Because in our case we have only raid1 array and so it's easier to manage (md/1 is hd[ac]1, hd/5 is hd[ac]5, .. and so on).
The next step is to create our configuration file for starting the raids automatically. Here it is:
fcmaster01:~# cat /etc/mdadm/mdadm.conf
DEVICE /dev/hd[ac]*
ARRAY /dev/md/1 devices="/dev/hda1,missing"
ARRAY /dev/md/5 devices="/dev/hda5,missing"
fcmaster01:~#
Testing by stopping the raids manually and starting automatically:
fcmaster01:~# mdadm -S /dev/md/1
fcmaster01:~# mdadm -S /dev/md/5
fcmaster01:~# /etc/init.d/mdadm-raid start
Starting raid devices:
mdadm: /dev/md/1 has been started with 1 drive.
mdadm: /dev/md/5 has been started with 1 drive.
done.
fcmaster01:~#