Add a software RAID to Linux
We have added this tutorial, because we use it very often ourselves. (ALT is an IT consulting company, providing support for Apple, Windows and Linux based systems and servers.) It describes steps for adding extra disks to an already existing system, not converting current ones to RAID (the disks will be wiped, so don't do it on the OS partition!) We are adding a RAID1 software RAID to most common Linux distributions (the setps 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
Contact us for any of your IT support related issues. Original article was posted on ALT IT Support Miami.