united states of america usa  linkedinfacebookgoogle
Add a software raid to Linux

linux-icon-19This tutorial is for adding extra disks to an already existing system, not conerting current ones to RAID. We are adding a RAID1 software RAID to most common Linux distributions (this should work on any one of them).

We have used 2 disks for this:
/dev/sdb: 500.1
/dev/sdc 500.1

First disk

fdisk /dev/sdb
Command (m for help): <-- n
Command action
   e   extended
   p   primary partition <-- p
Partition number (1-4): <-- 1
Command (m for help): <-- t
Hex code (type L to list codes): <-- fd

Save all:

Command (m for help): <-- w

Run this command only if the disks were previously used in a software RAID configuration

mdadm --zero-superblock /dev/sdb1

Let's see which ones we already have:

cat /proc/mdstat
md1 : active raid1 sda5[0] sdg5[1]
      441378816 blocks super 1.2 [2/2] [UU]
      bitmap: 2/4 pages [8KB], 65536KB chunk
md0 : active raid1 sda1[0] sdg1[1]
      46840832 blocks super 1.2 [2/2] [UU]

We already have md0 and md1, so let's call our new disk md2:

mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb1

Format it as ext4

mkfs.ext4 /dev/md2

Generate new config:

cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm --examine --scan >> /etc/mdadm/mdadm.conf

Second Disk

fdisk /dev/sdc

Command (m for help): <-- n
Command action
   e   extended
   p   primary partition <-- p
Partition number (1-4): <-- 1
Command (m for help): <-- t
Hex code (type L to list codes): <-- fd

Save all:

Command (m for help): <-- w

Then add the disk to the array

mdadm --add /dev/md2 /dev/sdc1

 

Tel: (786) 646-6461   |   Toll-Free: (877) 454-0758
18350 NW 2nd Ave, Suite 406E, Miami, FL, 33169, USA
Privacy Policy