
To install using software RAID you need to install CentOS using the graphical install program. Its a little tricky to configure RAID but once you get your head round it things start to take shape.
|
Create two 100M Software RAID partition. One on EACH disk. |
|
|
Create two 490Gb Software RAID partition. One on EACH disk. |
|
|
Create a RAID group /dev/md0 with an ext3 filesystem with a mount point of /boot. |
|
|
Create a RAID group /dev/md1 with a Volume Group filesystem. There should be no moint point. Call the volume group something other than default. e.g. VolGroupSW01. More about this later. |
|
|
Create as many ext3 Logical Volumes as you need on this volume group. i.e. / /var /home etc. Do not forget to create a swapfile. |
My RAID partitions looked like this.:
[root@vader ~]# fdisk -l Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 fd Linux raid autodetect /dev/sda2 14 60801 488279610 fd Linux raid autodetect Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 * 1 13 104391 fd Linux raid autodetect /dev/sdb2 14 60801 488279610 fd Linux raid autodetect |
These partitions are grouped into RAID1:
|
/dev/md0 = /dev/sda1 and /dev/sdb1 |
|
|
/dev/md1 = /dev/sda2 and /dev/sdb2 |
These partitions are grouped into RAID1:
[root@vader ~]# mdadm --examine --scan /dev/sda1 ARRAY /dev/md0 level=raid1 num-devices=2 UUID=bca3ce06:38a364ce:6724e86c:a15c8963 [root@vader ~]# mdadm --examine --scan /dev/sda2 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=b68ba15e:cf6724e8:087c3994:c7a154a6 [root@vader ~]# mdadm --examine --scan /dev/sdb1 ARRAY /dev/md0 level=raid1 num-devices=2 UUID=bca3ce06:38a364ce:6724e86c:a15c8963 [root@vader ~]# mdadm --examine --scan /dev/sdb2 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=b68ba15e:cf6724e8:087c3994:c7a154a6 |
The RAID partition /dev/md1 is assigned to the volume group VolGroupSW02:
[root@vader ~]# pvscan PV /dev/md1 VG VolGroupSW01 lvm2 [465.66 GB / 0 free] Total: 1 [465.66 GB] / in use: 1 [465.66 GB] / in no VG: 0 [0 ] |
Inside the Volume Group there are Logical Volumes:
[root@vader ~]# lvscan ACTIVE '/dev/VolGroupSW01/LogVol01' [5.34 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol02' [10.00 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol03' [448.31 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol00' [2.00 GB] inherit |
The /etc/fstab file tells Linux where to mount the Logical Volumes:
[root@vader log]# cat /etc/fstab /dev/VolGroupSW01/LogVol01 / ext3 defaults 1 1 /dev/VolGroupSW01/LogVol02 /var ext3 defaults 1 2 /dev/VolGroupSW01/LogVol03 /data ext3 defaults 1 2 /dev/md0 /boot ext3 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/VolGroupSW01/LogVol00 swap swap defaults 0 0 |
The fileysystem layout looks like this:
[root@vader ~]# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroupSW01-LogVol01 5427652 1286960 3860528 26% / /dev/mapper/VolGroupSW01-LogVol02 10158648 211080 9423280 3% /var /dev/mapper/VolGroupSW01-LogVol03 455366520 248766500 187796432 57% /data /dev/md0 101018 11740 84062 13% /boot tmpfs 224740 0 224740 0% /dev/shm |
The plan is to put all my data on LogVol03 which is mounted on /data.
These Logical volumes can easily be resized: Resizing RAID Logical Volumes.
The Logical Volumes are on top of RAID1 giving data redundancy: How to recover a RAID disk.
The cool thing about LVMs is that you can easily resize them. This is like using HP-UX a decado ago!!.
I reduced /var from its initial 20Gb to 10Gb. Note you need to unmount the filesystem to resize LVMs. To unmount /var you need to be in single user mode.
e2fsck -f /dev/VolGroupSW01-LogVol02 resize2fs -L-10G /dev/VolGroupSW01-LogVol02 lvreduce -L 10G /dev/VolGroupSW01-LogVol02 |
I then extended /data using the freed up 10Gb. Note you need to unmount the filesystem to resize LVMs.
lvextend -L+10G /dev/VolGroupSW01-LogVol03 e2fsck -f /dev/VolGroupSW01-LogVol03 resize2fs /dev/VolGroupSW01-LogVol03 |
When a RAID disk fails putting the good disk in another computer and reading it is not straight forward.
First we need to check which partitions are on the disk:
[root@vader dev]# fdisk -l Disk /dev/sdc: 38913 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sdc1 * 0+ 12 13- 104391 fd Linux raid autodetect /dev/sdc2 13 38912 38900 312464250 fd Linux raid autodetect /dev/sdc3 0 - 0 0 0 Empty /dev/sdc4 0 - 0 0 0 Empty |
The interesting one here the larger /dev/sdc2 which is where my old /data volume was in. But first we need to mount the RAID Volume Group before we can get to the Logical Volumes. To do this we need to examine the partition:
[root@vader dev]# mdadm --examine --scan /dev/sdc2 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=7bf4df0f:6dc46235:aa08cacf:e5805443 |
Add the ARRAY line above to the /etc/mdadm.conf file:
[root@vader dev]# mdadm --examine --scan /dev/sdc2 >> /etc/mdadm.conf [root@vader dev]# cat /etc/mdadm.conf # mdadm.conf written out by anaconda DEVICE partitions MAILADDR root ARRAY /dev/md0 level=raid1 num-devices=2 uuid=bca3ce06:38a364ce:6724e86c:a15c8963 ARRAY /dev/md1 level=raid1 num-devices=2 uuid=b68ba15e:cf6724e8:087c3994:c7a154a6 ARRAY /dev/md1 level=raid1 num-devices=2 UUID=7bf4df0f:6dc46235:aa08cacf:e5805443 |
Edit /ect/mdadm.conf and change /dev/md1 to an unused mount point, for example /dev/md2:
[root@vader dev]# vi /etc/mdadm.conf # mdadm.conf written out by anaconda DEVICE partitions MAILADDR root ARRAY /dev/md0 level=raid1 num-devices=2 uuid=bca3ce06:38a364ce:6724e86c:a15c8963 ARRAY /dev/md1 level=raid1 num-devices=2 uuid=b68ba15e:cf6724e8:087c3994:c7a154a6 ARRAY /dev/md2 level=raid1 num-devices=2 UUID=7bf4df0f:6dc46235:aa08cacf:e5805443 |
Next activate the RAID /dev/md2 partition.
[root@vader dev]# mdadm -A -s -a yes mdadm: /dev/md0 is already active. mdadm: /dev/md1 is already active. mdadm: /dev/md2 has been started with 1 drive (out of 2). |
Next check the Volume Groups. Note the differrent names! This is where life can get tricky if your Volume Group name is the same as the current Volume Group. This is why you should always change the Volume Group names from default. (The solution to clashing Volume Group names is to boot off a LiveCD and change the Volume Group name.)
[root@vader dev]# pvscan PV /dev/md2 VG VolGroup00 lvm2 [297.97 GB / 0 free] PV /dev/md1 VG VolGroupSW01 lvm2 [465.66 GB / 0 free] |
Activate the Volume Group:
[root@vader dev]# vgchange VolGroup00 -a y 4 logical volume(s) in volume group "VolGroup00" now active |
Scan the active Volume Groups for Logical Volumes. Its /dev/VolGroup00 we are interested in here:
[root@vader dev]# lvscan ACTIVE '/dev/VolGroup00/LogVol01' [4.88 GB] inherit ACTIVE '/dev/VolGroup00/LogVol02' [4.88 GB] inherit ACTIVE '/dev/VolGroup00/LogVol03' [287.22 GB] inherit ACTIVE '/dev/VolGroup00/LogVol00' [1.00 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol01' [5.34 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol02' [19.53 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol03' [438.78 GB] inherit ACTIVE '/dev/VolGroupSW01/LogVol00' [2.00 GB] inherit |
Mount the required Logical Volumes and recover the data:
mkdir /olddata [root@vader dev]# mount /dev/VolGroup00/LogVol03 /olddata |