Introduction
This HOWTO cover how to replace one drive at a time in order to upgrade the capacity without the need of more controllers or physical space for extra drives.
Preperation
List all drives and their serial numbers to easily find the drives physically på reading the serial number of the drives.
for d in /dev/sd? ; do
s="$(hdparm -I $d 2>/dev/null | grep -Fi "serial number")"
m="$(hdparm -I $d | grep -Fi "model number")"
echo $d
echo $m
echo $s
printf -- "---------------------\n\n"
done
List the available raid devices with cat /proc/mdstat
and make sure all arrays are fully funtional and no drives have failed.
cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md126 : active raid1 sda1[0] sdb1[1]
7813893120 blocks super 1.2 [2/2] [UU]
bitmap: 3/59 pages [12KB], 65536KB chunk
md3 : active raid1 sde1[1] sdh1[0]
5860389888 blocks super 1.2 [2/2] [UU]
bitmap: 0/44 pages [0KB], 65536KB chunk
md1 : active raid1 sdd1[2] sdc1[0]
5860389888 blocks super 1.2 [2/2] [UU]
bitmap: 0/44 pages [0KB], 65536KB chunk
md2 : active raid1 sdf1[3] sdg1[2]
7813894471 blocks super 1.2 [2/2] [UU]
bitmap: 0/30 pages [0KB], 131072KB chunk
md127 : active raid1 sdn1[0] sdj1[1]
7813893120 blocks super 1.2 [2/2] [UU]
bitmap: 0/59 pages [0KB], 65536KB chunk
md0 : active raid1 sdl1[1] sdm1[0]
244066304 blocks super 1.2 [2/2] [UU]
bitmap: 0/2 pages [0KB], 65536KB chunk
unused devices: <none>
Find the raid device you want to extend. In this example we will upgrade /dev/md1 from 6TB drives to 18TB drives. We will first replace /dev/sdd and then /dev/sdc.
Step 1 - Mark drive as failed and remove it
In order to replace the drive /dev/sdd we first need to mark it as failed and then remove it from the array with the commands mdadm --manage /dev/md1 --fail /dev/sdd1
followed by mdadm --manage /dev/md1 --remove /dev/hdd1
.
Step 2 - Unplug the drive
If you can hotunplug/hotplug your drives you first need to remove it from the host with the command echo 1 > /sys/block/sdd/device/delete
. Otherwise shutdown the server with the command poweroff
.
Step 3 - Replace the drive
Unplug the drive and install the new drive. If you have hotplugged the new drive and it does not show up, perform a new search with the command: echo "- - -" > /sys/class/scsi_host/hostX/scan
(make sure to replace the X with the ID of your scsi host).
Step 4 - Verify and add the new drive to the array
First create a partition table on the new drive and add a partition with the command parted /dev/sdd mktable gpt
followed by adding a partition of type 29 (Linux RAID) with the command fdisk /dev/sdd
.
Next make sure the drive is free from any previous array with the command mdadm --examine /dev/sdd1
. This command shall return mdadm: No md superblock detected on /dev/sdd1
.
Now we are ready to add the new disk back to the array with the command mdadm --manage /dev/md1 --add /dev/sdd1
.
Step 5 - Watch the array synchronize
watch -n 1 cat /proc/mdstat
When the array has synced, it's time to continue to step 6.
Step 6 - Replace the next drive
Start over on step 1 but this time we will replace /dev/sdd
with /dev/sdc
in all command.
Step 7 - Grow the array to the new size
When all drives has been replaced we need to grow the array to the new physical size of the drives with the command mdadm --grow /dev/md1 --size=max