Difference between revisions of "linux software raid 5 quick guide"

From thelinuxwiki
Jump to: navigation, search
Line 5: Line 5:
 
All drives same size
 
All drives same size
 
All space used on all drives
 
All space used on all drives
 
+
devices to be used in this example: sdb sdc sdd
  
  
Line 19: Line 19:
 
== prepare disks ==
 
== prepare disks ==
  
 +
'''check existing partition tables'''
 +
 +
this command will dump the partitions for all three drives
 
  # '''fdisk -l /dev/sd[bcd]'''
 
  # '''fdisk -l /dev/sd[bcd]'''
<br>Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
 
Units = sectors of 1 * 512 = 512 bytes
 
Sector size (logical/physical): 512 bytes / 4096 bytes
 
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
Disk identifier: 0xa9c961d6
 
  <br>Device Boot      Start        End      Blocks  Id  System
 
<br>Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
 
Units = sectors of 1 * 512 = 512 bytes
 
Sector size (logical/physical): 512 bytes / 4096 bytes
 
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
Disk identifier: 0xfff8a252
 
  <br>Device Boot      Start        End      Blocks  Id  System
 
<br>Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
 
Units = sectors of 1 * 512 = 512 bytes
 
Sector size (logical/physical): 512 bytes / 4096 bytes
 
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 
Disk identifier: 0xa2e90880
 
  <br>Device Boot      Start        End      Blocks  Id  System
 
  
create three raid partions of equal size on 3 disks
+
 
 +
'''create three raid partions'''
 +
 
 +
assuming they don't already exist...
 +
 
 +
linux # '''fdisk /dev/sdb'''
 +
<br>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).
 +
<br>Changes will remain in memory only, until you decide to write them.
 +
Be careful before using the write command.
 +
<br><br>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
 +
<br>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)
 +
<br>Command (m for help): w
 +
The partition table has been altered!
 +
<br>Calling ioctl() to re-read partition table.
 +
Syncing disks.
 +
 
 +
 
  
  

Revision as of 19:28, 30 March 2014

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]


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.



Creating an array

Links

this guide is recommended by the linux kernel help... [Software RAID HOWTO]