1. Raid1 require same disk size of two disk, fdisk /dev/sdb and /dev/sdc to one partition sdb1 and sdc1
[root@RHEL3 root]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 7832.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-7832, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-7832, default 7832):
Using default value 7832
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@RHEL3 root]# partprobe
[root@RHEL3 root]# fdisk -l
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1288 10241437+ 83 Linux
/dev/sda3 1289 1925 5116702+ 83 Linux
/dev/sda4 1926 7832 47447977+ f Win95 Ext'd (LBA)
/dev/sda5 1926 2435 4096543+ 83 Linux
/dev/sda6 2436 2690 2048256 83 Linux
/dev/sda7 2691 2817 1020096 82 Linux swap
/dev/sda8 2818 2830 104391 8e Linux LVM
/dev/sda9 2831 2843 104391 fd Linux raid autodetect
/dev/sda10 2844 2856 104391 83 Linux
Disk /dev/sdb: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 7832 62910508+ 83 Linux
Disk /dev/sdc: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 7832 62910508+ 83 Linux
[root@RHEL3 root]#
2. Create raid1 with mdadm
mdadm -Cv /dev/md0 -l1 -n2 -x0 -c128 /dev/sdb1 /dev/sdc1
-C: create raid
-l: raid type, 0,1, 5. etc
-c: the size of block in new raid /dev/md0
3. Status of raid
[root@RHEL3 root]# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
Event: 1
md0 : active raid1 sdc1[1] sdb1[0]
62910336 blocks [2/2] [UU]
[>....................] resync = 0.3% (199104/62910336) finish=99.6min speed=10479K/sec
unused devices:
######[UU] means normal, [U_] means abnormal.
######
4. Configuration file /etc/mdadm.conf
/etc/mdadm.conf is optional for raid running, but some command read information from it.
Such as mdadm -As
Detect information with mdadm -Ds
[root@RHEL3 root]# mdadm -Ds
mdadm: bad /proc/mdstat line starts: Event:
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=6a32b480:78bea1d2:89b65aaa:6e6c72bc
[root@RHEL3 root]#
And update above line
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=6a32b480:78bea1d2:89b65aaa:6e6c72bc
to /etc/mdadm.conf with specify format.
Steps of replace a failed disk
1. Mark failed device with -f option
mdadm /dev/md0 -f /deb/sda1
2. Remove failed device with -r option
mdadm /dev/md0 -r /dev/sda1
3. Add new device with -a option
mdadm /dev/md -a /dev/sdd1