RAID Configuration Tutorial:
In this example i am using 5 disks with 1GB size.
To check the new attached disks run
fdisk -l ............. To lists the disks and partitions
It list all the partitions.
Already two disks with LVM has listed.
New disks are:
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf
To create the new partition run the following command
fdisk /dev/sdb
press "m" for help
press "n" for creating new partition
To create a new partition,
press "n" then press "p" for the primary partition.
To print the partition , press "p"
The new partition /dev/sdb1 is linux partition.
To list the available system id press "l"
83 -- linux
8e -- LVM
fd --- Linux RAID auto detect
To change the system id for the existing partition, press "t"
Type "fd" --- Linux raid autodetect
Press "p" to print the partition table.
Press "w" to write the new partition.
To list the partition , type fdisk -l
To create RAID array the following command is used.
mdadm
mdadm --create <device name> --level=RAIDLEVEL --raid-devices=<no of disks> device names.
For example:
mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
Array /dev/md0 created and started.
To check the status of the array, run the following command
cat /proc/mdstat
All are in active mode.
Now the array is activated then we need to create the file system.
For creating file system, use the following command.
mkfs -t ext3 /dev/md0
Now the file file system successfully created. Then we need to mount the file system in the mount point.
To mount, create one directory using mkdir /rdata
Now mount the the array.
mount -t ext3 /dev/md0 /rdata
Use the following command to check the file system mount status and mount point.
mount
df -h
To list the RAID array details, use the following command.
mdadm --detail /dev/md0
Adding the Hot Spare disks use the following command.
mdadm --manage /dev/md0 --add /dev/sdf1
This will add the spare to disk to the array. to check this use the following command.
cat /proc/mdstat
mdadm --detail /dev/md0
Mount command output.
Now i am accessing the file system and creating the new directories and files.
If the disk fails, the spare disk replaces as the data disk without affecting the file system operations.
Use following command to fail the disk.
mdadm --manage /dev/md0 --fail /dev/sdb1
Even if the disk is failed, still the file system is working.
The output of mdadm --detail /dev/md0
Now no spare disk. The spare disk replaced as a data disk.
To remove the fail disk use the following command.
mdadm --manage /dev/md0 --remove /dev/sdb1
Now check the the array using,
mdadm --detail /dev/md0
To add a new disk to an existing array, use the following command.
mdadm --manage /dev/md0 --add /dev/sdb1
Now the new disk added as a spare disk.
Out of the mdadm --detail /dev/md0
Really a good article sir.....Very simple to understand.
ReplyDelete