linux software raid 5 quick guide
Here will create a raid 5 setup with three drives for redundant storage using mdadm (not raidtools). This example does not include putting your O.S. root partion on the raid device. It is only for a volume to be mounted by Linux which boots off of another device.
Number of drives: 3 Number of spare drives: 0 All drives same size All space used on all drives devices to be used in this example: sdb sdc sdd
Contents |
kernel config
Check for support If your system has RAID support, you should have a file called /proc/mdstat. If you do not have that file, maybe your kernel does not have RAID support. For more info on configuring your linux kernel for software raid, go here
install mdadm
prepare disks
check existing partition tables
this command will dump the partitions for all three drives
# fdisk -l /dev/sd[bcd]
Assumming you have 3 drives with no data to preserve or they are new, delete the existing partions in preparation for creating new partitions of type "Linux raid autodetect"
create three raid partions
assuming they don't already exist...
linux # fdisk /dev/sdb
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. Welcome to fdisk (util-linux 2.22.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): Using default value 1 First sector (2048-1953525167, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-1953525167, default 1953525167): Using default value 1953525167 Partition 1 of type Linux and of size 931.5 GiB is set
Command (m for help): t Selected partition 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
Duplicate the sdb partition tables to sdc and sdd. You can re-run fdisk two more times, or just run this.
# sfdisk -d /dev/sdb | sfdisk /dev/sdc; sfdisk -d /dev/sdb | sfdisk /dev/sdd
Verify the partition layout
Partitions should look similar to the following:
# fdisk -l /dev/sd[bcd] | grep -A 1 Device Device Boot Start End Blocks Id System /dev/sdb1 2048 1953525167 976761560 fd Linux raid autodetect -- Device Boot Start End Blocks Id System /dev/sdc1 2048 1953525167 976761560 fd Linux raid autodetect -- Device Boot Start End Blocks Id System /dev/sdd1 2048 1953525167 976761560 fd Linux raid autodetect
Creating an array
Links
this guide is recommended by the linux kernel help... [Software RAID HOWTO]