Replace Disks in a Failed RAID1 and Grow it Afterwards

One week ago, my Linux NAS decided to spam me with mails, while I was sitting in a bar. Nothing is more disturbing, while having a nice chat and drink a beer, than your home server screaming about a failed RAID. I have to admit, I knew the RAID will fail soon, since one of the HDDs already was marked bad by SMART for some weeks…

Anyway, I shut down the server remotely and ordered immediately two new Seagate 4 TB NAS Drives. They arrived soon, but then my struggle begun. I really had no idea how to replace the HDDs in the RAID array and then grow the RAID to the new size of the HDDs, since my old drives where only 2 TB.

After some time of Google research I was aware of the steps to perform the procedure and it’s fairly easy!

(Be aware that identifier in your system might be different! Perform this steps at your own risk and make a backup before you perform anything on your system!)

  1. Shutdown the server and replace the failed HDD with the first new HDD.
  2. Now its time to create a new partition on the drive. Since my partition will be greater than 2 TB, I need to use GPT layout on the drive. This can be archived with the parted command.

    Now I have the GPT in place and can add a partition. I’ll use the whole drive as one big partition and use ext4:
  3. Add the new HDD to the RAID array and wait for the re-sync. This can take a long time, in my case 3.5 h.
  4. After the re-sync, remove the last old HDD with the following commands:
  5. Now shutdown the system again and replace the second old HDD with a new one.
  6. Repeat the steps 2 and 3 on the new drive.
  7. Now it’s time to grow the array. Let’s have a look first:

    Ok, looks great. Notice the line 4 where the block number is displayed. 1953382208 1024K blocks equal to 2 TB or 1.82 TiB. Now let’s gow the array with mdadm:
  8. So, now the virtual disk is bigger, but the partition is still 2 TB. So we have to grow this as well:
  9. And we are done!

I repeated some steps in a virtual machine for this blog post, so if you find some mismatches in the sizes etc. its most likely from that. Feel free to drop a comment for errata requests! 🙂


Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *