RAID 0,RAID 1,RAID 5,Explained with Diagrams:
RAID, means Redundant Array of Independent Disks (originally Redundant Array of Inexpensive Disks), is a storage technology that provides increased reliability and functions through redundancy. This is achieved by combining multiple disk drive components into a logical unit, where data is distributed across the drives in one of several ways called "RAID levels"; RAID can be handled either by the operating system software or it may be implemented via a purpose built RAID disk controller card without having to configure the operating system at all.On most situations you will be using one of the following four levels of RAIDs.
- RAID 0
- RAID 1
- RAID 5
In the figure A, B, C, D, E and F – represents blocks and p1, p2, and p3 – represents parity
RAID LEVEL 0 :
Following are the key points to remember for RAID level 0.
- Minimum 2 disks.
- Excellent performance ( as blocks are striped ).
- No redundancy ( no mirror, no parity ).
- Don’t use this for any critical system.
RAID LEVEL 1 :
Following are the key points to remember for RAID level 1.- Minimum 2 disks.
- Good performance ( no striping. no parity ).
- Excellent redundancy ( as blocks are mirrored ).
RAID LEVEL 5 :
Following are the key points to remember for RAID level 5.
- Minimum 3 disks.
- Good performance ( as blocks are striped ).
- Good redundancy ( distributed parity ).
- Best cost effective option providing both performance and redundancy. Use this for DB that is heavily read oriented. Write operations will be slow.
[root@localhost ~]# parted /dev/hda
GNU Parted 1.8.1
Using /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: SAMSUNG SP0802N (ide)
Disk /dev/hda: 80.1GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 22.7GB 22.7GB primary ntfs boot
2 22.7GB 80.1GB 57.3GB extended
5 22.7GB 54.3GB 31.6GB logical ntfs
6 54.3GB 70.0GB 15.7GB logical ext3
7 70.0GB 70.8GB 732MB logical linux-swap
8 70.8GB 71.0GB 206MB logical ext2
71.0GB 80.1GB 9089MB Free Space
[root@localhost ~]# fdisk -l
Disk /dev/hda: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2764 22201798+ 7 HPFS/NTFS
/dev/hda2 2765 9733 55978492+ 5 Extended
/dev/hda5 2765 6602 30828703+ 7 HPFS/NTFS
/dev/hda6 6603 8514 15358108+ 83 Linux
/dev/hda7 8515 8603 714861 82 Linux swap / Solaris
/dev/hda8 8604 8628 200781 83 Linux
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 15G 7.1G 6.5G 53% /
tmpfs 124M 0 124M 0% /dev/shm
/dev/hda8 190M 1.6M 179M 1% /saifulpartion
RAID Configuration for Linux :
[root@localhost ~]# fdisk /dev/hda
The number of cylinders for this disk is set to 9733.
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)
Command (m for help): n (Creat New partition)
Command action
l logical (5 or over)
p primary partition (1-4)
l(For logical Partition)
First cylinder (8629-9733, default 8629):Press Enter
Using default value 8629
Last cylinder or +size or +sizeM or +sizeK (8629-9733, default 9733): +500M(Partition size in MB)
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (8691-9733, default 8691):
Using default value 8691
Last cylinder or +size or +sizeM or +sizeK (8691-9733, default 9733): +500M
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (8753-9733, default 8753):
Using default value 8753
Last cylinder or +size or +sizeM or +sizeK (8753-9733, default 9733): +500M
Command (m for help): w(Press w for save)
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# partprobe /dev/hda(For )
[root@localhost ~]# partprobe /dev/hda
[root@localhost ~]# partprobe /dev/hda
[root@localhost ~]# fdisk -l(For check Newly create partition)
Disk /dev/hda: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2764 22201798+ 7 HPFS/NTFS
/dev/hda2 2765 9733 55978492+ 5 Extended
/dev/hda5 2765 6602 30828703+ 7 HPFS/NTFS
/dev/hda6 6603 8514 15358108+ 83 Linux
/dev/hda7 8515 8603 714861 82 Linux swap / Solaris
/dev/hda8 8604 8628 200781 83 Linux
/dev/hda9 8629 8690 497983+ 83 Linux
/dev/hda10 8691 8752 497983+ 83 Linux
/dev/hda11 8753 8814 497983+ 83 Linux
Command (m for help): L(For Search ID)
0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris
1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 82 Linux swap / So c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c7 Syrinx
5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data
6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df BootIt
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
[root@localhost ~]# fdisk /dev/hda
The number of cylinders for this disk is set to 9733.
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)
Command (m for help): t(Press t for change ID)
Partition number (1-11): 9(type partition number )
Hex code (type L to list codes): fd(write fd for convert ID to RAID)
Changed system type of partition 9 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-11): 10
Hex code (type L to list codes): fd
Changed system type of partition 10 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-11): 11
Hex code (type L to list codes): fd
Changed system type of partition 11 to fd (Linux raid autodetect)
Command (m for help): w(Press w for save)
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# fdisk -l(For show ID)
Disk /dev/hda: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2764 22201798+ 7 HPFS/NTFS
/dev/hda2 2765 9733 55978492+ 5 Extended
/dev/hda5 2765 6602 30828703+ 7 HPFS/NTFS
/dev/hda6 6603 8514 15358108+ 83 Linux
/dev/hda7 8515 8603 714861 82 Linux swap / Solaris
/dev/hda8 8604 8628 200781 83 Linux
/dev/hda9 8629 8690 497983+ fd Linux raid autodetect
/dev/hda10 8691 8752 497983+ fd Linux raid autodetect
/dev/hda11 8753 8814 497983+ fd Linux raid autodetect
[root@localhost ~]# yum install mdadm(For install mdadm package)
For RAID 5:
[root@localhost ~]# mdadm -C /dev/md0 -l 5 -n 3 /dev/hda{9,10,11}
For RAID 0 :
[root@localhost ~]# mdadm -C /dev/md1 -l 0 -n 2 /dev/hda{9,10}
For RAID 1 :
[root@localhost ~]# mdadm -C /dev/md2 -l 1 -n 2 /dev/hda{9,10}
mdadm: array /dev/md0 started.
[root@localhost ~]# mkfs.ext3 /dev/md0(For change file system) mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 124672 inodes, 248928 blocks 12446 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=255852544 8 block groups 32768 blocks per group, 32768 fragments per group 15584 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# mkdir /raid5 [root@localhost ~]# mount /dev/md0 /raid5/ [root@localhost ~]# vim /etc/fstab
/dev/md0 /raid5 ext3 defaults 0 0
[root@localhost ~]# mdadm -D /dev/md0(For Show RAID devices) /dev/md0: Version : 0.90 Creation Time : Mon Oct 24 00:03:36 2011 Raid Level : raid5 Array Size : 995712 (972.54 MiB 1019.61 MB) Used Dev Size : 497856 (486.27 MiB 509.80 MB) Raid Devices : 3 Total Devices : 3 Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Mon Oct 24 00:05:28 2011 State : clean Active Devices : 3 Working Devices : 3 Failed Devices : 0 Spare Devices : 0 Layout : left-symmetric Chunk Size : 64K UUID : 58290efa:377bd1aa:c4e791dc:92062b3c Events : 0.6 Number Major Minor RaidDevice State 0 3 9 0 active sync /dev/hda9 1 3 10 1 active sync /dev/hda10 2 3 11 2 active sync /dev/hda11 [root@localhost ~]# cat /proc/mdstat
[root@localhost ~]# mdadm --detail /dev/md0 Personalities : [raid6] [raid5] [raid4] md0 : active raid5 hda11[2] hda10[1] hda9[0] 995712 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU] unused devices: <none>
just for checking-
[root@localhost ~]#mdadm --fail /dev/sda9
[root@localhost ~]#mdadm --remove /dev/sda9
now need to mount "/dev/sda9" into another one directory remove everything
which data has there then again add this by the following command
[root@localhost ~]#mdadm --add /dev/sda9
now need to umount fail remove & mount previously
then you can to see there your deleted data has restored there.