Oct 12, 2012

Configure Software Raid in Linux


The term RAID is an acronym for the phrase, Redundant Array of Independent Disks. RAID is a way of combining the storage available across multiple disks and supplying users a single, unified virtual device.
RAID can be used to provide:
  • data integrity
  • fault tolerance
  • improved performance
  • greater storage capacity
Configuring Software RAID
Configuring RAID using Linux requires a number of steps that need to be followed carefully. In the tutorial example, we will be configuring RAID 5 using a system with three pre-partitioned hard disks. The partitions to be used are:

/dev/hde1
/dev/hdf2
/dev/hdg1

RAID Partitioning
You first need to identify two or more partitions, each on a separate disk. If you are doing RAID 0 or RAID 5, the partitions should be of approximately the same size, as in this scenario. RAID limits the extent of data access on each partition to an area no larger than that of the smallest partition in the RAID set.

Determining Available Partitions
First use the fdisk -l command to view all the mounted and unmounted filesystems available on your system. You may then also want to use the df -k command, which shows only mounted filesystems but has the big advantage of giving you the mount points too.

These two commands should help you to easily identify the partitions you want to use. Here is some sample output of these commands.
[root@linuxbox tmp]# fdisk -l
Disk /dev/hda: 12.0 GB, 12072517632 bytes
255 heads, 63 sectors/track, 1467 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hda: 12.0 GB, 12072517632 bytes
255 heads, 63 sectors/track, 1467 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device BootStartEndBlocksIdSystem
/dev/hda111310439183Linux
/dev/hda2141441052257+83Linux
/dev/hda3145209522112+82Linux swap
/dev/hda42101467101048855Extended
/dev/hda52106553582463+83Linux
...     
...     
/dev/hda1514551467104391  

[root@linuxbox tmp# df -k
Filesystem1K-blocksUsedAvailableUse%Mounted on
/dev/hda21035692 163916 81916417%/
/dev/hda1 1010868357875109%/boot
/dev/hda15  1010864127917405%/data1
...     
...     
...     
/dev/hda75336664464228460134410%/var
Unmount the Partitions
You don't want anyone else accessing these partitions while you are creating the RAID set, so you need to make sure they are unmounted.

[root@linuxbox tmp]# umount /dev/hde1
[root@linuxbox tmp]# umount /dev/hdf2
[root@linuxbox tmp]# umount /dev/hdg1

Prepare The Partitions With FDISK
You have to change each partition in the RAID set to be of type FD (Linux raid autodetect), and you can do this with fdisk. Here is an example using /dev/hde1.

[root@linuxbox tmp]# fdisk /dev/hde
The number of cylinders for this disk is set to 8355.
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):
Use FDISK Help
Now use the fdisk m command to get some help:
Command (m for help): m
...
...
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition's system id
...
...
Command (m for help):





No comments:

Post a Comment