Ben's Pro Tips

Tech Tips Made Easy

February 13, 2014 Linux Server Tips raid, raid1, redundancy, sync

Adding a drive to your RAID1 array on Debian/Ubuntu/Linux Mint

Last week we looked at making a single-disk system redundant by setting up a raid array. Today we’re going to see how to add a new disk to the array. It’s a good practice to have at least 3 disks, so in case one fails, you don’t have to worry about a devastating failure while a replacement is shipping.

Adding a disk is fairly easy using mdadm. You can follow these steps:

1. Install the drive into your machine

2. Boot and check fdisk -l to find its drive letter, in this example we’ll use /dev/sdg.

3. Partition the new drive using parted (commands you type are in bold):

parted -a optimal /dev/sdc
GNU Parted 2.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt 
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes 
(parted) mkpart primary 1 -1
(parted) align-check 
alignment type(min/opt) [optimal]/minimal? optimal 
Partition number? 1 
1 aligned
(parted) quit 
Information: You may need to update /etc/fstab.

4. Next add the partitioned drive to the array with madm:

mdadm --manage /dev/md0 --add /dev/sdc1

5. You’ll see it as a spare, this means it’s not being used:

/sbin/mdadm --detail /dev/md0
/dev/md0:
 Version : 1.2
 Creation Time : Fri Feb 7 11:35:08 2014
 Raid Level : raid1
 Array Size : 471741248 (449.89 GiB 483.06 GB)
 Used Dev Size : 471741248 (449.89 GiB 483.06 GB)
 Raid Devices : 2
 Total Devices : 3
 Persistence : Superblock is persistent
Update Time : Thu Feb 13 09:18:17 2014
 State : clean 
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
 Spare Devices : 1
Name : devserver:0 (local to host devserver)
 UUID : a55fd0fe:7b142a4c:ad0d9a93:e97e9483
 Events : 11194
Number Major Minor RaidDevice State
 0 8 1 0 active sync /dev/sda1
 2 8 33 1 active sync /dev/sdb1
3 8 17 - spare /dev/sdc1

6. Lastly sync it by growing your RAID array:

mdadm --grow /dev/md0 --raid-devices=3

It’ll take a while to sync up before you see it as active sync in mdadm –detail /dev/md0. You can follow these same steps for each drive you add. You now have a three (or more!) drive redundant RAID1 array.

Leave a comment

Time limit is exhausted. Please reload the CAPTCHA.