Software RAID

Some useful links to software based RAID:

Replacing a disk

[[email protected] ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hdc3[1]
78911168 blocks [2/1] [_U]

md0 : active raid1 hdc1[1]
104320 blocks [2/1] [_U]

unused devices: <none>

Replacing a software based raid disk is fairly straight forward, however, on this occasion the system saw the new disk with different head counts and cylinders.

[[email protected] ~]# fdisk -l /dev/hda

Disk /dev/hda: 81.9 GB, 81964302336 bytes
16 heads, 63 sectors/track, 158816 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
[[email protected] ~]# fdisk -l /dev/hdc

Disk /dev/hdc: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 * 1 13 104391 fd Linux raid autodetect
/dev/hdc2 14 140 1020127+ 82 Linux swap / Solaris
/dev/hdc3 141 9964 78911280 fd Linux raid autodetect

Two ways of changing this, one includes rebooting.

  1. In grubs grub.conf change the kernel line to reflect what the values should be:
    WAS: kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/md1
    NOW: kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/md1 hda=9964,255,63
  2. Or, execute command:
    echo bios_head:255 > /proc/ide/hda/settings

In this case I went for the echo option and below are the results…

[[email protected] ~]# fdisk -l /dev/hda

Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Now, I can manually edit the partition table with fdisk /dev/hda or sfdisk.

[[email protected] ~]# sfdisk -d /dev/hdc | sfdisk /dev/hda

But, that some times gives an error, so I did it by hand with fdisk /dev/hda. Once complete/dev/hda looks the same:

[[email protected] ~]# fdisk -l /dev/hda

Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 13 104391 fd Linux raid autodetect
/dev/hda2 14 140 1020127+ 82 Linux swap / Solaris
/dev/hda3 141 9964 78911280 fd Linux raid autodetect

Restart the raid syncronisation:

[[email protected] ~]# mdadm /dev/md0 -a /dev/hda1
mdadm: hot added /dev/hda1
[[email protected] ~]# mdadm /dev/md1 -a /dev/hda3
mdadm: hot added /dev/hda3

[[email protected] ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda3[2] hdc3[1]
78911168 blocks [2/1] [_U]
[>………………..] recovery = 0.3% (241920/78911168) finish=75.8min speed=17280K/sec
md0 : active raid1 hda1[0] hdc1[1]
104320 blocks [2/2] [UU]

unused devices: <none>

Just wait for it to finish now and hope the new disk has no errors.

Don’t forget about the swap partition, in this case /dev/hdc2.  As it’s already been partitioned you will need to set it up for being a swap partition:

 [[email protected] ~]# mkswap /dev/hdc2
[[email protected] ~]# swapon /dev/hdc2

That should ensure that the swap is mounted after reboot.